Skip to content

Commit 0dedc6c

Browse files
authored
Rollup merge of #80254 - Aaron1011:rustdoc-auto-param-env, r=estebank
Don't try to add nested predicate to Rustdoc auto-trait `ParamEnv` Fixes #80233 We already have logic in `evaluate_predicates` that tries to add unimplemented predicates to our `ParamEnv`. Trying to add a predicate that already holds can lead to errors later on, since projection will prefer trait candidates from the `ParamEnv` to predicates from an impl.
2 parents dcf622e + f2d7c05 commit 0dedc6c

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,10 @@ impl AutoTraitFinder<'tcx> {
636636
let bound_predicate = predicate.bound_atom();
637637
match bound_predicate.skip_binder() {
638638
ty::PredicateAtom::Trait(p, _) => {
639-
if self.is_param_no_infer(p.trait_ref.substs)
640-
&& !only_projections
641-
&& is_new_pred
642-
{
643-
self.add_user_pred(computed_preds, predicate);
644-
}
639+
// Add this to `predicates` so that we end up calling `select`
640+
// with it. If this predicate ends up being unimplemented,
641+
// then `evaluate_predicates` will handle adding it the `ParamEnv`
642+
// if possible.
645643
predicates.push_back(bound_predicate.rebind(p));
646644
}
647645
ty::PredicateAtom::Projection(p) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Regression test for issue #80233
2+
// Tests that we don't ICE when processing auto traits
3+
4+
#![crate_type = "lib"]
5+
pub trait Trait1 {}
6+
7+
pub trait Trait2 {
8+
type Type2;
9+
}
10+
11+
pub trait Trait3 {
12+
type Type3;
13+
}
14+
15+
impl Trait2 for Struct1 {
16+
type Type2 = Struct1;
17+
}
18+
19+
impl<I: Trait2> Trait2 for Vec<I> {
20+
type Type2 = Vec<I::Type2>;
21+
}
22+
23+
impl<T: Trait1> Trait3 for T {
24+
type Type3 = Struct1;
25+
}
26+
27+
impl<T: Trait3> Trait3 for Vec<T> {
28+
type Type3 = Vec<T::Type3>;
29+
}
30+
31+
pub struct Struct1 {}
32+
33+
// @has issue_80233_normalize_auto_trait/struct.Question.html
34+
// @has - '//code' 'impl<T> Send for Question<T>'
35+
pub struct Question<T: Trait1> {
36+
pub ins: <<Vec<T> as Trait3>::Type3 as Trait2>::Type2,
37+
}

0 commit comments

Comments
 (0)