This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +28
-12
lines changed
compiler/rustc_typeck/src/check/generator_interior Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,18 @@ impl TrackedValue {
116116 TrackedValue :: Variable ( hir_id) | TrackedValue :: Temporary ( hir_id) => * hir_id,
117117 }
118118 }
119+
120+ fn from_place_with_projections_allowed ( place_with_id : & PlaceWithHirId < ' _ > ) -> Self {
121+ match place_with_id. place . base {
122+ PlaceBase :: Rvalue | PlaceBase :: StaticItem => {
123+ TrackedValue :: Temporary ( place_with_id. hir_id )
124+ }
125+ PlaceBase :: Local ( hir_id)
126+ | PlaceBase :: Upvar ( ty:: UpvarId { var_path : ty:: UpvarPath { hir_id } , .. } ) => {
127+ TrackedValue :: Variable ( hir_id)
128+ }
129+ }
130+ }
119131}
120132
121133/// Represents a reason why we might not be able to convert a HirId or Place
@@ -142,15 +154,7 @@ impl TryFrom<&PlaceWithHirId<'_>> for TrackedValue {
142154 return Err ( TrackedValueConversionError :: PlaceProjectionsNotSupported ) ;
143155 }
144156
145- match place_with_id. place . base {
146- PlaceBase :: Rvalue | PlaceBase :: StaticItem => {
147- Ok ( TrackedValue :: Temporary ( place_with_id. hir_id ) )
148- }
149- PlaceBase :: Local ( hir_id)
150- | PlaceBase :: Upvar ( ty:: UpvarId { var_path : ty:: UpvarPath { hir_id } , .. } ) => {
151- Ok ( TrackedValue :: Variable ( hir_id) )
152- }
153- }
157+ Ok ( TrackedValue :: from_place_with_projections_allowed ( place_with_id) )
154158 }
155159}
156160
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
9696 _diag_expr_id : HirId ,
9797 _bk : rustc_middle:: ty:: BorrowKind ,
9898 ) {
99- place_with_id
100- . try_into ( )
101- . map_or ( false , |tracked_value| self . places . borrowed . insert ( tracked_value ) ) ;
99+ self . places
100+ . borrowed
101+ . insert ( TrackedValue :: from_place_with_projections_allowed ( place_with_id ) ) ;
102102 }
103103
104104 fn mutate (
Original file line number Diff line number Diff line change 1+ // edition:2021
2+ // build-pass
3+ // compile-flags: -Zdrop-tracking
4+
5+ fn main ( ) {
6+ let _ = async {
7+ let mut s = ( String :: new ( ) , ) ;
8+ s. 0 . push_str ( "abc" ) ;
9+ std:: mem:: drop ( s) ;
10+ async { } . await ;
11+ } ;
12+ }
You can’t perform that action at this time.
0 commit comments