diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 5331773e58bed..5aac347342a2d 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -607,6 +607,12 @@ impl<'tcx> AutoTraitFinder<'tcx> { // if possible. predicates.push_back(bound_predicate.rebind(p)); } + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(p)) => { + let p = bound_predicate.rebind(p); + if self.is_param_no_infer(p.skip_binder().trait_ref.args) && is_new_pred { + self.add_user_pred(computed_preds, predicate); + } + } ty::PredicateKind::Clause(ty::ClauseKind::Projection(p)) => { let p = bound_predicate.rebind(p); debug!( @@ -811,8 +817,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { | ty::PredicateKind::DynCompatible(..) | ty::PredicateKind::Subtype(..) | ty::PredicateKind::Coerce(..) - | ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) - | ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(..)) => {} + | ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) => {} ty::PredicateKind::Ambiguous => return false, // FIXME(generic_const_exprs): you can absolutely add this as a where clauses diff --git a/tests/rustdoc-ui/synthetic-auto-trait-impls/const-trait-bound.rs b/tests/rustdoc-ui/synthetic-auto-trait-impls/const-trait-bound.rs new file mode 100644 index 0000000000000..858e38b08fcd1 --- /dev/null +++ b/tests/rustdoc-ui/synthetic-auto-trait-impls/const-trait-bound.rs @@ -0,0 +1,14 @@ +// We used to ICE here while trying to synthesize auto trait impls. +//@ check-pass + +#![feature(const_default)] +#![feature(const_trait_impl)] + +pub struct Inner(T); + +pub struct Outer(Inner); + +impl Unpin for Inner +where + T: const std::default::Default, +{}