mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Count copies of locals as borrowed temporaries
This commit is contained in:
parent
577bf0f354
commit
d5b72058fe
@ -171,7 +171,13 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
|
|||||||
.insert(TrackedValue::from_place_with_projections_allowed(place_with_id));
|
.insert(TrackedValue::from_place_with_projections_allowed(place_with_id));
|
||||||
|
|
||||||
// For copied we treat this mostly like a borrow except that we don't add the place
|
// For copied we treat this mostly like a borrow except that we don't add the place
|
||||||
// to borrowed_temporaries because the copy is consumed.
|
// to borrowed_temporaries if it is not a local because the copy is consumed.
|
||||||
|
match place_with_id.place.base {
|
||||||
|
PlaceBase::Rvalue | PlaceBase::StaticItem | PlaceBase::Upvar(_) => (),
|
||||||
|
PlaceBase::Local(_) => {
|
||||||
|
self.places.borrowed_temporaries.insert(place_with_id.hir_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate(
|
fn mutate(
|
||||||
|
@ -14,8 +14,20 @@
|
|||||||
#![feature(generators)]
|
#![feature(generators)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = static |x: u8| match x {
|
let _a = static |x: u8| match x {
|
||||||
y if { yield } == y + 1 => (),
|
y if { yield } == y + 1 => (),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static STATIC: u8 = 42;
|
||||||
|
let _b = static |x: u8| match x {
|
||||||
|
y if { yield } == STATIC + 1 => (),
|
||||||
|
_ => (),
|
||||||
|
};
|
||||||
|
|
||||||
|
let upvar = 42u8;
|
||||||
|
let _c = static |x: u8| match x {
|
||||||
|
y if { yield } == upvar + 1 => (),
|
||||||
|
_ => (),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user