@@ -502,9 +502,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
502
502
hir:: OpaqueTyOrigin :: AsyncFn => return false ,
503
503
504
504
// Otherwise, generate the label we'll use in the error message.
505
- hir:: OpaqueTyOrigin :: TypeAlias => "impl Trait" ,
506
- hir:: OpaqueTyOrigin :: FnReturn => "impl Trait" ,
507
- hir:: OpaqueTyOrigin :: Misc => "impl Trait" ,
505
+ hir:: OpaqueTyOrigin :: TypeAlias
506
+ | hir:: OpaqueTyOrigin :: FnReturn
507
+ | hir:: OpaqueTyOrigin :: Misc => "impl Trait" ,
508
508
} ;
509
509
let msg = format ! ( "ambiguous lifetime bound in `{}`" , context_name) ;
510
510
let mut err = self . tcx . sess . struct_span_err ( span, & msg) ;
@@ -815,18 +815,25 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
815
815
816
816
fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
817
817
match r {
818
- // Ignore bound regions that appear in the type, they don't need to
819
- // be remapped (e.g., this would ignore `'r` in a type like
820
- // `for<'r> fn(&'r u32)`.
821
- ty:: ReLateBound ( ..)
822
-
823
- // If regions have been erased, don't try to unerase them.
824
- | ty:: ReErased
825
-
826
- // ignore `'static`, as that can appear anywhere
827
- | ty:: ReStatic => return r,
828
-
829
- _ => { }
818
+ // Ignore bound regions and `'static` regions that appear in the
819
+ // type, we only need to remap regions that reference lifetimes
820
+ // from the function declaraion.
821
+ // This would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
822
+ ty:: ReLateBound ( ..) | ty:: ReStatic => return r,
823
+
824
+ // If regions have been erased (by writeback), don't try to unerase
825
+ // them.
826
+ ty:: ReErased => return r,
827
+
828
+ // The regions that we expect from borrow checking.
829
+ ty:: ReEarlyBound ( _) | ty:: ReFree ( _) | ty:: ReEmpty => { }
830
+
831
+ ty:: RePlaceholder ( _) | ty:: ReVar ( _) | ty:: ReScope ( _) | ty:: ReClosureBound ( _) => {
832
+ // All of the regions in the type should either have been
833
+ // erased by writeback, or mapped back to named regions by
834
+ // borrow checking.
835
+ bug ! ( "unexpected region kind in opaque type: {:?}" , r) ;
836
+ }
830
837
}
831
838
832
839
let generics = self . tcx ( ) . generics_of ( self . opaque_type_def_id ) ;
0 commit comments