diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/sty.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 45fb8cf3dc9..10f89c965d1 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -572,7 +572,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> { pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> { match self[0] { ExistentialPredicate::Trait(tr) => Some(tr), - other => bug!("first predicate is {:?}", other), + _ => None } } diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 1db7141917f..22d609ea8a4 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1138,13 +1138,19 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { auto_traits.dedup(); // Calling `skip_binder` is okay, because the predicates are re-bound. + let principal = if tcx.trait_is_auto(existential_principal.def_id()) { + ty::ExistentialPredicate::AutoTrait(existential_principal.def_id()) + } else { + ty::ExistentialPredicate::Trait(*existential_principal.skip_binder()) + }; let mut v = - iter::once(ty::ExistentialPredicate::Trait(*existential_principal.skip_binder())) + iter::once(principal) .chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait)) .chain(existential_projections .map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder()))) .collect::<SmallVec<[_; 8]>>(); v.sort_by(|a, b| a.stable_cmp(tcx, b)); + v.dedup(); let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter())); // Use explicitly-specified region bound. |
