Skip to content

Commit c617a8e

Browse files
committed
Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
1 parent 2444494 commit c617a8e

19 files changed

+28
-28
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,14 +969,14 @@ fn binding_ty_auto_deref_stability<'tcx>(
969969
precedence: i8,
970970
binder_args: &'tcx List<BoundVariableKind>,
971971
) -> Position {
972-
let TyKind::Rptr(_, ty) = &ty.kind else {
972+
let TyKind::Ref(_, ty) = &ty.kind else {
973973
return Position::Other(precedence);
974974
};
975975
let mut ty = ty;
976976

977977
loop {
978978
break match ty.ty.kind {
979-
TyKind::Rptr(_, ref ref_ty) => {
979+
TyKind::Ref(_, ref ref_ty) => {
980980
ty = ref_ty;
981981
continue;
982982
},

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
152152
let input_lifetimes: Vec<LifetimeName> = inputs
153153
.iter()
154154
.filter_map(|ty| {
155-
if let TyKind::Rptr(lt, _) = ty.kind {
155+
if let TyKind::Ref(lt, _) = ty.kind {
156156
Some(lt.res)
157157
} else {
158158
None

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3986,7 +3986,7 @@ impl OutType {
39863986
(Self::Unit, &hir::FnRetTy::Return(ty)) if is_unit(ty) => true,
39873987
(Self::Bool, &hir::FnRetTy::Return(ty)) if is_bool(ty) => true,
39883988
(Self::Any, &hir::FnRetTy::Return(ty)) if !is_unit(ty) => true,
3989-
(Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Rptr(_, _)),
3989+
(Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Ref(_, _)),
39903990
_ => false,
39913991
}
39923992
}

clippy_lints/src/mut_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
8686
return;
8787
}
8888

89-
if let hir::TyKind::Rptr(
89+
if let hir::TyKind::Ref(
9090
_,
9191
hir::MutTy {
9292
ty: pty,
9393
mutbl: hir::Mutability::Mut,
9494
},
9595
) = ty.kind
9696
{
97-
if let hir::TyKind::Rptr(
97+
if let hir::TyKind::Ref(
9898
_,
9999
hir::MutTy {
100100
mutbl: hir::Mutability::Mut,

clippy_lints/src/needless_arbitrary_self_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
124124
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl);
125125
}
126126
},
127-
TyKind::Rptr(lifetime, mut_ty) => {
127+
TyKind::Ref(lifetime, mut_ty) => {
128128
if_chain! {
129129
if let TyKind::Path(None, path) = &mut_ty.ty.kind;
130130
if let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind;

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'tcx> PassByRefOrValue {
184184
if is_copy(cx, ty)
185185
&& let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes())
186186
&& size <= self.ref_min_size
187-
&& let hir::TyKind::Rptr(_, MutTy { ty: decl_ty, .. }) = input.kind
187+
&& let hir::TyKind::Ref(_, MutTy { ty: decl_ty, .. }) = input.kind
188188
{
189189
if let Some(typeck) = cx.maybe_typeck_results() {
190190
// Don't lint if an unsafe pointer is created.

clippy_lints/src/ptr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
421421
if let ty::Ref(_, ty, mutability) = *ty.kind();
422422
if let ty::Adt(adt, substs) = *ty.kind();
423423

424-
if let TyKind::Rptr(lt, ref ty) = hir_ty.kind;
424+
if let TyKind::Ref(lt, ref ty) = hir_ty.kind;
425425
if let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind;
426426

427427
// Check that the name as typed matches the actual name of the type.
@@ -503,14 +503,14 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
503503

504504
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) {
505505
if let FnRetTy::Return(ty) = sig.decl.output
506-
&& let Some((out, Mutability::Mut, _)) = get_rptr_lm(ty)
506+
&& let Some((out, Mutability::Mut, _)) = get_ref_lm(ty)
507507
{
508508
let out_region = cx.tcx.named_region(out.hir_id);
509509
let args: Option<Vec<_>> = sig
510510
.decl
511511
.inputs
512512
.iter()
513-
.filter_map(get_rptr_lm)
513+
.filter_map(get_ref_lm)
514514
.filter(|&(lt, _, _)| cx.tcx.named_region(lt.hir_id) == out_region)
515515
.map(|(_, mutability, span)| (mutability == Mutability::Not).then_some(span))
516516
.collect();
@@ -704,8 +704,8 @@ fn matches_preds<'tcx>(
704704
})
705705
}
706706

707-
fn get_rptr_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
708-
if let TyKind::Rptr(lt, ref m) = ty.kind {
707+
fn get_ref_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
708+
if let TyKind::Ref(lt, ref m) = ty.kind {
709709
Some((lt, m.mutbl, ty.span))
710710
} else {
711711
None

clippy_lints/src/redundant_static_lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl RedundantStaticLifetimes {
5959
}
6060
},
6161
// This is what we are looking for !
62-
TyKind::Rptr(ref optional_lifetime, ref borrow_type) => {
62+
TyKind::Ref(ref optional_lifetime, ref borrow_type) => {
6363
// Match the 'static lifetime
6464
if let Some(lifetime) = *optional_lifetime {
6565
match borrow_type.ty.kind {

clippy_lints/src/ref_option_ref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ declare_lint_pass!(RefOptionRef => [REF_OPTION_REF]);
3939
impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
4040
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
4141
if_chain! {
42-
if let TyKind::Rptr(_, ref mut_ty) = ty.kind;
42+
if let TyKind::Ref(_, ref mut_ty) = ty.kind;
4343
if mut_ty.mutbl == Mutability::Not;
4444
if let TyKind::Path(ref qpath) = &mut_ty.ty.kind;
4545
let last = last_path_segment(qpath);
@@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
5252
GenericArg::Type(inner_ty) => Some(inner_ty),
5353
_ => None,
5454
});
55-
if let TyKind::Rptr(_, ref inner_mut_ty) = inner_ty.kind;
55+
if let TyKind::Ref(_, ref inner_mut_ty) = inner_ty.kind;
5656
if inner_mut_ty.mutbl == Mutability::Not;
5757

5858
then {

clippy_lints/src/transmute/transmute_ptr_to_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub(super) fn check<'tcx>(
7171
/// Gets the type `Bar` in `…::transmute<Foo, &Bar>`.
7272
fn get_explicit_type<'tcx>(path: &'tcx Path<'tcx>) -> Option<&'tcx hir::Ty<'tcx>> {
7373
if let GenericArg::Type(ty) = path.segments.last()?.args?.args.get(1)?
74-
&& let TyKind::Rptr(_, ty) = &ty.kind
74+
&& let TyKind::Ref(_, ty) = &ty.kind
7575
{
7676
Some(ty.ty)
7777
} else {

clippy_lints/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl Types {
539539
QPath::LangItem(..) => {},
540540
}
541541
},
542-
TyKind::Rptr(lt, ref mut_ty) => {
542+
TyKind::Ref(lt, ref mut_ty) => {
543543
context.is_nested_call = true;
544544
if !borrowed_box::check(cx, hir_ty, lt, mut_ty) {
545545
self.check_ty(cx, mut_ty.ty, context);

clippy_lints/src/types/type_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
4444
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
4545
let (add_score, sub_nest) = match ty.kind {
4646
// _, &x and *x have only small overhead; don't mess with nesting level
47-
TyKind::Infer | TyKind::Ptr(..) | TyKind::Rptr(..) => (1, 0),
47+
TyKind::Infer | TyKind::Ptr(..) | TyKind::Ref(..) => (1, 0),
4848

4949
// the "normal" components of a type: named types, arrays/tuples
5050
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),

clippy_lints/src/types/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>)
1313
GenericArg::Type(ty) => Some(ty),
1414
_ => None,
1515
});
16-
if let TyKind::Rptr(..) = ty.kind;
16+
if let TyKind::Ref(..) = ty.kind;
1717
then {
1818
return Some(ty.span);
1919
}

clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
257257
}
258258

259259
pub(super) fn is_lint_ref_type(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
260-
if let TyKind::Rptr(
260+
if let TyKind::Ref(
261261
_,
262262
MutTy {
263263
ty: inner,

clippy_utils/src/ast_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
625625
(Slice(l), Slice(r)) => eq_ty(l, r),
626626
(Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value),
627627
(Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty),
628-
(Rptr(ll, l), Rptr(rl, r)) => {
628+
(Ref(ll, l), Ref(rl, r)) => {
629629
both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
630630
},
631631
(BareFn(l), BareFn(r)) => {

clippy_utils/src/hir_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl HirEqInterExpr<'_, '_, '_> {
430430
(&TyKind::Slice(l_vec), &TyKind::Slice(r_vec)) => self.eq_ty(l_vec, r_vec),
431431
(&TyKind::Array(lt, ll), &TyKind::Array(rt, rl)) => self.eq_ty(lt, rt) && self.eq_array_length(ll, rl),
432432
(TyKind::Ptr(l_mut), TyKind::Ptr(r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(l_mut.ty, r_mut.ty),
433-
(TyKind::Rptr(_, l_rmut), TyKind::Rptr(_, r_rmut)) => {
433+
(TyKind::Ref(_, l_rmut), TyKind::Ref(_, r_rmut)) => {
434434
l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(l_rmut.ty, r_rmut.ty)
435435
},
436436
(TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r),
@@ -950,7 +950,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
950950
self.hash_ty(mut_ty.ty);
951951
mut_ty.mutbl.hash(&mut self.s);
952952
},
953-
TyKind::Rptr(lifetime, ref mut_ty) => {
953+
TyKind::Ref(lifetime, ref mut_ty) => {
954954
self.hash_lifetime(lifetime);
955955
self.hash_ty(mut_ty.ty);
956956
mut_ty.mutbl.hash(&mut self.s);

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2264,7 +2264,7 @@ pub fn peel_hir_ty_refs<'a>(mut ty: &'a hir::Ty<'a>) -> (&'a hir::Ty<'a>, usize)
22642264
let mut count = 0;
22652265
loop {
22662266
match &ty.kind {
2267-
TyKind::Rptr(_, ref_ty) => {
2267+
TyKind::Ref(_, ref_ty) => {
22682268
ty = ref_ty.ty;
22692269
count += 1;
22702270
},

clippy_utils/src/sugg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,9 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
813813
let closure_body = cx.tcx.hir().body(body);
814814
// is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
815815
// a type annotation is present if param `kind` is different from `TyKind::Infer`
816-
let closure_arg_is_type_annotated_double_ref = if let TyKind::Rptr(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
816+
let closure_arg_is_type_annotated_double_ref = if let TyKind::Ref(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
817817
{
818-
matches!(ty.kind, TyKind::Rptr(_, MutTy { .. }))
818+
matches!(ty.kind, TyKind::Ref(_, MutTy { .. }))
819819
} else {
820820
false
821821
};

clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bo
496496
/// Returns the base type for HIR references and pointers.
497497
pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
498498
match ty.kind {
499-
TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
499+
TyKind::Ptr(ref mut_ty) | TyKind::Ref(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
500500
_ => ty,
501501
}
502502
}

0 commit comments

Comments
 (0)