@@ -39,7 +39,7 @@ use rustc_mir_dataflow::move_paths::MoveData;
39
39
use rustc_mir_dataflow:: points:: DenseLocationMap ;
40
40
use rustc_span:: def_id:: CRATE_DEF_ID ;
41
41
use rustc_span:: source_map:: Spanned ;
42
- use rustc_span:: { DUMMY_SP , Span , sym} ;
42
+ use rustc_span:: { Span , sym} ;
43
43
use rustc_trait_selection:: traits:: query:: type_op:: custom:: scrape_region_constraints;
44
44
use rustc_trait_selection:: traits:: query:: type_op:: { TypeOp , TypeOpOutput } ;
45
45
use tracing:: { debug, instrument, trace} ;
@@ -52,7 +52,6 @@ use crate::polonius::legacy::{PoloniusFacts, PoloniusLocationTable};
52
52
use crate :: polonius:: { PoloniusContext , PoloniusLivenessContext } ;
53
53
use crate :: region_infer:: TypeTest ;
54
54
use crate :: region_infer:: values:: { LivenessValues , PlaceholderIndex , PlaceholderIndices } ;
55
- use crate :: renumber:: RegionCtxt ;
56
55
use crate :: session_diagnostics:: { MoveUnsized , SimdIntrinsicArgConst } ;
57
56
use crate :: type_check:: free_region_relations:: { CreateResult , UniversalRegionRelations } ;
58
57
use crate :: universal_regions:: { DefiningTy , UniversalRegions } ;
@@ -2120,8 +2119,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2120
2119
//
2121
2120
// Note that other checks (such as denying `dyn Send` -> `dyn
2122
2121
// Debug`) are in `rustc_hir_typeck`.
2123
- if let ty:: Dynamic ( src_tty, ..) = src_tail. kind ( )
2124
- && let ty:: Dynamic ( dst_tty, ..) = dst_tail. kind ( )
2122
+ if let ty:: Dynamic ( src_tty, src_region_bound, ..) = src_tail. kind ( )
2123
+ && let ty:: Dynamic ( dst_tty, dst_region_bound, ..) =
2124
+ dst_tail. kind ( )
2125
2125
&& src_tty. principal ( ) . is_some ( )
2126
2126
&& dst_tty. principal ( ) . is_some ( )
2127
2127
{
@@ -2131,25 +2131,17 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2131
2131
tcx. mk_poly_existential_predicates (
2132
2132
& src_tty. without_auto_traits ( ) . collect :: < Vec < _ > > ( ) ,
2133
2133
) ,
2134
- tcx . lifetimes . re_static ,
2134
+ * src_region_bound ,
2135
2135
ty:: Dyn ,
2136
2136
) ) ;
2137
2137
let dst_obj = tcx. mk_ty_from_kind ( ty:: Dynamic (
2138
2138
tcx. mk_poly_existential_predicates (
2139
2139
& dst_tty. without_auto_traits ( ) . collect :: < Vec < _ > > ( ) ,
2140
2140
) ,
2141
- tcx . lifetimes . re_static ,
2141
+ * dst_region_bound ,
2142
2142
ty:: Dyn ,
2143
2143
) ) ;
2144
2144
2145
- // Replace trait object lifetimes with fresh vars, to allow
2146
- // casts like
2147
- // `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static`
2148
- let src_obj =
2149
- freshen_single_trait_object_lifetime ( self . infcx , src_obj) ;
2150
- let dst_obj =
2151
- freshen_single_trait_object_lifetime ( self . infcx , dst_obj) ;
2152
-
2153
2145
debug ! ( ?src_tty, ?dst_tty, ?src_obj, ?dst_obj) ;
2154
2146
2155
2147
self . sub_types (
@@ -2706,16 +2698,3 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> {
2706
2698
Ok ( output)
2707
2699
}
2708
2700
}
2709
-
2710
- fn freshen_single_trait_object_lifetime < ' tcx > (
2711
- infcx : & BorrowckInferCtxt < ' tcx > ,
2712
- ty : Ty < ' tcx > ,
2713
- ) -> Ty < ' tcx > {
2714
- let & ty:: Dynamic ( tty, _, dyn_kind @ ty:: Dyn ) = ty. kind ( ) else { bug ! ( "expected trait object" ) } ;
2715
-
2716
- let fresh = infcx
2717
- . next_region_var ( rustc_infer:: infer:: RegionVariableOrigin :: MiscVariable ( DUMMY_SP ) , || {
2718
- RegionCtxt :: Unknown
2719
- } ) ;
2720
- infcx. tcx . mk_ty_from_kind ( ty:: Dynamic ( tty, fresh, dyn_kind) )
2721
- }
0 commit comments