File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
compiler/rustc_typeck/src/check/generator_interior/drop_ranges Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,13 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
171
171
. insert ( TrackedValue :: from_place_with_projections_allowed ( place_with_id) ) ;
172
172
173
173
// For copied we treat this mostly like a borrow except that we don't add the place
174
- // to borrowed_temporaries because the copy is consumed.
174
+ // to borrowed_temporaries if it is not a local because the copy is consumed.
175
+ match place_with_id. place . base {
176
+ PlaceBase :: Rvalue | PlaceBase :: StaticItem | PlaceBase :: Upvar ( _) => ( ) ,
177
+ PlaceBase :: Local ( _) => {
178
+ self . places . borrowed_temporaries . insert ( place_with_id. hir_id ) ;
179
+ }
180
+ }
175
181
}
176
182
177
183
fn mutate (
Original file line number Diff line number Diff line change 14
14
#![ feature( generators) ]
15
15
16
16
fn main ( ) {
17
- let _ = static |x : u8 | match x {
17
+ let _a = static |x : u8 | match x {
18
18
y if { yield } == y + 1 => ( ) ,
19
19
_ => ( ) ,
20
20
} ;
21
+
22
+ static STATIC : u8 = 42 ;
23
+ let _b = static |x : u8 | match x {
24
+ y if { yield } == STATIC + 1 => ( ) ,
25
+ _ => ( ) ,
26
+ } ;
27
+
28
+ let upvar = 42u8 ;
29
+ let _c = static |x : u8 | match x {
30
+ y if { yield } == upvar + 1 => ( ) ,
31
+ _ => ( ) ,
32
+ } ;
21
33
}
You can’t perform that action at this time.
0 commit comments