@@ -278,7 +278,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
278
278
self . tcx
279
279
}
280
280
281
- fn fold_binder < T > ( & mut self , t : ty:: Binder < ' tcx , T > ) -> Result < ty:: Binder < ' tcx , T > , Self :: Error >
281
+ fn fold_binder < T > ( & mut self , t : ty:: Binder < ' tcx , T > ) -> ty:: Binder < ' tcx , T >
282
282
where
283
283
T : TypeFoldable < ' tcx > ,
284
284
{
@@ -288,13 +288,13 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
288
288
t
289
289
}
290
290
291
- fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> Result < ty:: Region < ' tcx > , Self :: Error > {
291
+ fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
292
292
match * r {
293
293
ty:: ReLateBound ( index, ..) => {
294
294
if index >= self . binder_index {
295
295
bug ! ( "escaping late-bound region during canonicalization" ) ;
296
296
} else {
297
- Ok ( r )
297
+ r
298
298
}
299
299
}
300
300
@@ -311,19 +311,19 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
311
311
vid, r
312
312
) ;
313
313
let r = self . tcx . reuse_or_mk_region ( r, ty:: ReVar ( resolved_vid) ) ;
314
- Ok ( self . canonicalize_region_mode . canonicalize_free_region ( self , r) )
314
+ self . canonicalize_region_mode . canonicalize_free_region ( self , r)
315
315
}
316
316
317
317
ty:: ReStatic
318
318
| ty:: ReEarlyBound ( ..)
319
319
| ty:: ReFree ( _)
320
320
| ty:: ReEmpty ( _)
321
321
| ty:: RePlaceholder ( ..)
322
- | ty:: ReErased => Ok ( self . canonicalize_region_mode . canonicalize_free_region ( self , r) ) ,
322
+ | ty:: ReErased => self . canonicalize_region_mode . canonicalize_free_region ( self , r) ,
323
323
}
324
324
}
325
325
326
- fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Result < Ty < ' tcx > , Self :: Error > {
326
+ fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
327
327
match * t. kind ( ) {
328
328
ty:: Infer ( ty:: TyVar ( vid) ) => {
329
329
debug ! ( "canonical: type var found with vid {:?}" , vid) ;
@@ -339,40 +339,40 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
339
339
Err ( mut ui) => {
340
340
// FIXME: perf problem described in #55921.
341
341
ui = ty:: UniverseIndex :: ROOT ;
342
- Ok ( self . canonicalize_ty_var (
342
+ self . canonicalize_ty_var (
343
343
CanonicalVarInfo {
344
344
kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( ui) ) ,
345
345
} ,
346
346
t,
347
- ) )
347
+ )
348
348
}
349
349
}
350
350
}
351
351
352
- ty:: Infer ( ty:: IntVar ( _) ) => Ok ( self . canonicalize_ty_var (
352
+ ty:: Infer ( ty:: IntVar ( _) ) => self . canonicalize_ty_var (
353
353
CanonicalVarInfo { kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int ) } ,
354
354
t,
355
- ) ) ,
355
+ ) ,
356
356
357
- ty:: Infer ( ty:: FloatVar ( _) ) => Ok ( self . canonicalize_ty_var (
357
+ ty:: Infer ( ty:: FloatVar ( _) ) => self . canonicalize_ty_var (
358
358
CanonicalVarInfo { kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Float ) } ,
359
359
t,
360
- ) ) ,
360
+ ) ,
361
361
362
362
ty:: Infer ( ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) ) => {
363
363
bug ! ( "encountered a fresh type during canonicalization" )
364
364
}
365
365
366
- ty:: Placeholder ( placeholder) => Ok ( self . canonicalize_ty_var (
366
+ ty:: Placeholder ( placeholder) => self . canonicalize_ty_var (
367
367
CanonicalVarInfo { kind : CanonicalVarKind :: PlaceholderTy ( placeholder) } ,
368
368
t,
369
- ) ) ,
369
+ ) ,
370
370
371
371
ty:: Bound ( debruijn, _) => {
372
372
if debruijn >= self . binder_index {
373
373
bug ! ( "escaping bound type during canonicalization" )
374
374
} else {
375
- Ok ( t )
375
+ t
376
376
}
377
377
}
378
378
@@ -403,16 +403,13 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
403
403
if t. flags ( ) . intersects ( self . needs_canonical_flags ) {
404
404
t. super_fold_with ( self )
405
405
} else {
406
- Ok ( t )
406
+ t
407
407
}
408
408
}
409
409
}
410
410
}
411
411
412
- fn fold_const (
413
- & mut self ,
414
- ct : & ' tcx ty:: Const < ' tcx > ,
415
- ) -> Result < & ' tcx ty:: Const < ' tcx > , Self :: Error > {
412
+ fn fold_const ( & mut self , ct : & ' tcx ty:: Const < ' tcx > ) -> & ' tcx ty:: Const < ' tcx > {
416
413
match ct. val {
417
414
ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
418
415
debug ! ( "canonical: const var found with vid {:?}" , vid) ;
@@ -427,10 +424,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
427
424
Err ( mut ui) => {
428
425
// FIXME: perf problem described in #55921.
429
426
ui = ty:: UniverseIndex :: ROOT ;
430
- return Ok ( self . canonicalize_const_var (
427
+ return self . canonicalize_const_var (
431
428
CanonicalVarInfo { kind : CanonicalVarKind :: Const ( ui) } ,
432
429
ct,
433
- ) ) ;
430
+ ) ;
434
431
}
435
432
}
436
433
}
@@ -441,20 +438,20 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
441
438
if debruijn >= self . binder_index {
442
439
bug ! ( "escaping bound type during canonicalization" )
443
440
} else {
444
- return Ok ( ct ) ;
441
+ return ct ;
445
442
}
446
443
}
447
444
ty:: ConstKind :: Placeholder ( placeholder) => {
448
- return Ok ( self . canonicalize_const_var (
445
+ return self . canonicalize_const_var (
449
446
CanonicalVarInfo { kind : CanonicalVarKind :: PlaceholderConst ( placeholder) } ,
450
447
ct,
451
- ) ) ;
448
+ ) ;
452
449
}
453
450
_ => { }
454
451
}
455
452
456
453
let flags = FlagComputation :: for_const ( ct) ;
457
- if flags. intersects ( self . needs_canonical_flags ) { ct. super_fold_with ( self ) } else { Ok ( ct ) }
454
+ if flags. intersects ( self . needs_canonical_flags ) { ct. super_fold_with ( self ) } else { ct }
458
455
}
459
456
}
460
457
@@ -503,7 +500,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
503
500
indices : FxHashMap :: default ( ) ,
504
501
binder_index : ty:: INNERMOST ,
505
502
} ;
506
- let out_value = value. fold_with ( & mut canonicalizer) . into_ok ( ) ;
503
+ let out_value = value. fold_with ( & mut canonicalizer) ;
507
504
508
505
// Once we have canonicalized `out_value`, it should not
509
506
// contain anything that ties it to this inference context
@@ -621,7 +618,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
621
618
let infcx = self . infcx ;
622
619
let bound_to = infcx. shallow_resolve ( ty_var) ;
623
620
if bound_to != ty_var {
624
- self . fold_ty ( bound_to) . into_ok ( )
621
+ self . fold_ty ( bound_to)
625
622
} else {
626
623
let var = self . canonical_var ( info, ty_var. into ( ) ) ;
627
624
self . tcx ( ) . mk_ty ( ty:: Bound ( self . binder_index , var. into ( ) ) )
@@ -640,12 +637,12 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
640
637
let infcx = self . infcx ;
641
638
let bound_to = infcx. shallow_resolve ( const_var) ;
642
639
if bound_to != const_var {
643
- self . fold_const ( bound_to) . into_ok ( )
640
+ self . fold_const ( bound_to)
644
641
} else {
645
642
let var = self . canonical_var ( info, const_var. into ( ) ) ;
646
643
self . tcx ( ) . mk_const ( ty:: Const {
647
644
val : ty:: ConstKind :: Bound ( self . binder_index , var) ,
648
- ty : self . fold_ty ( const_var. ty ) . into_ok ( ) ,
645
+ ty : self . fold_ty ( const_var. ty ) ,
649
646
} )
650
647
}
651
648
}
0 commit comments