File tree 3 files changed +28
-12
lines changed
compiler/rustc_typeck/src/check/generator_interior
3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,18 @@ impl TrackedValue {
116
116
TrackedValue :: Variable ( hir_id) | TrackedValue :: Temporary ( hir_id) => * hir_id,
117
117
}
118
118
}
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
+ }
119
131
}
120
132
121
133
/// Represents a reason why we might not be able to convert a HirId or Place
@@ -142,15 +154,7 @@ impl TryFrom<&PlaceWithHirId<'_>> for TrackedValue {
142
154
return Err ( TrackedValueConversionError :: PlaceProjectionsNotSupported ) ;
143
155
}
144
156
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) )
154
158
}
155
159
}
156
160
Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
96
96
_diag_expr_id : HirId ,
97
97
_bk : rustc_middle:: ty:: BorrowKind ,
98
98
) {
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 ) ) ;
102
102
}
103
103
104
104
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