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