File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
compiler/rustc_next_trait_solver/src/solve/assembly
tests/ui/traits/next-solver/normalization-shadowing Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1143,6 +1143,12 @@ where
11431143 // See `tests/ui/winnowing/norm-where-bound-gt-alias-bound.rs`.
11441144 if candidates. iter ( ) . any ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) {
11451145 candidates. retain ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) ;
1146+ } else if matches ! ( goal. predicate. self_ty( ) . kind( ) , ty:: Dynamic ( ..) ) {
1147+ // Object candidate may be shadowed by where-bound for the trait goal, see
1148+ // `tests/ui/traits/next-solver/normalization-shadowing/use_object_if_empty_env.rs`.
1149+ // Trait objects always have their associated types specified so `candidates`
1150+ // won't be empty.
1151+ self . assemble_object_bound_candidates ( goal, & mut candidates) ;
11461152 } else if candidates. is_empty ( ) {
11471153 // If the trait goal has been proven by using the environment, we want to treat
11481154 // aliases as rigid if there are no applicable projection bounds in the environment.
Original file line number Diff line number Diff line change 1+ //@ compile-flags: -Znext-solver
2+ //@ check-pass
3+
4+ trait Trait {
5+ type Assoc ;
6+ }
7+
8+ // We have param env candidate for the trait goal but not the projection.
9+ // Under such circumstance, consider object candidate if the self_ty is trait object.
10+ fn foo < T > ( x : <dyn Trait < Assoc = T > as Trait >:: Assoc ) -> T
11+ where
12+ dyn Trait < Assoc = T > : Trait ,
13+ {
14+ x
15+ }
16+
17+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments