@@ -46,6 +46,7 @@ use rustc_infer::infer::relate::RelateResult;
46
46
use rustc_infer:: infer:: { Coercion , DefineOpaqueTypes , InferOk , InferResult } ;
47
47
use rustc_infer:: traits:: {
48
48
IfExpressionCause , MatchExpressionArmCause , Obligation , PredicateObligation ,
49
+ PredicateObligations ,
49
50
} ;
50
51
use rustc_middle:: lint:: in_external_macro;
51
52
use rustc_middle:: span_bug;
@@ -120,7 +121,7 @@ fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'
120
121
fn success < ' tcx > (
121
122
adj : Vec < Adjustment < ' tcx > > ,
122
123
target : Ty < ' tcx > ,
123
- obligations : Vec < traits :: PredicateObligation < ' tcx > > ,
124
+ obligations : PredicateObligations < ' tcx > ,
124
125
) -> CoerceResult < ' tcx > {
125
126
Ok ( InferOk { value : ( adj, target) , obligations } )
126
127
}
@@ -184,7 +185,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
184
185
// Coercing from `!` to any type is allowed:
185
186
if a. is_never ( ) {
186
187
if self . coerce_never {
187
- return success ( simple ( Adjust :: NeverToAny ) ( b) , b, vec ! [ ] ) ;
188
+ return success ( simple ( Adjust :: NeverToAny ) ( b) , b, PredicateObligations :: new ( ) ) ;
188
189
} else {
189
190
// Otherwise the only coercion we can do is unification.
190
191
return self . unify_and ( a, b, identity) ;
@@ -278,7 +279,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
278
279
// Two unresolved type variables: create a `Coerce` predicate.
279
280
let target_ty = if self . use_lub { self . next_ty_var ( self . cause . span ) } else { b } ;
280
281
281
- let mut obligations = Vec :: with_capacity ( 2 ) ;
282
+ let mut obligations = PredicateObligations :: with_capacity ( 2 ) ;
282
283
for & source_ty in & [ a, b] {
283
284
if source_ty != target_ty {
284
285
obligations. push ( Obligation :: new (
@@ -744,7 +745,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
744
745
745
746
// Check the obligations of the cast -- for example, when casting
746
747
// `usize` to `dyn* Clone + 'static`:
747
- let mut obligations: Vec < _ > = predicates
748
+ let obligations = predicates
748
749
. iter ( )
749
750
. map ( |predicate| {
750
751
// For each existential predicate (e.g., `?Self: Clone`) instantiate
@@ -764,21 +765,21 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
764
765
ty:: OutlivesPredicate ( a, b_region) ,
765
766
) ) ) ,
766
767
) ,
768
+ // Enforce that the type is `usize`/pointer-sized.
769
+ Obligation :: new (
770
+ self . tcx ,
771
+ self . cause . clone ( ) ,
772
+ self . param_env ,
773
+ ty:: TraitRef :: new (
774
+ self . tcx ,
775
+ self . tcx
776
+ . require_lang_item ( hir:: LangItem :: PointerLike , Some ( self . cause . span ) ) ,
777
+ [ a] ,
778
+ ) ,
779
+ ) ,
767
780
] )
768
781
. collect ( ) ;
769
782
770
- // Enforce that the type is `usize`/pointer-sized.
771
- obligations. push ( Obligation :: new (
772
- self . tcx ,
773
- self . cause . clone ( ) ,
774
- self . param_env ,
775
- ty:: TraitRef :: new (
776
- self . tcx ,
777
- self . tcx . require_lang_item ( hir:: LangItem :: PointerLike , Some ( self . cause . span ) ) ,
778
- [ a] ,
779
- ) ,
780
- ) ) ;
781
-
782
783
Ok ( InferOk {
783
784
value : (
784
785
vec ! [ Adjustment { kind: Adjust :: Pointer ( PointerCoercion :: DynStar ) , target: b } ] ,
0 commit comments