@@ -8,7 +8,6 @@ use rustc_type_ir::lang_items::TraitSolverLangItem;
8
8
use rustc_type_ir:: solve:: CanonicalResponse ;
9
9
use rustc_type_ir:: visit:: TypeVisitableExt as _;
10
10
use rustc_type_ir:: { self as ty, Interner , TraitPredicate , TypingMode , Upcast as _, elaborate} ;
11
- use smallvec:: SmallVec ;
12
11
use tracing:: { instrument, trace} ;
13
12
14
13
use crate :: delegate:: SolverDelegate ;
@@ -1199,25 +1198,14 @@ where
1199
1198
// nested requirements, over all others. This is a fix for #53123 and
1200
1199
// prevents where-bounds from accidentally extending the lifetime of a
1201
1200
// variable.
1202
- if candidates
1203
- . iter ( )
1204
- . any ( |c| matches ! ( c. source, CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Trivial ) ) )
1205
- {
1206
- let trivial_builtin_impls: SmallVec < [ _ ; 1 ] > = candidates
1207
- . iter ( )
1208
- . filter ( |c| {
1209
- matches ! ( c. source, CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Trivial ) )
1210
- } )
1211
- . map ( |c| c. result )
1212
- . collect ( ) ;
1201
+ let mut trivial_builtin_impls = candidates. iter ( ) . filter ( |c| {
1202
+ matches ! ( c. source, CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Trivial ) )
1203
+ } ) ;
1204
+ if let Some ( candidate) = trivial_builtin_impls. next ( ) {
1213
1205
// There should only ever be a single trivial builtin candidate
1214
1206
// as they would otherwise overlap.
1215
- assert_eq ! ( trivial_builtin_impls. len( ) , 1 ) ;
1216
- return if let Some ( response) = self . try_merge_responses ( & trivial_builtin_impls) {
1217
- Ok ( ( response, Some ( TraitGoalProvenVia :: Misc ) ) )
1218
- } else {
1219
- Ok ( ( self . bail_with_ambiguity ( & trivial_builtin_impls) , None ) )
1220
- } ;
1207
+ assert ! ( trivial_builtin_impls. next( ) . is_none( ) ) ;
1208
+ return Ok ( ( candidate. result , Some ( TraitGoalProvenVia :: Misc ) ) ) ;
1221
1209
}
1222
1210
1223
1211
// If there are non-global where-bounds, prefer where-bounds
0 commit comments