@@ -2,7 +2,6 @@ use rustc_data_structures::fx::FxHashMap;
2
2
use rustc_data_structures:: vec_map:: VecMap ;
3
3
use rustc_hir:: def_id:: LocalDefId ;
4
4
use rustc_hir:: OpaqueTyOrigin ;
5
- use rustc_infer:: infer:: error_reporting:: unexpected_hidden_region_diagnostic;
6
5
use rustc_infer:: infer:: TyCtxtInferExt as _;
7
6
use rustc_infer:: infer:: { DefiningAnchor , InferCtxt } ;
8
7
use rustc_infer:: traits:: { Obligation , ObligationCause , TraitEngine } ;
@@ -248,9 +247,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
248
247
// after producing an error for each of them.
249
248
let definition_ty = instantiated_ty. ty . fold_with ( & mut ReverseMapper :: new (
250
249
self . tcx ,
251
- opaque_type_key,
252
250
map,
253
- instantiated_ty. ty ,
254
251
instantiated_ty. span ,
255
252
) ) ;
256
253
debug ! ( ?definition_ty) ;
@@ -427,27 +424,20 @@ fn check_opaque_type_parameter_valid(
427
424
428
425
struct ReverseMapper < ' tcx > {
429
426
tcx : TyCtxt < ' tcx > ,
430
-
431
- key : ty:: OpaqueTypeKey < ' tcx > ,
432
427
map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
433
428
do_not_error : bool ,
434
429
435
- /// initially `Some`, set to `None` once error has been reported
436
- hidden_ty : Option < Ty < ' tcx > > ,
437
-
438
430
/// Span of function being checked.
439
431
span : Span ,
440
432
}
441
433
442
434
impl < ' tcx > ReverseMapper < ' tcx > {
443
435
fn new (
444
436
tcx : TyCtxt < ' tcx > ,
445
- key : ty:: OpaqueTypeKey < ' tcx > ,
446
437
map : FxHashMap < GenericArg < ' tcx > , GenericArg < ' tcx > > ,
447
- hidden_ty : Ty < ' tcx > ,
448
438
span : Span ,
449
439
) -> 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 }
451
441
}
452
442
453
443
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> {
493
483
}
494
484
}
495
485
496
- let generics = self . tcx ( ) . generics_of ( self . key . def_id ) ;
497
486
match self . map . get ( & r. into ( ) ) . map ( |k| k. unpack ( ) ) {
498
487
Some ( GenericArgKind :: Lifetime ( r1) ) => r1,
499
488
Some ( u) => panic ! ( "region mapped to unexpected kind: {:?}" , u) ,
500
489
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
- }
514
490
None => {
515
491
self . tcx
516
492
. sess
0 commit comments