@@ -37,13 +37,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3737 candidate : SelectionCandidate < ' tcx > ,
3838 ) -> Result < Selection < ' tcx > , SelectionError < ' tcx > > {
3939 Ok ( match candidate {
40- SizedCandidate { has_nested } => {
41- let data = self . confirm_builtin_candidate ( obligation, has_nested ) ;
40+ SizedCandidate => {
41+ let data = self . confirm_builtin_candidate ( obligation) ;
4242 ImplSource :: Builtin ( BuiltinImplSource :: Misc , data)
4343 }
4444
45- BuiltinCandidate { has_nested } => {
46- let data = self . confirm_builtin_candidate ( obligation, has_nested ) ;
45+ BuiltinCandidate => {
46+ let data = self . confirm_builtin_candidate ( obligation) ;
4747 ImplSource :: Builtin ( BuiltinImplSource :: Misc , data)
4848 }
4949
@@ -249,50 +249,47 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
249249 }
250250 }
251251
252+ #[ instrument( level = "debug" , skip( self ) , ret) ]
252253 fn confirm_builtin_candidate (
253254 & mut self ,
254255 obligation : & PolyTraitObligation < ' tcx > ,
255- has_nested : bool ,
256256 ) -> PredicateObligations < ' tcx > {
257- debug ! ( ?obligation, ?has_nested, "confirm_builtin_candidate" ) ;
258-
257+ debug ! ( ?obligation, "confirm_builtin_candidate" ) ;
259258 let tcx = self . tcx ( ) ;
260- let obligations = if has_nested {
261- let trait_def = obligation. predicate . def_id ( ) ;
262- let conditions = match tcx. as_lang_item ( trait_def) {
263- Some ( LangItem :: Sized ) => {
264- self . sizedness_conditions ( obligation, SizedTraitKind :: Sized )
265- }
266- Some ( LangItem :: MetaSized ) => {
267- self . sizedness_conditions ( obligation, SizedTraitKind :: MetaSized )
268- }
269- Some ( LangItem :: PointeeSized ) => {
270- bug ! ( "`PointeeSized` is removing during lowering" ) ;
271- }
272- Some ( LangItem :: Copy | LangItem :: Clone ) => self . copy_clone_conditions ( obligation) ,
273- Some ( LangItem :: FusedIterator ) => self . fused_iterator_conditions ( obligation) ,
274- other => bug ! ( "unexpected builtin trait {trait_def:?} ({other:?})" ) ,
275- } ;
276- let BuiltinImplConditions :: Where ( types) = conditions else {
277- bug ! ( "obligation {:?} had matched a builtin impl but now doesn't" , obligation) ;
278- } ;
279- let types = self . infcx . enter_forall_and_leak_universe ( types) ;
280-
281- let cause = obligation. derived_cause ( ObligationCauseCode :: BuiltinDerived ) ;
282- self . collect_predicates_for_types (
283- obligation. param_env ,
284- cause,
285- obligation. recursion_depth + 1 ,
286- trait_def,
287- types,
288- )
289- } else {
290- PredicateObligations :: new ( )
259+ let trait_def = obligation. predicate . def_id ( ) ;
260+ let conditions = match tcx. as_lang_item ( trait_def) {
261+ Some ( LangItem :: Sized ) => self . sizedness_conditions ( obligation, SizedTraitKind :: Sized ) ,
262+ Some ( LangItem :: MetaSized ) => {
263+ self . sizedness_conditions ( obligation, SizedTraitKind :: MetaSized )
264+ }
265+ Some ( LangItem :: PointeeSized ) => {
266+ bug ! ( "`PointeeSized` is removing during lowering" ) ;
267+ }
268+ Some ( LangItem :: Copy | LangItem :: Clone ) => self . copy_clone_conditions ( obligation) ,
269+ Some ( LangItem :: FusedIterator ) => self . fused_iterator_conditions ( obligation) ,
270+ Some (
271+ LangItem :: Destruct
272+ | LangItem :: DiscriminantKind
273+ | LangItem :: FnPtrTrait
274+ | LangItem :: PointeeTrait
275+ | LangItem :: Tuple
276+ | LangItem :: Unpin ,
277+ ) => BuiltinImplConditions :: Where ( ty:: Binder :: dummy ( vec ! [ ] ) ) ,
278+ other => bug ! ( "unexpected builtin trait {trait_def:?} ({other:?})" ) ,
291279 } ;
280+ let BuiltinImplConditions :: Where ( types) = conditions else {
281+ bug ! ( "obligation {:?} had matched a builtin impl but now doesn't" , obligation) ;
282+ } ;
283+ let types = self . infcx . enter_forall_and_leak_universe ( types) ;
292284
293- debug ! ( ?obligations) ;
294-
295- obligations
285+ let cause = obligation. derived_cause ( ObligationCauseCode :: BuiltinDerived ) ;
286+ self . collect_predicates_for_types (
287+ obligation. param_env ,
288+ cause,
289+ obligation. recursion_depth + 1 ,
290+ trait_def,
291+ types,
292+ )
296293 }
297294
298295 #[ instrument( level = "debug" , skip( self ) ) ]
0 commit comments