From 00be060daf3c38256e58360bfa591b8e22f60f7a Mon Sep 17 00:00:00 2001 From: "leonardo.yvens" Date: Thu, 12 Oct 2017 11:18:55 -0300 Subject: [PATCH] Teach typeck about `auto trait` --- src/librustc/hir/lowering.rs | 4 ++-- src/librustc_typeck/collect.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 7214904887e4..a69d41d16033 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1742,8 +1742,8 @@ impl<'a> LoweringContext<'a> { } } - fn lower_is_auto(&mut self, u: IsAuto) -> hir::IsAuto { - match u { + fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto { + match a { IsAuto::Yes => hir::IsAuto::Yes, IsAuto::No => hir::IsAuto::No, } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 72b40d877085..814470974285 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -730,11 +730,14 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let def_path_hash = tcx.def_path_hash(def_id); - let has_auto_impl = tcx.hir.trait_is_auto(def_id); + let is_auto = match item.node { + hir::ItemTrait(hir::IsAuto::Yes, ..) => true, + _ => tcx.hir.trait_is_auto(def_id), + }; let def = ty::TraitDef::new(def_id, unsafety, paren_sugar, - has_auto_impl, + is_auto, def_path_hash); tcx.alloc_trait_def(def) }