]> git.lizzy.rs Git - rust.git/commitdiff
change to a struct variant
authorEllen <supbscripter@gmail.com>
Wed, 9 Feb 2022 11:03:27 +0000 (11:03 +0000)
committerEllen <supbscripter@gmail.com>
Sat, 12 Feb 2022 11:23:53 +0000 (11:23 +0000)
27 files changed:
compiler/rustc_hir/src/def.rs
compiler/rustc_hir/src/hir.rs
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs
compiler/rustc_lint/src/internal.rs
compiler/rustc_lint/src/pass_by_value.rs
compiler/rustc_middle/src/ty/adt.rs
compiler/rustc_mir_build/src/thir/pattern/mod.rs
compiler/rustc_passes/src/dead.rs
compiler/rustc_privacy/src/lib.rs
compiler/rustc_resolve/src/build_reduced_graph.rs
compiler/rustc_resolve/src/diagnostics.rs
compiler/rustc_resolve/src/late.rs
compiler/rustc_resolve/src/late/diagnostics.rs
compiler/rustc_resolve/src/late/lifetimes.rs
compiler/rustc_resolve/src/lib.rs
compiler/rustc_save_analysis/src/dump_visitor.rs
compiler/rustc_save_analysis/src/lib.rs
compiler/rustc_save_analysis/src/sig.rs
compiler/rustc_typeck/src/astconv/mod.rs
compiler/rustc_typeck/src/check/check.rs
compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
compiler/rustc_typeck/src/mem_categorization.rs
src/librustdoc/clean/types.rs
src/librustdoc/clean/utils.rs
src/tools/clippy/clippy_lints/src/trait_bounds.rs
src/tools/clippy/clippy_lints/src/use_self.rs
src/tools/clippy/clippy_utils/src/lib.rs

index a43cb0203dd239c757c66cdf4efcc01c33f091c5..1738e0495d8e0852efa5d07f6f942ed507bc29d5 100644 (file)
@@ -313,12 +313,12 @@ pub enum Res<Id = hir::HirId> {
     /// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint.
     ///
     /// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.
-    SelfTy(
+    SelfTy {
         /// Optionally, the trait associated with this `Self` type.
-        Option<DefId>,
-        /// Optionally, the impl associated with this `Self` type.
-        Option<(DefId, bool)>,
-    ),
+        trait_: Option<DefId>,
+        /// Optionally, the impl or adt associated with this `Self` type.
+        alias_to: Option<(DefId, bool)>,
+    },
     /// A tool attribute module; e.g., the `rustfmt` in `#[rustfmt::skip]`.
     ///
     /// **Belongs to the type namespace.**
@@ -550,7 +550,7 @@ pub fn opt_def_id(&self) -> Option<DefId> {
 
             Res::Local(..)
             | Res::PrimTy(..)
-            | Res::SelfTy(..)
+            | Res::SelfTy { .. }
             | Res::SelfCtor(..)
             | Res::ToolMod
             | Res::NonMacroAttr(..)
@@ -573,7 +573,7 @@ pub fn descr(&self) -> &'static str {
             Res::SelfCtor(..) => "self constructor",
             Res::PrimTy(..) => "builtin type",
             Res::Local(..) => "local variable",
-            Res::SelfTy(..) => "self type",
+            Res::SelfTy { .. } => "self type",
             Res::ToolMod => "tool module",
             Res::NonMacroAttr(attr_kind) => attr_kind.descr(),
             Res::Err => "unresolved item",
@@ -596,7 +596,7 @@ pub fn map_id<R>(self, mut map: impl FnMut(Id) -> R) -> Res<R> {
             Res::SelfCtor(id) => Res::SelfCtor(id),
             Res::PrimTy(id) => Res::PrimTy(id),
             Res::Local(id) => Res::Local(map(id)),
-            Res::SelfTy(a, b) => Res::SelfTy(a, b),
+            Res::SelfTy { trait_, alias_to } => Res::SelfTy { trait_, alias_to },
             Res::ToolMod => Res::ToolMod,
             Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
             Res::Err => Res::Err,
@@ -620,7 +620,7 @@ pub fn macro_kind(self) -> Option<MacroKind> {
     pub fn ns(&self) -> Option<Namespace> {
         match self {
             Res::Def(kind, ..) => kind.ns(),
-            Res::PrimTy(..) | Res::SelfTy(..) | Res::ToolMod => Some(Namespace::TypeNS),
+            Res::PrimTy(..) | Res::SelfTy { .. } | Res::ToolMod => Some(Namespace::TypeNS),
             Res::SelfCtor(..) | Res::Local(..) => Some(Namespace::ValueNS),
             Res::NonMacroAttr(..) => Some(Namespace::MacroNS),
             Res::Err => None,
index f21f17439a4007338d52a06aacdbe9ed418b1d6a..0961d0131d07cfca16b61f201f9498f26e518b24 100644 (file)
@@ -640,9 +640,8 @@ pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
             _ => return false,
         };
         match path.res {
-            Res::Def(DefKind::TyParam, def_id) | Res::SelfTy(Some(def_id), None) => {
-                def_id == param_def_id
-            }
+            Res::Def(DefKind::TyParam, def_id)
+            | Res::SelfTy { trait_: Some(def_id), alias_to: None } => def_id == param_def_id,
             _ => false,
         }
     }
index a79ed20730b5cf014eff50d71b7ccc3ac8c528f8..ba4d412cf7597f2e5caecd0d6fa5e121bbbda1b6 100644 (file)
@@ -203,7 +203,8 @@ fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) {
                         .map(|res| {
                             matches!(
                                 res,
-                                Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)
+                                Res::SelfTy { trait_: _, alias_to: _ }
+                                    | Res::Def(hir::def::DefKind::TyParam, _)
                             )
                         })
                         .unwrap_or(false) =>
index fa8cbeaaf51e2b90d374a0adfcfbb8f96bac39db..944a0996427557a7fdef625e8836d08ca4c8b019 100644 (file)
@@ -202,7 +202,7 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, ty: &Ty<'_>) -> Option<String> {
                 }
             }
             // Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
-            Res::SelfTy(None, Some((did, _))) => {
+            Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
                 if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
                     if let Some(name @ (sym::Ty | sym::TyCtxt)) =
                         cx.tcx.get_diagnostic_name(adt.did)
index 2caf929788f182f6efbc873525aa92a7824633fc..5ee263159c0fd0aedf18e7938a620acc179cf0bb 100644 (file)
@@ -54,7 +54,7 @@ fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option<Stri
                 let path_segment = path.segments.last().unwrap();
                 return Some(format!("{}{}", name, gen_args(cx, path_segment)));
             }
-            Res::SelfTy(None, Some((did, _))) => {
+            Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
                 if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
                     if cx.tcx.has_attr(adt.did, sym::rustc_pass_by_value) {
                         return Some(cx.tcx.def_path_str_with_substs(adt.did, substs));
index aa264c26de88f8ac16e66ff7cc8b5ca60078bb48..40fbea7c3d91fc7e643799b48c03347dae2fba31 100644 (file)
@@ -395,7 +395,7 @@ pub fn variant_of_res(&self, res: Res) -> &VariantDef {
             | Res::Def(DefKind::Union, _)
             | Res::Def(DefKind::TyAlias, _)
             | Res::Def(DefKind::AssocTy, _)
-            | Res::SelfTy(..)
+            | Res::SelfTy { .. }
             | Res::SelfCtor(..) => self.non_enum_variant(),
             _ => bug!("unexpected res {:?} in variant_of_res", res),
         }
index 55cf807172e02fc0b390ccd8653e4abe615a3a33..df5d2f30284aa13e5c78cc00e4b61712a5de49e7 100644 (file)
@@ -417,7 +417,7 @@ fn lower_variant_or_leaf(
                 | DefKind::AssocTy,
                 _,
             )
-            | Res::SelfTy(..)
+            | Res::SelfTy { .. }
             | Res::SelfCtor(..) => PatKind::Leaf { subpatterns },
             _ => {
                 let pattern_error = match res {
index dc3ce1afa3361beff88760c9edba3c01b66deece..e52fbc8ab92d6587285f7fb779cc2e29e53a7931 100644 (file)
@@ -104,7 +104,7 @@ fn handle_res(&mut self, res: Res) {
                     self.check_def_id(variant_id);
                 }
             }
-            Res::SelfTy(t, i) => {
+            Res::SelfTy { trait_: t, alias_to: i } => {
                 if let Some(t) = t {
                     self.check_def_id(t);
                 }
index 7c511ccbd576aeef1edd857d31075c0ce3a1fc55..e53d712224c8a7f4a5049d14a2d7116dc46cb4ed 100644 (file)
@@ -1350,7 +1350,7 @@ struct ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
 impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
     fn path_is_private_type(&self, path: &hir::Path<'_>) -> bool {
         let did = match path.res {
-            Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => return false,
+            Res::PrimTy(..) | Res::SelfTy { .. } | Res::Err => return false,
             res => res.def_id(),
         };
 
index e4d8b7d528319cd3d770784132a079f7ca5355f3..3fa9343c399adf2a32115a9c5ae63a7552764ab8 100644 (file)
@@ -991,7 +991,7 @@ fn build_reduced_graph_for_external_crate_res(&mut self, child: ModChild) {
                 _,
             )
             | Res::Local(..)
-            | Res::SelfTy(..)
+            | Res::SelfTy { .. }
             | Res::SelfCtor(..)
             | Res::Err => bug!("unexpected resolution: {:?}", res),
         }
index 1f657218a64a980591098e040e33e5e7dc58c2af..4b85531557c68d2a36b92fcf0d5e307d9bdc03a2 100644 (file)
@@ -123,7 +123,7 @@ impl<'a> Resolver<'a> {
 
                 let sm = self.session.source_map();
                 match outer_res {
-                    Res::SelfTy(maybe_trait_defid, maybe_impl_defid) => {
+                    Res::SelfTy { trait_: maybe_trait_defid, alias_to: maybe_impl_defid } => {
                         if let Some(impl_span) =
                             maybe_impl_defid.and_then(|(def_id, _)| self.opt_span(def_id))
                         {
index 6aed3223480f1a93645fb95f00ddeec878a0a0f0..9ac3e6e22bd9d81aa17f4b9c49ca1812e8acd9a3 100644 (file)
@@ -289,7 +289,7 @@ fn is_call(self) -> bool {
                         | DefKind::ForeignTy,
                     _,
                 ) | Res::PrimTy(..)
-                    | Res::SelfTy(..)
+                    | Res::SelfTy { .. }
             ),
             PathSource::Trait(AliasPossibility::No) => matches!(res, Res::Def(DefKind::Trait, _)),
             PathSource::Trait(AliasPossibility::Maybe) => {
@@ -326,7 +326,7 @@ fn is_call(self) -> bool {
                         | DefKind::TyAlias
                         | DefKind::AssocTy,
                     _,
-                ) | Res::SelfTy(..)
+                ) | Res::SelfTy { .. }
             ),
             PathSource::TraitItem(ns) => match res {
                 Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) if ns == ValueNS => true,
@@ -911,9 +911,12 @@ fn resolve_adt(&mut self, item: &'ast Item, generics: &'ast Generics) {
         self.with_current_self_item(item, |this| {
             this.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
                 let item_def_id = this.r.local_def_id(item.id).to_def_id();
-                this.with_self_rib(Res::SelfTy(None, Some((item_def_id, false))), |this| {
-                    visit::walk_item(this, item);
-                });
+                this.with_self_rib(
+                    Res::SelfTy { trait_: None, alias_to: Some((item_def_id, false)) },
+                    |this| {
+                        visit::walk_item(this, item);
+                    },
+                );
             });
         });
     }
@@ -999,8 +1002,8 @@ fn resolve_item(&mut self, item: &'ast Item) {
                 self.compute_num_lifetime_params(item.id, generics);
                 // Create a new rib for the trait-wide type parameters.
                 self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
-                    let local_def_id = this.r.local_def_id(item.id).to_def_id();
-                    this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| {
+                    let def = this.r.local_def_id(item.id).to_def_id();
+                    this.with_self_rib(Res::SelfTy { trait_: Some(def), alias_to: None }, |this| {
                         this.visit_generics(generics);
                         walk_list!(this, visit_param_bound, bounds);
 
@@ -1051,8 +1054,8 @@ fn resolve_item(&mut self, item: &'ast Item) {
                 self.compute_num_lifetime_params(item.id, generics);
                 // Create a new rib for the trait-wide type parameters.
                 self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
-                    let local_def_id = this.r.local_def_id(item.id).to_def_id();
-                    this.with_self_rib(Res::SelfTy(Some(local_def_id), None), |this| {
+                    let def = this.r.local_def_id(item.id).to_def_id();
+                    this.with_self_rib(Res::SelfTy { trait_: Some(def), alias_to: None }, |this| {
                         this.visit_generics(generics);
                         walk_list!(this, visit_param_bound, bounds);
                     });
@@ -1296,7 +1299,7 @@ fn resolve_implementation(
         // If applicable, create a rib for the type parameters.
         self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| {
             // Dummy self type for better errors if `Self` is used in the trait path.
-            this.with_self_rib(Res::SelfTy(None, None), |this| {
+            this.with_self_rib(Res::SelfTy { trait_: None, alias_to: None }, |this| {
                 // Resolve the trait reference, if necessary.
                 this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| {
                     let item_def_id = this.r.local_def_id(item_id);
@@ -1307,7 +1310,9 @@ fn resolve_implementation(
                     }
 
                     let item_def_id = item_def_id.to_def_id();
-                    this.with_self_rib(Res::SelfTy(trait_id, Some((item_def_id, false))), |this| {
+                    let res =
+                        Res::SelfTy { trait_: trait_id, alias_to: Some((item_def_id, false)) };
+                    this.with_self_rib(res, |this| {
                         if let Some(trait_ref) = opt_trait_reference.as_ref() {
                             // Resolve type arguments in the trait path.
                             visit::walk_trait_ref(this, trait_ref);
index d05f139e3bf5aaf9876a78708a614b766b967146..5d843b46ee2258899c6778baa3a49238b5fb72aa 100644 (file)
@@ -1189,7 +1189,7 @@ fn smart_resolve_context_dependent_help(
                     Applicability::HasPlaceholders,
                 );
             }
-            (Res::SelfTy(..), _) if ns == ValueNS => {
+            (Res::SelfTy { .. }, _) if ns == ValueNS => {
                 err.span_label(span, fallback_label);
                 err.note("can't use `Self` as a constructor, you must use the implemented struct");
             }
index 5a1378a3686b359146f22ddaf9053977209a9b93..3bea95fa1d554ecfcaa418cd8c909dbce92902e2 100644 (file)
@@ -2793,7 +2793,7 @@ impl SelfVisitor<'_> {
                 // Look for `self: &'a Self` - also desugared from `&'a self`,
                 // and if that matches, use it for elision and return early.
                 fn is_self_ty(&self, res: Res) -> bool {
-                    if let Res::SelfTy(..) = res {
+                    if let Res::SelfTy { .. } = res {
                         return true;
                     }
 
index 28f06ed3a261424f7ac2b71d786428f9ec6c0070..dbda59e8884b9846d2e60ad55c02b64a7fab6db0 100644 (file)
@@ -2784,7 +2784,7 @@ fn validate_res_from_ribs(
                     return Res::Err;
                 }
             }
-            Res::Def(DefKind::TyParam, _) | Res::SelfTy(..) => {
+            Res::Def(DefKind::TyParam, _) | Res::SelfTy { .. } => {
                 for rib in ribs {
                     let has_generic_params: HasGenericParams = match rib.kind {
                         NormalRibKind
@@ -2804,8 +2804,8 @@ fn validate_res_from_ribs(
                                 // HACK(min_const_generics): If we encounter `Self` in an anonymous constant
                                 // we can't easily tell if it's generic at this stage, so we instead remember
                                 // this and then enforce the self type to be concrete later on.
-                                if let Res::SelfTy(trait_def, Some((impl_def, _))) = res {
-                                    res = Res::SelfTy(trait_def, Some((impl_def, true)));
+                                if let Res::SelfTy { trait_, alias_to: Some((def, _)) } = res {
+                                    res = Res::SelfTy { trait_, alias_to: Some((def, true)) }
                                 } else {
                                     if record_used {
                                         self.report_error(
index 79d55b297fd30b308cc0b4d7849db9a5009d6b5d..0ff56a30ea005fb50d43996b0632e5c39dfe2024 100644 (file)
@@ -921,7 +921,7 @@ fn process_var_decl(&mut self, pat: &'tcx hir::Pat<'tcx>) {
                     | HirDefKind::AssocTy,
                     _,
                 )
-                | Res::SelfTy(..) => {
+                | Res::SelfTy { .. } => {
                     self.dump_path_segment_ref(id, &hir::PathSegment::from_ident(ident));
                 }
                 def => {
index 2eebddb47df5c24d2f7f4ea74ad05c36996d8b18..8b0adba9fab15b0202765c791ce53aaffc743ac0 100644 (file)
@@ -749,7 +749,7 @@ fn fn_type(seg: &hir::PathSegment<'_>) -> bool {
                 _,
             )
             | Res::PrimTy(..)
-            | Res::SelfTy(..)
+            | Res::SelfTy { .. }
             | Res::ToolMod
             | Res::NonMacroAttr(..)
             | Res::SelfCtor(..)
@@ -814,7 +814,7 @@ fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
 
     fn lookup_def_id(&self, ref_id: hir::HirId) -> Option<DefId> {
         match self.get_path_res(ref_id) {
-            Res::PrimTy(_) | Res::SelfTy(..) | Res::Err => None,
+            Res::PrimTy(_) | Res::SelfTy { .. } | Res::Err => None,
             def => def.opt_def_id(),
         }
     }
index 4971bb6d1aad7bff565fd43bf957cfae6b7620cd..3bb1d2ff35730ad5ecc45d32c641ae303ebf4ef1 100644 (file)
@@ -573,7 +573,7 @@ fn make(&self, offset: usize, id: Option<hir::HirId>, scx: &SaveContext<'_>) ->
         let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
 
         let (name, start, end) = match res {
-            Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => {
+            Res::PrimTy(..) | Res::SelfTy { .. } | Res::Err => {
                 return Ok(Signature { text: path_to_string(self), defs: vec![], refs: vec![] });
             }
             Res::Def(DefKind::AssocConst | DefKind::Variant | DefKind::Ctor(..), _) => {
index aa054043c4e886e0d9a60a0b4e2fef0286b3a3ea..2bee37c0238e02e8385296b27bede769b5c9e368 100644 (file)
@@ -1805,7 +1805,7 @@ pub fn associated_path_to_ty(
         // Find the type of the associated item, and the trait where the associated
         // item is declared.
         let bound = match (&qself_ty.kind(), qself_res) {
-            (_, Res::SelfTy(Some(_), Some((impl_def_id, _)))) => {
+            (_, Res::SelfTy { trait_: Some(_), alias_to: Some((impl_def_id, _)) }) => {
                 // `Self` in an impl of a trait -- we have a concrete self type and a
                 // trait reference.
                 let trait_ref = match tcx.impl_trait_ref(impl_def_id) {
@@ -1826,7 +1826,8 @@ pub fn associated_path_to_ty(
             }
             (
                 &ty::Param(_),
-                Res::SelfTy(Some(param_did), None) | Res::Def(DefKind::TyParam, param_did),
+                Res::SelfTy { trait_: Some(param_did), alias_to: None }
+                | Res::Def(DefKind::TyParam, param_did),
             ) => self.find_bound_for_assoc_item(param_did.expect_local(), assoc_ident, span)?,
             _ => {
                 if variant_resolution.is_some() {
@@ -2270,13 +2271,13 @@ pub fn res_to_ty(
                 let index = generics.param_def_id_to_index[&def_id];
                 tcx.mk_ty_param(index, tcx.hir().name(hir_id))
             }
-            Res::SelfTy(Some(_), None) => {
+            Res::SelfTy { trait_: Some(_), alias_to: None } => {
                 // `Self` in trait or type alias.
                 assert_eq!(opt_self_ty, None);
                 self.prohibit_generics(path.segments);
                 tcx.types.self_param
             }
-            Res::SelfTy(_, Some((def_id, forbid_generic))) => {
+            Res::SelfTy { trait_: _, alias_to: Some((def_id, forbid_generic)) } => {
                 // `Self` in impl (we know the concrete type).
                 assert_eq!(opt_self_ty, None);
                 self.prohibit_generics(path.segments);
index 18a0a8767d45bf786d6ace91f4db58fd06d12465..7adefbbbe3db20041e3c07e06375d4358a3a15ef 100644 (file)
@@ -522,7 +522,12 @@ fn nested_visit_map(&mut self) -> Self::Map {
         fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) {
             match arg.kind {
                 hir::TyKind::Path(hir::QPath::Resolved(None, path)) => match &path.segments {
-                    [PathSegment { res: Some(Res::SelfTy(_, impl_ref)), .. }] => {
+                    [
+                        PathSegment {
+                            res: Some(Res::SelfTy { trait_: _, alias_to: impl_ref }),
+                            ..
+                        },
+                    ] => {
                         let impl_ty_name =
                             impl_ref.map(|(def_id, _)| self.tcx.def_path_str(def_id));
                         self.selftys.push((path.span, impl_ty_name));
index 1b93017c5aa47da19c12768a35acc8543491debe..d05dd517f1ea32ab68d9737805309b5680d9dbcc 100644 (file)
@@ -578,7 +578,7 @@ pub fn check_struct_path(
                 _ => bug!("unexpected type: {:?}", ty),
             },
             Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
-            | Res::SelfTy(..) => match ty.kind() {
+            | Res::SelfTy { .. } => match ty.kind() {
                 ty::Adt(adt, substs) if !adt.is_enum() => {
                     Some((adt.non_enum_variant(), adt.did, substs))
                 }
index 2c2d2be8bb5141e9eac2f9c9073b64164243074b..025232ff48829f4a1dd24fec0efd57d14bd21912 100644 (file)
@@ -562,7 +562,7 @@ fn variant_index_for_adt(
             Res::Def(DefKind::Ctor(CtorOf::Struct, ..), _)
             | Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
             | Res::SelfCtor(..)
-            | Res::SelfTy(..) => {
+            | Res::SelfTy { .. } => {
                 // Structs and Unions have only have one variant.
                 Ok(VariantIdx::new(0))
             }
index 6feba34134c592397b2a95ae10d38c03c9ce431e..74184427dd5732e413ce6cf56c1383b46e42e32c 100644 (file)
@@ -1972,7 +1972,7 @@ impl Path {
     /// Checks if this is a `T::Name` path for an associated type.
     crate fn is_assoc_ty(&self) -> bool {
         match self.res {
-            Res::SelfTy(..) if self.segments.len() != 1 => true,
+            Res::SelfTy { .. } if self.segments.len() != 1 => true,
             Res::Def(DefKind::TyParam, _) if self.segments.len() != 1 => true,
             Res::Def(DefKind::AssocTy, _) => true,
             _ => false,
index dabf1e878c9fb38d3f5aaaf04f128a2cd7cd7c30..1a1755ea38cde975df6222e60d443cdc6b39b996 100644 (file)
@@ -355,7 +355,7 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: &ty::Const<'_>) ->
 
     match path.res {
         Res::PrimTy(p) => Primitive(PrimitiveType::from(p)),
-        Res::SelfTy(..) if path.segments.len() == 1 => Generic(kw::SelfUpper),
+        Res::SelfTy { .. } if path.segments.len() == 1 => Generic(kw::SelfUpper),
         Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => Generic(path.segments[0].name),
         _ => {
             let _ = register_res(cx, path.res);
@@ -398,10 +398,10 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: &ty::Const<'_>) ->
             i,
         ) => (i, kind.into()),
         // This is part of a trait definition; document the trait.
-        Res::SelfTy(Some(trait_def_id), _) => (trait_def_id, ItemType::Trait),
+        Res::SelfTy { trait_: Some(trait_def_id), alias_to: _ } => (trait_def_id, ItemType::Trait),
         // This is an inherent impl; it doesn't have its own page.
-        Res::SelfTy(None, Some((impl_def_id, _))) => return impl_def_id,
-        Res::SelfTy(None, None)
+        Res::SelfTy { trait_: None, alias_to: Some((impl_def_id, _)) } => return impl_def_id,
+        Res::SelfTy { trait_: None, alias_to: None }
         | Res::PrimTy(_)
         | Res::ToolMod
         | Res::SelfCtor(_)
index 5257f5302cd90d87c2ced61cd1f582cb2b4d1dd7..bca95b7f25638449b03f0c13d68c1d2a41d250f6 100644 (file)
@@ -98,7 +98,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'tc
                 if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
                 if !bound_predicate.span.from_expansion();
                 if let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind;
-                if let Some(PathSegment { res: Some(Res::SelfTy(Some(def_id), _)), .. }) = segments.first();
+                if let Some(PathSegment { res: Some(Res::SelfTy{ trait_: Some(def_id), alias_to: _ }), .. }) = segments.first();
 
                 if let Some(
                     Node::Item(
index be20282b3b88c53547571a7ec2f2a28443e3ab14..80164c59ba74c3e570d82fb46985d25f6e47255a 100644 (file)
@@ -204,7 +204,7 @@ fn check_ty(&mut self, cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>) {
                 ref types_to_skip,
             }) = self.stack.last();
             if let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind;
-            if !matches!(path.res, Res::SelfTy(..) | Res::Def(DefKind::TyParam, _));
+            if !matches!(path.res, Res::SelfTy { .. } | Res::Def(DefKind::TyParam, _));
             if !types_to_skip.contains(&hir_ty.hir_id);
             let ty = if in_body > 0 {
                 cx.typeck_results().node_type(hir_ty.hir_id)
@@ -231,7 +231,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
         }
         match expr.kind {
             ExprKind::Struct(QPath::Resolved(_, path), ..) => match path.res {
-                Res::SelfTy(..) => (),
+                Res::SelfTy { .. } => (),
                 Res::Def(DefKind::Variant, _) => lint_path_to_variant(cx, path),
                 _ => span_lint(cx, path.span),
             },
index 42955080c966e10d37ca00c6feb89009b2797c19..f775cdd3bc280b0c6047ef771d22e2812b5b37ba 100644 (file)
@@ -1460,7 +1460,7 @@ pub fn is_self(slf: &Param<'_>) -> bool {
 
 pub fn is_self_ty(slf: &hir::Ty<'_>) -> bool {
     if let TyKind::Path(QPath::Resolved(None, path)) = slf.kind {
-        if let Res::SelfTy(..) = path.res {
+        if let Res::SelfTy { .. } = path.res {
             return true;
         }
     }