@@ -278,7 +278,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
278278 self . tcx
279279 }
280280
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 >
282282 where
283283 T : TypeFoldable < ' tcx > ,
284284 {
@@ -288,13 +288,13 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
288288 t
289289 }
290290
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 > {
292292 match * r {
293293 ty:: ReLateBound ( index, ..) => {
294294 if index >= self . binder_index {
295295 bug ! ( "escaping late-bound region during canonicalization" ) ;
296296 } else {
297- Ok ( r )
297+ r
298298 }
299299 }
300300
@@ -311,19 +311,19 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
311311 vid, r
312312 ) ;
313313 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)
315315 }
316316
317317 ty:: ReStatic
318318 | ty:: ReEarlyBound ( ..)
319319 | ty:: ReFree ( _)
320320 | ty:: ReEmpty ( _)
321321 | 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) ,
323323 }
324324 }
325325
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 > {
327327 match * t. kind ( ) {
328328 ty:: Infer ( ty:: TyVar ( vid) ) => {
329329 debug ! ( "canonical: type var found with vid {:?}" , vid) ;
@@ -339,40 +339,40 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
339339 Err ( mut ui) => {
340340 // FIXME: perf problem described in #55921.
341341 ui = ty:: UniverseIndex :: ROOT ;
342- Ok ( self . canonicalize_ty_var (
342+ self . canonicalize_ty_var (
343343 CanonicalVarInfo {
344344 kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( ui) ) ,
345345 } ,
346346 t,
347- ) )
347+ )
348348 }
349349 }
350350 }
351351
352- ty:: Infer ( ty:: IntVar ( _) ) => Ok ( self . canonicalize_ty_var (
352+ ty:: Infer ( ty:: IntVar ( _) ) => self . canonicalize_ty_var (
353353 CanonicalVarInfo { kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int ) } ,
354354 t,
355- ) ) ,
355+ ) ,
356356
357- ty:: Infer ( ty:: FloatVar ( _) ) => Ok ( self . canonicalize_ty_var (
357+ ty:: Infer ( ty:: FloatVar ( _) ) => self . canonicalize_ty_var (
358358 CanonicalVarInfo { kind : CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Float ) } ,
359359 t,
360- ) ) ,
360+ ) ,
361361
362362 ty:: Infer ( ty:: FreshTy ( _) | ty:: FreshIntTy ( _) | ty:: FreshFloatTy ( _) ) => {
363363 bug ! ( "encountered a fresh type during canonicalization" )
364364 }
365365
366- ty:: Placeholder ( placeholder) => Ok ( self . canonicalize_ty_var (
366+ ty:: Placeholder ( placeholder) => self . canonicalize_ty_var (
367367 CanonicalVarInfo { kind : CanonicalVarKind :: PlaceholderTy ( placeholder) } ,
368368 t,
369- ) ) ,
369+ ) ,
370370
371371 ty:: Bound ( debruijn, _) => {
372372 if debruijn >= self . binder_index {
373373 bug ! ( "escaping bound type during canonicalization" )
374374 } else {
375- Ok ( t )
375+ t
376376 }
377377 }
378378
@@ -403,16 +403,13 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
403403 if t. flags ( ) . intersects ( self . needs_canonical_flags ) {
404404 t. super_fold_with ( self )
405405 } else {
406- Ok ( t )
406+ t
407407 }
408408 }
409409 }
410410 }
411411
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 > {
416413 match ct. val {
417414 ty:: ConstKind :: Infer ( InferConst :: Var ( vid) ) => {
418415 debug ! ( "canonical: const var found with vid {:?}" , vid) ;
@@ -427,10 +424,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
427424 Err ( mut ui) => {
428425 // FIXME: perf problem described in #55921.
429426 ui = ty:: UniverseIndex :: ROOT ;
430- return Ok ( self . canonicalize_const_var (
427+ return self . canonicalize_const_var (
431428 CanonicalVarInfo { kind : CanonicalVarKind :: Const ( ui) } ,
432429 ct,
433- ) ) ;
430+ ) ;
434431 }
435432 }
436433 }
@@ -441,20 +438,20 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
441438 if debruijn >= self . binder_index {
442439 bug ! ( "escaping bound type during canonicalization" )
443440 } else {
444- return Ok ( ct ) ;
441+ return ct ;
445442 }
446443 }
447444 ty:: ConstKind :: Placeholder ( placeholder) => {
448- return Ok ( self . canonicalize_const_var (
445+ return self . canonicalize_const_var (
449446 CanonicalVarInfo { kind : CanonicalVarKind :: PlaceholderConst ( placeholder) } ,
450447 ct,
451- ) ) ;
448+ ) ;
452449 }
453450 _ => { }
454451 }
455452
456453 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 }
458455 }
459456}
460457
@@ -503,7 +500,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
503500 indices : FxHashMap :: default ( ) ,
504501 binder_index : ty:: INNERMOST ,
505502 } ;
506- let out_value = value. fold_with ( & mut canonicalizer) . into_ok ( ) ;
503+ let out_value = value. fold_with ( & mut canonicalizer) ;
507504
508505 // Once we have canonicalized `out_value`, it should not
509506 // contain anything that ties it to this inference context
@@ -621,7 +618,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
621618 let infcx = self . infcx ;
622619 let bound_to = infcx. shallow_resolve ( ty_var) ;
623620 if bound_to != ty_var {
624- self . fold_ty ( bound_to) . into_ok ( )
621+ self . fold_ty ( bound_to)
625622 } else {
626623 let var = self . canonical_var ( info, ty_var. into ( ) ) ;
627624 self . tcx ( ) . mk_ty ( ty:: Bound ( self . binder_index , var. into ( ) ) )
@@ -640,12 +637,12 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
640637 let infcx = self . infcx ;
641638 let bound_to = infcx. shallow_resolve ( const_var) ;
642639 if bound_to != const_var {
643- self . fold_const ( bound_to) . into_ok ( )
640+ self . fold_const ( bound_to)
644641 } else {
645642 let var = self . canonical_var ( info, const_var. into ( ) ) ;
646643 self . tcx ( ) . mk_const ( ty:: Const {
647644 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 ) ,
649646 } )
650647 }
651648 }
0 commit comments