]> git.lizzy.rs Git - rust.git/commitdiff
Rename `Rptr` to `Ref` in AST and HIR
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Wed, 28 Dec 2022 17:06:11 +0000 (18:06 +0100)
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>
Wed, 28 Dec 2022 17:52:36 +0000 (18:52 +0100)
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.

19 files changed:
clippy_lints/src/dereference.rs
clippy_lints/src/manual_async_fn.rs
clippy_lints/src/methods/mod.rs
clippy_lints/src/mut_mut.rs
clippy_lints/src/needless_arbitrary_self_type.rs
clippy_lints/src/pass_by_ref_or_value.rs
clippy_lints/src/ptr.rs
clippy_lints/src/redundant_static_lifetimes.rs
clippy_lints/src/ref_option_ref.rs
clippy_lints/src/transmute/transmute_ptr_to_ref.rs
clippy_lints/src/types/mod.rs
clippy_lints/src/types/type_complexity.rs
clippy_lints/src/types/utils.rs
clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs
clippy_utils/src/ast_utils.rs
clippy_utils/src/hir_utils.rs
clippy_utils/src/lib.rs
clippy_utils/src/sugg.rs
clippy_utils/src/ty.rs

index 7b43d8ccc67d1fec92a5be0389860e9c8c6658a5..05f2b92c037093affa39e21fe5ac1dc058528cb6 100644 (file)
@@ -969,14 +969,14 @@ fn binding_ty_auto_deref_stability<'tcx>(
     precedence: i8,
     binder_args: &'tcx List<BoundVariableKind>,
 ) -> Position {
-    let TyKind::Rptr(_, ty) = &ty.kind else {
+    let TyKind::Ref(_, ty) = &ty.kind else {
         return Position::Other(precedence);
     };
     let mut ty = ty;
 
     loop {
         break match ty.ty.kind {
-            TyKind::Rptr(_, ref ref_ty) => {
+            TyKind::Ref(_, ref ref_ty) => {
                 ty = ref_ty;
                 continue;
             },
index 075ecbe7eded37340c1b36db85654ea7996588dc..676a37e04f60269aeb16352f9e1818d70fe28975 100644 (file)
@@ -152,7 +152,7 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
     let input_lifetimes: Vec<LifetimeName> = inputs
         .iter()
         .filter_map(|ty| {
-            if let TyKind::Rptr(lt, _) = ty.kind {
+            if let TyKind::Ref(lt, _) = ty.kind {
                 Some(lt.res)
             } else {
                 None
index 561e4336593b047ed5f071e89c18f5ec6c82c69e..77be61b4793403d2a9ba489df6daab12103b8841 100644 (file)
@@ -3986,7 +3986,7 @@ fn matches(self, ty: &hir::FnRetTy<'_>) -> bool {
             (Self::Unit, &hir::FnRetTy::Return(ty)) if is_unit(ty) => true,
             (Self::Bool, &hir::FnRetTy::Return(ty)) if is_bool(ty) => true,
             (Self::Any, &hir::FnRetTy::Return(ty)) if !is_unit(ty) => true,
-            (Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Rptr(_, _)),
+            (Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Ref(_, _)),
             _ => false,
         }
     }
index bc90e131b7f3be65b1ff008599796c50d5da7f7f..64d8333a093b1143047981a19414a00cb4c33dd5 100644 (file)
@@ -86,7 +86,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
             return;
         }
 
-        if let hir::TyKind::Rptr(
+        if let hir::TyKind::Ref(
             _,
             hir::MutTy {
                 ty: pty,
@@ -94,7 +94,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
             },
         ) = ty.kind
         {
-            if let hir::TyKind::Rptr(
+            if let hir::TyKind::Ref(
                 _,
                 hir::MutTy {
                     mutbl: hir::Mutability::Mut,
index f2ffac85bf4023cc25368595e239b84c7383f7e9..5457eeec4eacf249c2b1fef96d88f3e7a62da831 100644 (file)
@@ -124,7 +124,7 @@ fn check_param(&mut self, cx: &EarlyContext<'_>, p: &Param) {
                     check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl);
                 }
             },
-            TyKind::Rptr(lifetime, mut_ty) => {
+            TyKind::Ref(lifetime, mut_ty) => {
                 if_chain! {
                 if let TyKind::Path(None, path) = &mut_ty.ty.kind;
                 if let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind;
index f9fd3645668a9959ee25a48f9fe46ba1fb9d5300..75add4ee4aadedb8747a09ff1f45c434b6c4782d 100644 (file)
@@ -184,7 +184,7 @@ fn check_poly_fn(&mut self, cx: &LateContext<'tcx>, def_id: LocalDefId, decl: &F
                     if is_copy(cx, ty)
                         && let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes())
                         && size <= self.ref_min_size
-                        && let hir::TyKind::Rptr(_, MutTy { ty: decl_ty, .. }) = input.kind
+                        && let hir::TyKind::Ref(_, MutTy { ty: decl_ty, .. }) = input.kind
                     {
                         if let Some(typeck) = cx.maybe_typeck_results() {
                             // Don't lint if an unsafe pointer is created.
index e395ff54cb15a00f0693e6f8007f9d4ab1585aab..262953042581ab5269cb97221a946830c14059ef 100644 (file)
@@ -421,7 +421,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
                 if let ty::Ref(_, ty, mutability) = *ty.kind();
                 if let ty::Adt(adt, substs) = *ty.kind();
 
-                if let TyKind::Rptr(lt, ref ty) = hir_ty.kind;
+                if let TyKind::Ref(lt, ref ty) = hir_ty.kind;
                 if let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind;
 
                 // Check that the name as typed matches the actual name of the type.
@@ -503,14 +503,14 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
 
 fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) {
     if let FnRetTy::Return(ty) = sig.decl.output
-        && let Some((out, Mutability::Mut, _)) = get_rptr_lm(ty)
+        && let Some((out, Mutability::Mut, _)) = get_ref_lm(ty)
     {
         let out_region = cx.tcx.named_region(out.hir_id);
         let args: Option<Vec<_>> = sig
             .decl
             .inputs
             .iter()
-            .filter_map(get_rptr_lm)
+            .filter_map(get_ref_lm)
             .filter(|&(lt, _, _)| cx.tcx.named_region(lt.hir_id) == out_region)
             .map(|(_, mutability, span)| (mutability == Mutability::Not).then_some(span))
             .collect();
@@ -704,8 +704,8 @@ fn matches_preds<'tcx>(
     })
 }
 
-fn get_rptr_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
-    if let TyKind::Rptr(lt, ref m) = ty.kind {
+fn get_ref_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
+    if let TyKind::Ref(lt, ref m) = ty.kind {
         Some((lt, m.mutbl, ty.span))
     } else {
         None
index 41f991a967bfd9929b025657ef21c8fc0aa573ca..44bf824aa0e2d432688e90827af89090640484dc 100644 (file)
@@ -59,7 +59,7 @@ fn visit_type(ty: &Ty, cx: &EarlyContext<'_>, reason: &str) {
                 }
             },
             // This is what we are looking for !
-            TyKind::Rptr(ref optional_lifetime, ref borrow_type) => {
+            TyKind::Ref(ref optional_lifetime, ref borrow_type) => {
                 // Match the 'static lifetime
                 if let Some(lifetime) = *optional_lifetime {
                     match borrow_type.ty.kind {
index f21b3ea6c3b05b078d8ad92ea700fc302fb9d85e..448a32b77c036d92d2d5768db876c95c9317cbb6 100644 (file)
@@ -39,7 +39,7 @@
 impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
     fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
         if_chain! {
-            if let TyKind::Rptr(_, ref mut_ty) = ty.kind;
+            if let TyKind::Ref(_, ref mut_ty) = ty.kind;
             if mut_ty.mutbl == Mutability::Not;
             if let TyKind::Path(ref qpath) = &mut_ty.ty.kind;
             let last = last_path_segment(qpath);
@@ -52,7 +52,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
                 GenericArg::Type(inner_ty) => Some(inner_ty),
                 _ => None,
             });
-            if let TyKind::Rptr(_, ref inner_mut_ty) = inner_ty.kind;
+            if let TyKind::Ref(_, ref inner_mut_ty) = inner_ty.kind;
             if inner_mut_ty.mutbl == Mutability::Not;
 
             then {
index 3dde4eee67179fd9a394b10d5799b1d93ca04748..54ac04df1c12ab9bc96a5f1e8edf7aeb80ff60b5 100644 (file)
@@ -71,7 +71,7 @@ pub(super) fn check<'tcx>(
 /// Gets the type `Bar` in `…::transmute<Foo, &Bar>`.
 fn get_explicit_type<'tcx>(path: &'tcx Path<'tcx>) -> Option<&'tcx hir::Ty<'tcx>> {
     if let GenericArg::Type(ty) = path.segments.last()?.args?.args.get(1)?
-        && let TyKind::Rptr(_, ty) = &ty.kind
+        && let TyKind::Ref(_, ty) = &ty.kind
     {
         Some(ty.ty)
     } else {
index 20978e81dc584619c5ade53fc1f15b806920fdf1..c14f056a1f2de181d41e47a99bdcbc2c09338ac1 100644 (file)
@@ -539,7 +539,7 @@ fn check_ty(&mut self, cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, mut context:
                     QPath::LangItem(..) => {},
                 }
             },
-            TyKind::Rptr(lt, ref mut_ty) => {
+            TyKind::Ref(lt, ref mut_ty) => {
                 context.is_nested_call = true;
                 if !borrowed_box::check(cx, hir_ty, lt, mut_ty) {
                     self.check_ty(cx, mut_ty.ty, context);
index 5ca4023aa5c199b3d8d2296525b2f2eb5640057b..0aa50c99c16904abed7bfd0c3ddb278a11877264 100644 (file)
@@ -44,7 +44,7 @@ fn visit_infer(&mut self, inf: &'tcx hir::InferArg) {
     fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
         let (add_score, sub_nest) = match ty.kind {
             // _, &x and *x have only small overhead; don't mess with nesting level
-            TyKind::Infer | TyKind::Ptr(..) | TyKind::Rptr(..) => (1, 0),
+            TyKind::Infer | TyKind::Ptr(..) | TyKind::Ref(..) => (1, 0),
 
             // the "normal" components of a type: named types, arrays/tuples
             TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),
index 0fa75f8f0a9be3e7c06632da3bd8bb0a7988fe37..7f43b7841ff33d887668c2b321e686db081d9d76 100644 (file)
@@ -13,7 +13,7 @@ pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>)
             GenericArg::Type(ty) => Some(ty),
             _ => None,
         });
-        if let TyKind::Rptr(..) = ty.kind;
+        if let TyKind::Ref(..) = ty.kind;
         then {
             return Some(ty.span);
         }
index 786d9608c851ee1001e1c59c36c1a0911e313544..4c3b1b131fd4caeea3f8d3951382f1a02defd374 100644 (file)
@@ -257,7 +257,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'tcx>) {
 }
 
 pub(super) fn is_lint_ref_type(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
-    if let TyKind::Rptr(
+    if let TyKind::Ref(
         _,
         MutTy {
             ty: inner,
index 49e5f283db08904b5e273449a9f3696343dcab3a..9d0263e93be756939d9e7df6c36f50e7169f6d8e 100644 (file)
@@ -625,7 +625,7 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
         (Slice(l), Slice(r)) => eq_ty(l, r),
         (Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value),
         (Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty),
-        (Rptr(ll, l), Rptr(rl, r)) => {
+        (Ref(ll, l), Ref(rl, r)) => {
             both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
         },
         (BareFn(l), BareFn(r)) => {
index 07fb6af91ba042f8a6372abb74171233ea891eb3..2bbe1a19b625a7e7eb19c77e88a8a8f2c8e566a5 100644 (file)
@@ -430,7 +430,7 @@ pub fn eq_ty(&mut self, left: &Ty<'_>, right: &Ty<'_>) -> bool {
             (&TyKind::Slice(l_vec), &TyKind::Slice(r_vec)) => self.eq_ty(l_vec, r_vec),
             (&TyKind::Array(lt, ll), &TyKind::Array(rt, rl)) => self.eq_ty(lt, rt) && self.eq_array_length(ll, rl),
             (TyKind::Ptr(l_mut), TyKind::Ptr(r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(l_mut.ty, r_mut.ty),
-            (TyKind::Rptr(_, l_rmut), TyKind::Rptr(_, r_rmut)) => {
+            (TyKind::Ref(_, l_rmut), TyKind::Ref(_, r_rmut)) => {
                 l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(l_rmut.ty, r_rmut.ty)
             },
             (TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r),
@@ -950,7 +950,7 @@ pub fn hash_tykind(&mut self, ty: &TyKind<'_>) {
                 self.hash_ty(mut_ty.ty);
                 mut_ty.mutbl.hash(&mut self.s);
             },
-            TyKind::Rptr(lifetime, ref mut_ty) => {
+            TyKind::Ref(lifetime, ref mut_ty) => {
                 self.hash_lifetime(lifetime);
                 self.hash_ty(mut_ty.ty);
                 mut_ty.mutbl.hash(&mut self.s);
index 43e2d1ec826c2343b9d6dea43c11ae3fe3789917..d863609b6a72688ac8cf171c38e9405edaa55a1a 100644 (file)
@@ -2264,7 +2264,7 @@ pub fn peel_hir_ty_refs<'a>(mut ty: &'a hir::Ty<'a>) -> (&'a hir::Ty<'a>, usize)
     let mut count = 0;
     loop {
         match &ty.kind {
-            TyKind::Rptr(_, ref_ty) => {
+            TyKind::Ref(_, ref_ty) => {
                 ty = ref_ty.ty;
                 count += 1;
             },
index b66604f33db1799d49b8fd5fb9b3ccfaa40fa1f1..a203a7afddf88bfef885aa6ba0f952c25414deda 100644 (file)
@@ -813,9 +813,9 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
         let closure_body = cx.tcx.hir().body(body);
         // is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
         // a type annotation is present if param `kind` is different from `TyKind::Infer`
-        let closure_arg_is_type_annotated_double_ref = if let TyKind::Rptr(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
+        let closure_arg_is_type_annotated_double_ref = if let TyKind::Ref(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
         {
-            matches!(ty.kind, TyKind::Rptr(_, MutTy { .. }))
+            matches!(ty.kind, TyKind::Ref(_, MutTy { .. }))
         } else {
             false
         };
index 2773da70d7880c2b387b96bfebabe33963051adb..c8d56a3be5cf356ca7c3723dd8cb29fbed2fbf79 100644 (file)
@@ -496,7 +496,7 @@ pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bo
 /// Returns the base type for HIR references and pointers.
 pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
     match ty.kind {
-        TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
+        TyKind::Ptr(ref mut_ty) | TyKind::Ref(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
         _ => ty,
     }
 }