@@ -8,7 +8,6 @@ use rustc_type_ir::lang_items::TraitSolverLangItem;
88use rustc_type_ir:: solve:: CanonicalResponse ;
99use rustc_type_ir:: visit:: TypeVisitableExt as _;
1010use rustc_type_ir:: { self as ty, Interner , TraitPredicate , TypingMode , Upcast as _, elaborate} ;
11- use smallvec:: SmallVec ;
1211use tracing:: { instrument, trace} ;
1312
1413use crate :: delegate:: SolverDelegate ;
@@ -1199,25 +1198,14 @@ where
11991198 // nested requirements, over all others. This is a fix for #53123 and
12001199 // prevents where-bounds from accidentally extending the lifetime of a
12011200 // 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 ( ) {
12131205 // There should only ever be a single trivial builtin candidate
12141206 // 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 ) ) ) ;
12211209 }
12221210
12231211 // If there are non-global where-bounds, prefer where-bounds
0 commit comments