@@ -112,23 +112,18 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
112
112
) -> QueryResult < ' tcx > {
113
113
if let Some ( projection_pred) = assumption. as_projection_clause ( ) {
114
114
if projection_pred. projection_def_id ( ) == goal. predicate . def_id ( ) {
115
- ecx. probe ( |r| CandidateKind :: Candidate { name : "assumption" . into ( ) , result : * r } )
116
- . enter ( |ecx| {
117
- let assumption_projection_pred =
118
- ecx. instantiate_binder_with_infer ( projection_pred) ;
119
- ecx. eq (
120
- goal. param_env ,
121
- goal. predicate . projection_ty ,
122
- assumption_projection_pred. projection_ty ,
123
- ) ?;
124
- ecx. eq (
125
- goal. param_env ,
126
- goal. predicate . term ,
127
- assumption_projection_pred. term ,
128
- )
115
+ ecx. probe_candidate ( "assumption" ) . enter ( |ecx| {
116
+ let assumption_projection_pred =
117
+ ecx. instantiate_binder_with_infer ( projection_pred) ;
118
+ ecx. eq (
119
+ goal. param_env ,
120
+ goal. predicate . projection_ty ,
121
+ assumption_projection_pred. projection_ty ,
122
+ ) ?;
123
+ ecx. eq ( goal. param_env , goal. predicate . term , assumption_projection_pred. term )
129
124
. expect ( "expected goal term to be fully unconstrained" ) ;
130
- then ( ecx)
131
- } )
125
+ then ( ecx)
126
+ } )
132
127
} else {
133
128
Err ( NoSolution )
134
129
}
@@ -329,91 +324,89 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
329
324
goal : Goal < ' tcx , Self > ,
330
325
) -> QueryResult < ' tcx > {
331
326
let tcx = ecx. tcx ( ) ;
332
- ecx. probe ( |r| CandidateKind :: Candidate { name : "builtin pointee" . into ( ) , result : * r } )
333
- . enter ( |ecx| {
334
- let metadata_ty = match goal. predicate . self_ty ( ) . kind ( ) {
335
- ty:: Bool
336
- | ty:: Char
337
- | ty:: Int ( ..)
338
- | ty:: Uint ( ..)
339
- | ty:: Float ( ..)
340
- | ty:: Array ( ..)
341
- | ty:: RawPtr ( ..)
342
- | ty:: Ref ( ..)
343
- | ty:: FnDef ( ..)
344
- | ty:: FnPtr ( ..)
345
- | ty:: Closure ( ..)
346
- | ty:: Infer ( ty:: IntVar ( ..) | ty:: FloatVar ( ..) )
347
- | ty:: Generator ( ..)
348
- | ty:: GeneratorWitness ( ..)
349
- | ty:: GeneratorWitnessMIR ( ..)
350
- | ty:: Never
351
- | ty:: Foreign ( ..) => tcx. types . unit ,
352
-
353
- ty:: Error ( e) => tcx. ty_error ( * e) ,
354
-
355
- ty:: Str | ty:: Slice ( _) => tcx. types . usize ,
356
-
357
- ty:: Dynamic ( _, _, _) => {
358
- let dyn_metadata = tcx. require_lang_item ( LangItem :: DynMetadata , None ) ;
359
- tcx. type_of ( dyn_metadata)
360
- . subst ( tcx, & [ ty:: GenericArg :: from ( goal. predicate . self_ty ( ) ) ] )
361
- }
362
-
363
- ty:: Alias ( _, _) | ty:: Param ( _) | ty:: Placeholder ( ..) => {
364
- // FIXME(ptr_metadata): It would also be possible to return a `Ok(Ambig)` with no constraints.
365
- let sized_predicate = ty:: TraitRef :: from_lang_item (
366
- tcx,
367
- LangItem :: Sized ,
368
- DUMMY_SP ,
369
- [ ty:: GenericArg :: from ( goal. predicate . self_ty ( ) ) ] ,
370
- ) ;
371
- ecx. add_goal ( goal. with ( tcx, sized_predicate) ) ;
372
- tcx. types . unit
373
- }
327
+ ecx. probe_candidate ( "builtin pointee" ) . enter ( |ecx| {
328
+ let metadata_ty = match goal. predicate . self_ty ( ) . kind ( ) {
329
+ ty:: Bool
330
+ | ty:: Char
331
+ | ty:: Int ( ..)
332
+ | ty:: Uint ( ..)
333
+ | ty:: Float ( ..)
334
+ | ty:: Array ( ..)
335
+ | ty:: RawPtr ( ..)
336
+ | ty:: Ref ( ..)
337
+ | ty:: FnDef ( ..)
338
+ | ty:: FnPtr ( ..)
339
+ | ty:: Closure ( ..)
340
+ | ty:: Infer ( ty:: IntVar ( ..) | ty:: FloatVar ( ..) )
341
+ | ty:: Generator ( ..)
342
+ | ty:: GeneratorWitness ( ..)
343
+ | ty:: GeneratorWitnessMIR ( ..)
344
+ | ty:: Never
345
+ | ty:: Foreign ( ..) => tcx. types . unit ,
346
+
347
+ ty:: Error ( e) => tcx. ty_error ( * e) ,
348
+
349
+ ty:: Str | ty:: Slice ( _) => tcx. types . usize ,
350
+
351
+ ty:: Dynamic ( _, _, _) => {
352
+ let dyn_metadata = tcx. require_lang_item ( LangItem :: DynMetadata , None ) ;
353
+ tcx. type_of ( dyn_metadata)
354
+ . subst ( tcx, & [ ty:: GenericArg :: from ( goal. predicate . self_ty ( ) ) ] )
355
+ }
374
356
375
- ty:: Adt ( def, substs) if def. is_struct ( ) => {
376
- match def. non_enum_variant ( ) . fields . raw . last ( ) {
377
- None => tcx. types . unit ,
378
- Some ( field_def) => {
379
- let self_ty = field_def. ty ( tcx, substs) ;
380
- ecx. add_goal ( goal. with (
381
- tcx,
382
- ty:: Binder :: dummy ( goal. predicate . with_self_ty ( tcx, self_ty) ) ,
383
- ) ) ;
384
- return ecx. evaluate_added_goals_and_make_canonical_response (
385
- Certainty :: Yes ,
386
- ) ;
387
- }
388
- }
389
- }
390
- ty:: Adt ( _, _) => tcx. types . unit ,
357
+ ty:: Alias ( _, _) | ty:: Param ( _) | ty:: Placeholder ( ..) => {
358
+ // FIXME(ptr_metadata): It would also be possible to return a `Ok(Ambig)` with no constraints.
359
+ let sized_predicate = ty:: TraitRef :: from_lang_item (
360
+ tcx,
361
+ LangItem :: Sized ,
362
+ DUMMY_SP ,
363
+ [ ty:: GenericArg :: from ( goal. predicate . self_ty ( ) ) ] ,
364
+ ) ;
365
+ ecx. add_goal ( goal. with ( tcx, sized_predicate) ) ;
366
+ tcx. types . unit
367
+ }
391
368
392
- ty:: Tuple ( elements) => match elements. last ( ) {
369
+ ty:: Adt ( def, substs) if def. is_struct ( ) => {
370
+ match def. non_enum_variant ( ) . fields . raw . last ( ) {
393
371
None => tcx. types . unit ,
394
- Some ( & self_ty) => {
372
+ Some ( field_def) => {
373
+ let self_ty = field_def. ty ( tcx, substs) ;
395
374
ecx. add_goal ( goal. with (
396
375
tcx,
397
376
ty:: Binder :: dummy ( goal. predicate . with_self_ty ( tcx, self_ty) ) ,
398
377
) ) ;
399
378
return ecx
400
379
. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
401
380
}
402
- } ,
403
-
404
- ty:: Infer (
405
- ty:: TyVar ( _) | ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) ,
406
- )
407
- | ty:: Bound ( ..) => bug ! (
408
- "unexpected self ty `{:?}` when normalizing `<T as Pointee>::Metadata`" ,
409
- goal. predicate. self_ty( )
410
- ) ,
411
- } ;
381
+ }
382
+ }
383
+ ty:: Adt ( _, _) => tcx. types . unit ,
412
384
413
- ecx. eq ( goal. param_env , goal. predicate . term , metadata_ty. into ( ) )
414
- . expect ( "expected goal term to be fully unconstrained" ) ;
415
- ecx. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
416
- } )
385
+ ty:: Tuple ( elements) => match elements. last ( ) {
386
+ None => tcx. types . unit ,
387
+ Some ( & self_ty) => {
388
+ ecx. add_goal ( goal. with (
389
+ tcx,
390
+ ty:: Binder :: dummy ( goal. predicate . with_self_ty ( tcx, self_ty) ) ,
391
+ ) ) ;
392
+ return ecx
393
+ . evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes ) ;
394
+ }
395
+ } ,
396
+
397
+ ty:: Infer (
398
+ ty:: TyVar ( _) | ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) ,
399
+ )
400
+ | ty:: Bound ( ..) => bug ! (
401
+ "unexpected self ty `{:?}` when normalizing `<T as Pointee>::Metadata`" ,
402
+ goal. predicate. self_ty( )
403
+ ) ,
404
+ } ;
405
+
406
+ ecx. eq ( goal. param_env , goal. predicate . term , metadata_ty. into ( ) )
407
+ . expect ( "expected goal term to be fully unconstrained" ) ;
408
+ ecx. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
409
+ } )
417
410
}
418
411
419
412
fn consider_builtin_future_candidate (
@@ -548,11 +541,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
548
541
) ,
549
542
} ;
550
543
551
- ecx. probe ( |r| CandidateKind :: Candidate {
552
- name : "builtin discriminant kind" . into ( ) ,
553
- result : * r,
554
- } )
555
- . enter ( |ecx| {
544
+ ecx. probe_candidate ( "builtin discriminant kind" ) . enter ( |ecx| {
556
545
ecx. eq ( goal. param_env , goal. predicate . term , discriminant_ty. into ( ) )
557
546
. expect ( "expected goal term to be fully unconstrained" ) ;
558
547
ecx. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
0 commit comments