]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_ast_lowering/item.rs
Rollup merge of #68425 - phi-gamma:try-method, r=varkor
[rust.git] / src / librustc_ast_lowering / item.rs
index 6da2d457f3c3b5692d103736cd74d7cb4d9a66b3..2025d0c1c8e342140794fb4097b650b272952133 100644 (file)
@@ -3,7 +3,6 @@
 
 use rustc::arena::Arena;
 use rustc::bug;
-use rustc_error_codes::*;
 use rustc_errors::struct_span_err;
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Res};
@@ -67,9 +66,8 @@ fn visit_item(&mut self, item: &'a Item) {
         if let Some(hir_id) = item_hir_id {
             self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
                 let this = &mut ItemLowerer { lctx: this };
-                if let ItemKind::Impl { ref of_trait, .. } = item.kind {
-                    if of_trait.as_ref().map(|tr| tr.constness.is_some()).unwrap_or(false) {
-                        this.with_trait_impl_ref(of_trait, |this| visit::walk_item(this, item));
+                if let ItemKind::Impl { constness, ref of_trait, .. } = item.kind {
+                    if constness == Constness::Const {
                         this.lctx
                             .diagnostic()
                             .span_err(item.span, "const trait impls are not yet implemented");
@@ -366,6 +364,7 @@ fn lower_item_kind(
                 unsafety,
                 polarity,
                 defaultness,
+                constness,
                 generics: ref ast_generics,
                 of_trait: ref trait_ref,
                 self_ty: ref ty,
@@ -422,6 +421,7 @@ fn lower_item_kind(
                     unsafety,
                     polarity,
                     defaultness: self.lower_defaultness(defaultness, true /* [1] */),
+                    constness,
                     generics,
                     of_trait: trait_ref,
                     self_ty: lowered_ty,