@@ -10,6 +10,7 @@ use either::Either;
10
10
use hir:: OpaqueTyOrigin ;
11
11
use rustc_data_structures:: frozen:: Frozen ;
12
12
use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
13
+ use rustc_errors:: ErrorGuaranteed ;
13
14
use rustc_hir as hir;
14
15
use rustc_hir:: def:: DefKind ;
15
16
use rustc_hir:: def_id:: LocalDefId ;
@@ -26,6 +27,7 @@ use rustc_middle::mir::tcx::PlaceTy;
26
27
use rustc_middle:: mir:: visit:: { NonMutatingUseContext , PlaceContext , Visitor } ;
27
28
use rustc_middle:: mir:: AssertKind ;
28
29
use rustc_middle:: mir:: * ;
30
+ use rustc_middle:: traits:: query:: NoSolution ;
29
31
use rustc_middle:: ty:: adjustment:: PointerCast ;
30
32
use rustc_middle:: ty:: cast:: CastTy ;
31
33
use rustc_middle:: ty:: subst:: { SubstsRef , UserSubsts } ;
@@ -41,7 +43,7 @@ use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
41
43
use rustc_trait_selection:: traits:: query:: type_op:: custom:: scrape_region_constraints;
42
44
use rustc_trait_selection:: traits:: query:: type_op:: custom:: CustomTypeOp ;
43
45
use rustc_trait_selection:: traits:: query:: type_op:: { TypeOp , TypeOpOutput } ;
44
- use rustc_trait_selection :: traits :: query :: Fallible ;
46
+
45
47
use rustc_trait_selection:: traits:: PredicateObligation ;
46
48
47
49
use rustc_mir_dataflow:: impls:: MaybeInitializedPlaces ;
@@ -216,24 +218,22 @@ pub(crate) fn type_check<'mir, 'tcx>(
216
218
let opaque_type_values = opaque_type_values
217
219
. into_iter ( )
218
220
. map ( |( opaque_type_key, decl) | {
219
- checker
220
- . fully_perform_op (
221
- Locations :: All ( body. span ) ,
222
- ConstraintCategory :: OpaqueType ,
223
- CustomTypeOp :: new (
224
- |ocx| {
225
- ocx. infcx . register_member_constraints (
226
- param_env,
227
- opaque_type_key,
228
- decl. hidden_type . ty ,
229
- decl. hidden_type . span ,
230
- ) ;
231
- Ok ( ( ) )
232
- } ,
233
- "opaque_type_map" ,
234
- ) ,
235
- )
236
- . unwrap ( ) ;
221
+ let _: Result < _ , ErrorGuaranteed > = checker. fully_perform_op (
222
+ Locations :: All ( body. span ) ,
223
+ ConstraintCategory :: OpaqueType ,
224
+ CustomTypeOp :: new (
225
+ |ocx| {
226
+ ocx. infcx . register_member_constraints (
227
+ param_env,
228
+ opaque_type_key,
229
+ decl. hidden_type . ty ,
230
+ decl. hidden_type . span ,
231
+ ) ;
232
+ Ok ( ( ) )
233
+ } ,
234
+ "opaque_type_map" ,
235
+ ) ,
236
+ ) ;
237
237
let mut hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
238
238
trace ! ( "finalized opaque type {:?} to {:#?}" , opaque_type_key, hidden_type. ty. kind( ) ) ;
239
239
if hidden_type. has_non_region_infer ( ) {
@@ -1134,7 +1134,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1134
1134
sup : Ty < ' tcx > ,
1135
1135
locations : Locations ,
1136
1136
category : ConstraintCategory < ' tcx > ,
1137
- ) -> Fallible < ( ) > {
1137
+ ) -> Result < ( ) , NoSolution > {
1138
1138
// Use this order of parameters because the sup type is usually the
1139
1139
// "expected" type in diagnostics.
1140
1140
self . relate_types ( sup, ty:: Variance :: Contravariant , sub, locations, category)
@@ -1147,7 +1147,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1147
1147
found : Ty < ' tcx > ,
1148
1148
locations : Locations ,
1149
1149
category : ConstraintCategory < ' tcx > ,
1150
- ) -> Fallible < ( ) > {
1150
+ ) -> Result < ( ) , NoSolution > {
1151
1151
self . relate_types ( expected, ty:: Variance :: Invariant , found, locations, category)
1152
1152
}
1153
1153
@@ -1159,7 +1159,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1159
1159
user_ty : & UserTypeProjection ,
1160
1160
locations : Locations ,
1161
1161
category : ConstraintCategory < ' tcx > ,
1162
- ) -> Fallible < ( ) > {
1162
+ ) -> Result < ( ) , NoSolution > {
1163
1163
let annotated_type = self . user_type_annotations [ user_ty. base ] . inferred_ty ;
1164
1164
trace ! ( ?annotated_type) ;
1165
1165
let mut curr_projected_ty = PlaceTy :: from_ty ( annotated_type) ;
@@ -2755,11 +2755,20 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
2755
2755
/// constraints in our `InferCtxt`
2756
2756
type ErrorInfo = InstantiateOpaqueType < ' tcx > ;
2757
2757
2758
- fn fully_perform ( mut self , infcx : & InferCtxt < ' tcx > ) -> Fallible < TypeOpOutput < ' tcx , Self > > {
2759
- let ( mut output, region_constraints) = scrape_region_constraints ( infcx, |ocx| {
2760
- ocx. register_obligations ( self . obligations . clone ( ) ) ;
2761
- Ok ( ( ) )
2762
- } ) ?;
2758
+ fn fully_perform (
2759
+ mut self ,
2760
+ infcx : & InferCtxt < ' tcx > ,
2761
+ span : Span ,
2762
+ ) -> Result < TypeOpOutput < ' tcx , Self > , ErrorGuaranteed > {
2763
+ let ( mut output, region_constraints) = scrape_region_constraints (
2764
+ infcx,
2765
+ |ocx| {
2766
+ ocx. register_obligations ( self . obligations . clone ( ) ) ;
2767
+ Ok ( ( ) )
2768
+ } ,
2769
+ "InstantiateOpaqueType" ,
2770
+ span,
2771
+ ) ?;
2763
2772
self . region_constraints = Some ( region_constraints) ;
2764
2773
output. error_info = Some ( self ) ;
2765
2774
Ok ( output)
0 commit comments