From bbd581c583a7168359bf94beaa111d6ad3316837 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Fri, 19 Jun 2020 19:19:21 +0200 Subject: [PATCH 1/1] fix elaborate for predicates with unbound variables --- src/librustc_infer/traits/util.rs | 14 +++++--------- src/librustc_trait_selection/traits/auto_trait.rs | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/librustc_infer/traits/util.rs b/src/librustc_infer/traits/util.rs index 1bee16f7556..6aeb225a6e9 100644 --- a/src/librustc_infer/traits/util.rs +++ b/src/librustc_infer/traits/util.rs @@ -151,15 +151,11 @@ pub fn filter_to_traits(self) -> FilterToTraits<'tcx, Self> { fn elaborate(&mut self, obligation: &PredicateObligation<'tcx>) { let tcx = self.visited.tcx; - let pred = match obligation.predicate.kind() { - // We have to be careful and rebind this when - // dealing with a predicate further down. - ty::PredicateKind::ForAll(binder) => binder.skip_binder().kind(), - pred => pred, - }; - - match pred { - ty::PredicateKind::ForAll(_) => bug!("unexpected predicate: {:?}", pred), + + match obligation.predicate.ignore_qualifiers(tcx).skip_binder().kind() { + ty::PredicateKind::ForAll(_) => { + bug!("unexpected predicate: {:?}", obligation.predicate) + } ty::PredicateKind::Trait(data, _) => { // Get predicates declared on the trait. let predicates = tcx.super_predicates_of(data.def_id()); diff --git a/src/librustc_trait_selection/traits/auto_trait.rs b/src/librustc_trait_selection/traits/auto_trait.rs index 9c530912bf0..74a4939ae10 100644 --- a/src/librustc_trait_selection/traits/auto_trait.rs +++ b/src/librustc_trait_selection/traits/auto_trait.rs @@ -763,7 +763,7 @@ fn evaluate_nested_obligations( } } Ok(None) => { - // It's ok not to make progress when hvave no inference variables - + // It's ok not to make progress when have no inference variables - // in that case, we were only performing unifcation to check if an // error occurred (which would indicate that it's impossible for our // type to implement the auto trait). -- 2.44.0