@@ -454,7 +454,16 @@ where
454454 self . assemble_object_bound_candidates ( goal, & mut candidates) ;
455455 }
456456 }
457- AssembleCandidatesFrom :: EnvAndBounds => { }
457+ AssembleCandidatesFrom :: EnvAndBounds => {
458+ // This is somewhat inconsistent and may make #57893 slightly easier to exploit.
459+ // However, it matches the behavior of the old solver. See
460+ // `tests/ui/traits/next-solver/normalization-shadowing/use_object_if_empty_env.rs`.
461+ if matches ! ( normalized_self_ty. kind( ) , ty:: Dynamic ( ..) )
462+ && !candidates. iter ( ) . any ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) )
463+ {
464+ self . assemble_object_bound_candidates ( goal, & mut candidates) ;
465+ }
466+ }
458467 }
459468
460469 ( candidates, failed_candidate_info)
@@ -1143,12 +1152,6 @@ where
11431152 // See `tests/ui/winnowing/norm-where-bound-gt-alias-bound.rs`.
11441153 if candidates. iter ( ) . any ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) {
11451154 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) ;
11521155 } else if candidates. is_empty ( ) {
11531156 // If the trait goal has been proven by using the environment, we want to treat
11541157 // aliases as rigid if there are no applicable projection bounds in the environment.
0 commit comments