]> git.lizzy.rs Git - rust.git/commitdiff
Remove defaultness from ImplItem.
authorCamille GILLOT <gillot.camille@gmail.com>
Wed, 2 Feb 2022 11:44:51 +0000 (12:44 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Thu, 3 Feb 2022 17:56:08 +0000 (18:56 +0100)
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_hir/src/hir.rs
compiler/rustc_hir/src/intravisit.rs
compiler/rustc_hir/src/stable_hash_impls.rs
compiler/rustc_hir_pretty/src/lib.rs
src/librustdoc/clean/mod.rs
src/test/incremental/hashes/trait_impls.rs
src/tools/clippy/clippy_lints/src/utils/inspector.rs

index 8b4a0840df58370e0d655ae089c06d57bc873a25..44ee666b5e9bcf70facca1e67fd8844dabbdfb6f 100644 (file)
@@ -896,9 +896,6 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
             AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
         };
 
-        // Since `default impl` is not yet implemented, this is always true in impls.
-        let has_value = true;
-        let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
         let hir_id = self.lower_node_id(i.id);
         self.lower_attrs(hir_id, &i.attrs);
         let item = hir::ImplItem {
@@ -906,7 +903,6 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir hir::ImplItem<'hir> {
             ident: self.lower_ident(i.ident),
             generics,
             vis: self.lower_visibility(&i.vis),
-            defaultness,
             kind,
             span: self.lower_span(i.span),
         };
index 67398c80f360cbd2864a72ac41baff411345323f..840b30623bf355167f7049baa34cc76d567fa7fa 100644 (file)
@@ -2112,7 +2112,6 @@ pub struct ImplItem<'hir> {
     pub ident: Ident,
     pub def_id: LocalDefId,
     pub vis: Visibility<'hir>,
-    pub defaultness: Defaultness,
     pub generics: Generics<'hir>,
     pub kind: ImplItemKind<'hir>,
     pub span: Span,
@@ -3304,6 +3303,6 @@ mod size_asserts {
 
     rustc_data_structures::static_assert_size!(super::Item<'static>, 184);
     rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 128);
-    rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 152);
+    rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 144);
     rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 136);
 }
index 1d10e79d3007b08eeee1b15f14a854ded24ee924..9811b0cd89191ef172e62b8064d45ed6305bb460 100644 (file)
@@ -1020,12 +1020,10 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
 
 pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
     // N.B., deliberately force a compilation error if/when new fields are added.
-    let ImplItem { def_id: _, ident, ref vis, ref defaultness, ref generics, ref kind, span: _ } =
-        *impl_item;
+    let ImplItem { def_id: _, ident, ref vis, ref generics, ref kind, span: _ } = *impl_item;
 
     visitor.visit_ident(ident);
     visitor.visit_vis(vis);
-    visitor.visit_defaultness(defaultness);
     visitor.visit_generics(generics);
     match *kind {
         ImplItemKind::Const(ref ty, body) => {
index b15054ae6d610420d8133002a6d68f776e5ca8f9..7204efc4224583c776fabd6fdd42d1fab02f1af5 100644 (file)
@@ -164,13 +164,11 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
 
 impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
     fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
-        let ImplItem { def_id: _, ident, ref vis, defaultness, ref generics, ref kind, span } =
-            *self;
+        let ImplItem { def_id: _, ident, ref vis, ref generics, ref kind, span } = *self;
 
         hcx.hash_hir_item_like(|hcx| {
             ident.name.hash_stable(hcx, hasher);
             vis.hash_stable(hcx, hasher);
-            defaultness.hash_stable(hcx, hasher);
             generics.hash_stable(hcx, hasher);
             kind.hash_stable(hcx, hasher);
             span.hash_stable(hcx, hasher);
index a47ebaf1237a1ec611a12dc642a13faef5414fc6..90833ffef952a746cc5501aff87b79ea34e07682 100644 (file)
@@ -923,7 +923,6 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem<'_>) {
         self.hardbreak_if_not_bol();
         self.maybe_print_comment(ii.span.lo());
         self.print_outer_attributes(self.attrs(ii.hir_id()));
-        self.print_defaultness(ii.defaultness);
 
         match ii.kind {
             hir::ImplItemKind::Const(ref ty, expr) => {
index 7d209accec9b50a24a41ea044baacc588b52ed6e..3bb55d2663f2a8d08a2f58db92c648e90a8809a3 100644 (file)
@@ -1014,7 +1014,8 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
                     {
                         m.header.constness = hir::Constness::NotConst;
                     }
-                    MethodItem(m, Some(self.defaultness))
+                    let defaultness = cx.tcx.associated_item(self.def_id).defaultness;
+                    MethodItem(m, Some(defaultness))
                 }
                 hir::ImplItemKind::TyAlias(ref hir_ty) => {
                     let type_ = hir_ty.clean(cx);
index 75c93b73f857dad4a433cd68ff01cd8eba352392..2fb991b60ef3f7b25aadf73ff8495c345995f0c9 100644 (file)
@@ -358,9 +358,11 @@ pub trait AddDefaultTrait {
 
 #[cfg(any(cfail1,cfail4))]
 impl AddDefaultTrait for Foo {
-    // -------------------------------------------------------------------------------------------
+    // ----------------------------------------------------
     // -------------------------
-            fn method_name() { }
+    // ----------------------------------------------------
+    // -------------------------
+    fn         method_name() { }
 }
 
 #[cfg(not(any(cfail1,cfail4)))]
@@ -369,9 +371,9 @@ fn method_name() { }
 #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail5")]
 #[rustc_clean(cfg="cfail6")]
 impl AddDefaultTrait for Foo {
-    #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item", cfg="cfail2")]
+    #[rustc_clean(except="associated_item", cfg="cfail2")]
     #[rustc_clean(cfg="cfail3")]
-    #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item,optimized_mir", cfg="cfail5")]
+    #[rustc_clean(except="associated_item", cfg="cfail5")]
     #[rustc_clean(cfg="cfail6")]
     default fn method_name() { }
 }
index b58325ac73ee964770ce951ffb6a25400932c234..8691148313702e4657a2137b664289b4b1925cb8 100644 (file)
@@ -54,9 +54,6 @@ fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<
             ),
             hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
         }
-        if item.defaultness.is_default() {
-            println!("default");
-        }
         match item.kind {
             hir::ImplItemKind::Const(_, body_id) => {
                 println!("associated constant");