File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
compiler/rustc_next_trait_solver/src/solve/normalizes_to
tests/ui/traits/next-solver Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 4545 goal,
4646 goal. predicate . alias ,
4747 ) ;
48- this. add_goal ( GoalSource :: AliasWellFormed , goal. with ( cx, trait_ref) ) ;
4948 this. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
5049 } )
5150 } )
Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Znext-solver
2+ //@ edition: 2024
3+ //@ check-pass
4+
5+ // Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/177>.
6+ // Coroutines erase all free lifetimes from their interior types. In the future in `from_request`,
7+ // that means the `'r` lifetime in the type `<T as FromRequest<'r>>::Assoc`, which is in the
8+ // `dyn Future` type it's awaiting. Normalizing this associated type, with its free lifetimes
9+ // replaced, means proving `T: FromRequest<'!0>`, which definitely doesn't hold.
10+
11+ // proving `T: Trait` holds when `<T as Trait>::Assoc` is rigid is not necessary for soundness,
12+ // at least not *yet*, and it's not even necessary for diagnostics since we have other special
13+ // casing for, e.g., AliasRelate goals failing in the BestObligation folder.
14+
15+ // The old solver deals this by not checking that `T: Trait` holds when `<T as Trait>::Assoc` is
16+ // rigid. Introducing this additional requirement when projecting rigidly in the old solver
17+ // causes this (and tons of production crates) to fail. See the fallout from the crater run at:
18+ // <https://github.com/rust-lang/rust/pull/139763>.
19+
20+ use std:: { future:: Future , pin:: Pin } ;
21+
22+ pub trait FromRequest < ' r > {
23+ type Assoc ;
24+ fn from_request ( ) -> Pin < Box < dyn Future < Output = Self :: Assoc > + Send > > ;
25+ }
26+
27+ fn test < ' r , T : FromRequest < ' r > > ( ) -> Pin < Box < dyn Future < Output = ( ) > + Send > > {
28+ Box :: pin ( async move {
29+ T :: from_request ( ) . await ;
30+ } )
31+ }
32+
33+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments