@@ -327,165 +327,6 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Pattern<'tcx> {
327327 }
328328}
329329
330- impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for Ty < ' tcx > {
331- fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
332- self ,
333- folder : & mut F ,
334- ) -> Result < Self , F :: Error > {
335- folder. try_fold_ty ( self )
336- }
337-
338- fn fold_with < F : TypeFolder < TyCtxt < ' tcx > > > ( self , folder : & mut F ) -> Self {
339- folder. fold_ty ( self )
340- }
341- }
342-
343- impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for Ty < ' tcx > {
344- fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
345- visitor. visit_ty ( * self )
346- }
347- }
348-
349- impl < ' tcx > TypeSuperFoldable < TyCtxt < ' tcx > > for Ty < ' tcx > {
350- fn try_super_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
351- self ,
352- folder : & mut F ,
353- ) -> Result < Self , F :: Error > {
354- let kind = match * self . kind ( ) {
355- ty:: RawPtr ( ty, mutbl) => ty:: RawPtr ( ty. try_fold_with ( folder) ?, mutbl) ,
356- ty:: Array ( typ, sz) => ty:: Array ( typ. try_fold_with ( folder) ?, sz. try_fold_with ( folder) ?) ,
357- ty:: Slice ( typ) => ty:: Slice ( typ. try_fold_with ( folder) ?) ,
358- ty:: Adt ( tid, args) => ty:: Adt ( tid, args. try_fold_with ( folder) ?) ,
359- ty:: Dynamic ( trait_ty, region) => {
360- ty:: Dynamic ( trait_ty. try_fold_with ( folder) ?, region. try_fold_with ( folder) ?)
361- }
362- ty:: Tuple ( ts) => ty:: Tuple ( ts. try_fold_with ( folder) ?) ,
363- ty:: FnDef ( def_id, args) => ty:: FnDef ( def_id, args. try_fold_with ( folder) ?) ,
364- ty:: FnPtr ( sig_tys, hdr) => ty:: FnPtr ( sig_tys. try_fold_with ( folder) ?, hdr) ,
365- ty:: UnsafeBinder ( f) => ty:: UnsafeBinder ( f. try_fold_with ( folder) ?) ,
366- ty:: Ref ( r, ty, mutbl) => {
367- ty:: Ref ( r. try_fold_with ( folder) ?, ty. try_fold_with ( folder) ?, mutbl)
368- }
369- ty:: Coroutine ( did, args) => ty:: Coroutine ( did, args. try_fold_with ( folder) ?) ,
370- ty:: CoroutineWitness ( did, args) => {
371- ty:: CoroutineWitness ( did, args. try_fold_with ( folder) ?)
372- }
373- ty:: Closure ( did, args) => ty:: Closure ( did, args. try_fold_with ( folder) ?) ,
374- ty:: CoroutineClosure ( did, args) => {
375- ty:: CoroutineClosure ( did, args. try_fold_with ( folder) ?)
376- }
377- ty:: Alias ( kind, data) => ty:: Alias ( kind, data. try_fold_with ( folder) ?) ,
378- ty:: Pat ( ty, pat) => ty:: Pat ( ty. try_fold_with ( folder) ?, pat. try_fold_with ( folder) ?) ,
379-
380- ty:: Bool
381- | ty:: Char
382- | ty:: Str
383- | ty:: Int ( _)
384- | ty:: Uint ( _)
385- | ty:: Float ( _)
386- | ty:: Error ( _)
387- | ty:: Infer ( _)
388- | ty:: Param ( ..)
389- | ty:: Bound ( ..)
390- | ty:: Placeholder ( ..)
391- | ty:: Never
392- | ty:: Foreign ( ..) => return Ok ( self ) ,
393- } ;
394-
395- Ok ( if * self . kind ( ) == kind { self } else { folder. cx ( ) . mk_ty_from_kind ( kind) } )
396- }
397-
398- fn super_fold_with < F : TypeFolder < TyCtxt < ' tcx > > > ( self , folder : & mut F ) -> Self {
399- let kind = match * self . kind ( ) {
400- ty:: RawPtr ( ty, mutbl) => ty:: RawPtr ( ty. fold_with ( folder) , mutbl) ,
401- ty:: Array ( typ, sz) => ty:: Array ( typ. fold_with ( folder) , sz. fold_with ( folder) ) ,
402- ty:: Slice ( typ) => ty:: Slice ( typ. fold_with ( folder) ) ,
403- ty:: Adt ( tid, args) => ty:: Adt ( tid, args. fold_with ( folder) ) ,
404- ty:: Dynamic ( trait_ty, region) => {
405- ty:: Dynamic ( trait_ty. fold_with ( folder) , region. fold_with ( folder) )
406- }
407- ty:: Tuple ( ts) => ty:: Tuple ( ts. fold_with ( folder) ) ,
408- ty:: FnDef ( def_id, args) => ty:: FnDef ( def_id, args. fold_with ( folder) ) ,
409- ty:: FnPtr ( sig_tys, hdr) => ty:: FnPtr ( sig_tys. fold_with ( folder) , hdr) ,
410- ty:: UnsafeBinder ( f) => ty:: UnsafeBinder ( f. fold_with ( folder) ) ,
411- ty:: Ref ( r, ty, mutbl) => ty:: Ref ( r. fold_with ( folder) , ty. fold_with ( folder) , mutbl) ,
412- ty:: Coroutine ( did, args) => ty:: Coroutine ( did, args. fold_with ( folder) ) ,
413- ty:: CoroutineWitness ( did, args) => ty:: CoroutineWitness ( did, args. fold_with ( folder) ) ,
414- ty:: Closure ( did, args) => ty:: Closure ( did, args. fold_with ( folder) ) ,
415- ty:: CoroutineClosure ( did, args) => ty:: CoroutineClosure ( did, args. fold_with ( folder) ) ,
416- ty:: Alias ( kind, data) => ty:: Alias ( kind, data. fold_with ( folder) ) ,
417- ty:: Pat ( ty, pat) => ty:: Pat ( ty. fold_with ( folder) , pat. fold_with ( folder) ) ,
418-
419- ty:: Bool
420- | ty:: Char
421- | ty:: Str
422- | ty:: Int ( _)
423- | ty:: Uint ( _)
424- | ty:: Float ( _)
425- | ty:: Error ( _)
426- | ty:: Infer ( _)
427- | ty:: Param ( ..)
428- | ty:: Bound ( ..)
429- | ty:: Placeholder ( ..)
430- | ty:: Never
431- | ty:: Foreign ( ..) => return self ,
432- } ;
433-
434- if * self . kind ( ) == kind { self } else { folder. cx ( ) . mk_ty_from_kind ( kind) }
435- }
436- }
437-
438- impl < ' tcx > TypeSuperVisitable < TyCtxt < ' tcx > > for Ty < ' tcx > {
439- fn super_visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
440- match self . kind ( ) {
441- ty:: RawPtr ( ty, _mutbl) => ty. visit_with ( visitor) ,
442- ty:: Array ( typ, sz) => {
443- try_visit ! ( typ. visit_with( visitor) ) ;
444- sz. visit_with ( visitor)
445- }
446- ty:: Slice ( typ) => typ. visit_with ( visitor) ,
447- ty:: Adt ( _, args) => args. visit_with ( visitor) ,
448- ty:: Dynamic ( trait_ty, reg) => {
449- try_visit ! ( trait_ty. visit_with( visitor) ) ;
450- reg. visit_with ( visitor)
451- }
452- ty:: Tuple ( ts) => ts. visit_with ( visitor) ,
453- ty:: FnDef ( _, args) => args. visit_with ( visitor) ,
454- ty:: FnPtr ( sig_tys, _) => sig_tys. visit_with ( visitor) ,
455- ty:: UnsafeBinder ( f) => f. visit_with ( visitor) ,
456- ty:: Ref ( r, ty, _) => {
457- try_visit ! ( r. visit_with( visitor) ) ;
458- ty. visit_with ( visitor)
459- }
460- ty:: Coroutine ( _did, args) => args. visit_with ( visitor) ,
461- ty:: CoroutineWitness ( _did, args) => args. visit_with ( visitor) ,
462- ty:: Closure ( _did, args) => args. visit_with ( visitor) ,
463- ty:: CoroutineClosure ( _did, args) => args. visit_with ( visitor) ,
464- ty:: Alias ( _, data) => data. visit_with ( visitor) ,
465-
466- ty:: Pat ( ty, pat) => {
467- try_visit ! ( ty. visit_with( visitor) ) ;
468- pat. visit_with ( visitor)
469- }
470-
471- ty:: Error ( guar) => guar. visit_with ( visitor) ,
472-
473- ty:: Bool
474- | ty:: Char
475- | ty:: Str
476- | ty:: Int ( _)
477- | ty:: Uint ( _)
478- | ty:: Float ( _)
479- | ty:: Infer ( _)
480- | ty:: Bound ( ..)
481- | ty:: Placeholder ( ..)
482- | ty:: Param ( ..)
483- | ty:: Never
484- | ty:: Foreign ( ..) => V :: Result :: output ( ) ,
485- }
486- }
487- }
488-
489330impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for ty:: Region < ' tcx > {
490331 fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
491332 self ,
0 commit comments