@@ -2,7 +2,6 @@ use rustc_data_structures::fx::FxHashMap;
22use rustc_data_structures:: vec_map:: VecMap ;
33use rustc_hir:: def_id:: LocalDefId ;
44use rustc_hir:: OpaqueTyOrigin ;
5- use rustc_infer:: infer:: error_reporting:: unexpected_hidden_region_diagnostic;
65use rustc_infer:: infer:: TyCtxtInferExt as _;
76use rustc_infer:: infer:: { DefiningAnchor , InferCtxt } ;
87use rustc_infer:: traits:: { Obligation , ObligationCause , TraitEngine } ;
@@ -248,9 +247,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
248247 // after producing an error for each of them.
249248 let definition_ty = instantiated_ty. ty . fold_with ( & mut ReverseMapper :: new (
250249 self . tcx ,
251- opaque_type_key,
252250 map,
253- instantiated_ty. ty ,
254251 instantiated_ty. span ,
255252 ) ) ;
256253 debug ! ( ?definition_ty) ;
@@ -427,27 +424,20 @@ fn check_opaque_type_parameter_valid(
427424
428425struct ReverseMapper < ' tcx > {
429426 tcx : TyCtxt < ' tcx > ,
430-
431- key : ty:: OpaqueTypeKey < ' tcx > ,
432427 map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
433428 do_not_error : bool ,
434429
435- /// initially `Some`, set to `None` once error has been reported
436- hidden_ty : Option < Ty < ' tcx > > ,
437-
438430 /// Span of function being checked.
439431 span : Span ,
440432}
441433
442434impl < ' tcx > ReverseMapper < ' tcx > {
443435 fn new (
444436 tcx : TyCtxt < ' tcx > ,
445- key : ty:: OpaqueTypeKey < ' tcx > ,
446437 map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
447- hidden_ty : Ty < ' tcx > ,
448438 span : Span ,
449439 ) -> Self {
450- Self { tcx, key , map, do_not_error : false , hidden_ty : Some ( hidden_ty ) , span }
440+ Self { tcx, map, do_not_error : false , span }
451441 }
452442
453443 fn fold_kind_no_missing_regions_error ( & mut self , kind : GenericArg < ' tcx > ) -> GenericArg < ' tcx > {
@@ -493,24 +483,10 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
493483 }
494484 }
495485
496- let generics = self . tcx ( ) . generics_of ( self . key . def_id ) ;
497486 match self . map . get ( & r. into ( ) ) . map ( |k| k. unpack ( ) ) {
498487 Some ( GenericArgKind :: Lifetime ( r1) ) => r1,
499488 Some ( u) => panic ! ( "region mapped to unexpected kind: {:?}" , u) ,
500489 None if self . do_not_error => self . tcx . lifetimes . re_static ,
501- None if generics. parent . is_some ( ) => {
502- if let Some ( hidden_ty) = self . hidden_ty . take ( ) {
503- unexpected_hidden_region_diagnostic (
504- self . tcx ,
505- self . tcx . def_span ( self . key . def_id ) ,
506- hidden_ty,
507- r,
508- self . key ,
509- )
510- . emit ( ) ;
511- }
512- self . tcx . lifetimes . re_static
513- }
514490 None => {
515491 self . tcx
516492 . sess
0 commit comments