diff --git a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs index 92d30f254a6af..f8bf5510a6459 100644 --- a/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs +++ b/compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs @@ -91,6 +91,12 @@ where } } + mir::Rvalue::Use(mir::Operand::Move(place)) => { + if place.projection.len() == 0 { + self.trans.kill(place.local) + } + } + mir::Rvalue::Cast(..) | mir::Rvalue::ShallowInitBox(..) | mir::Rvalue::Use(..) diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 4c4423721fb8c..20000701eb298 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -717,6 +717,7 @@ impl GeneratorSavedLocals { out.insert(saved_local); } } + out } diff --git a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr index b89d868040750..c4665ee26e450 100644 --- a/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/drop-track-field-assign-nonsend.drop_tracking_mir.stderr @@ -5,14 +5,11 @@ LL | assert_send(agent.handle()); | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/drop-track-field-assign-nonsend.rs:23:38 +note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` + --> $DIR/drop-track-field-assign-nonsend.rs:19:21 | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later +LL | async fn handle(&mut self) { + | ^^^^^^^^^ has type `&mut Agent` which is not `Send`, because `Agent` is not `Send` note: required by a bound in `assert_send` --> $DIR/drop-track-field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr index 8c9d14d624cd9..bbf9a3fae7ad2 100644 --- a/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr +++ b/tests/ui/async-await/field-assign-nonsend.drop_tracking_mir.stderr @@ -5,14 +5,11 @@ LL | assert_send(agent.handle()); | ^^^^^^^^^^^^^^ future returned by `handle` is not `Send` | = help: within `impl Future`, the trait `Send` is not implemented for `Rc` -note: future is not `Send` as this value is used across an await - --> $DIR/field-assign-nonsend.rs:23:38 +note: captured value is not `Send` because `&mut` references cannot be sent unless their referent is `Send` + --> $DIR/field-assign-nonsend.rs:19:21 | -LL | let mut info = self.info_result.clone(); - | -------- has type `InfoResult` which is not `Send` -... -LL | let _ = send_element(element).await; - | ^^^^^^ await occurs here, with `mut info` maybe used later +LL | async fn handle(&mut self) { + | ^^^^^^^^^ has type `&mut Agent` which is not `Send`, because `Agent` is not `Send` note: required by a bound in `assert_send` --> $DIR/field-assign-nonsend.rs:40:19 | diff --git a/tests/ui/async-await/issue-96084.rs b/tests/ui/async-await/issue-96084.rs new file mode 100644 index 0000000000000..7e84c155330a3 --- /dev/null +++ b/tests/ui/async-await/issue-96084.rs @@ -0,0 +1,33 @@ +// run-pass +// edition:2018 + +use std::mem; + +async fn foo() { + let x = [0u8; 100]; + async {}.await; + println!("{}", x.len()); +} + +async fn a() { + let fut = foo(); + let fut = fut; + fut.await; +} + +async fn b() { + let fut = foo(); + println!("{}", mem::size_of_val(&fut)); + let fut = fut; + fut.await; +} + +fn main() { + assert_eq!(mem::size_of_val(&foo()), 102); + + // 1 + sizeof(foo) + assert_eq!(mem::size_of_val(&a()), 103); + + // 1 + (sizeof(foo) * 2) + assert_eq!(mem::size_of_val(&b()), 103); +} diff --git a/tests/ui/generator/size-moved-locals.rs b/tests/ui/generator/size-moved-locals.rs index 601a314182876..32a75b274a23e 100644 --- a/tests/ui/generator/size-moved-locals.rs +++ b/tests/ui/generator/size-moved-locals.rs @@ -73,6 +73,6 @@ fn overlap_x_and_y() -> impl Generator { fn main() { assert_eq!(1025, std::mem::size_of_val(&move_before_yield())); assert_eq!(1026, std::mem::size_of_val(&move_before_yield_with_noop())); - assert_eq!(2051, std::mem::size_of_val(&overlap_move_points())); + assert_eq!(1027, std::mem::size_of_val(&overlap_move_points())); assert_eq!(1026, std::mem::size_of_val(&overlap_x_and_y())); }