diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-09-19 11:41:10 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2019-09-19 11:50:00 -0400 |
| commit | b2c51c24c96f8827eefc6f0de29636cc4cb6ff2c (patch) | |
| tree | fedf90b2380e3fd29ba5bfa23967369f0ae49b91 /src/test/ui | |
| parent | e35698371d36da83d3aca8322ad812fa5512b90f (diff) | |
| download | rust-b2c51c24c96f8827eefc6f0de29636cc4cb6ff2c.tar.gz rust-b2c51c24c96f8827eefc6f0de29636cc4cb6ff2c.zip | |
avoid generating drops for moved operands of calls
Currently, after a CALL terminator is created in MIR, we insert DROP statements for all of its operands -- even though they were just moved shortly before! These spurious drops are later removed, but not before causing borrow check errors. This PR series modifies the drop code to track operands that were moved and avoid creating drops for them. Right now, I'm only using this mechanism for calls, but it seems likely it could be used in more places.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/async-await/issues/issue-64391-2.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/async-await/issues/issue-64433.rs | 29 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/test/ui/async-await/issues/issue-64391-2.rs b/src/test/ui/async-await/issues/issue-64391-2.rs new file mode 100644 index 00000000000..528704c0e45 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-64391-2.rs @@ -0,0 +1,17 @@ +// Regression test for #64391 +// +// As described on the issue, the (spurious) `DROP` inserted for the +// `"".to_string()` value was causing a (spurious) unwind path that +// led us to believe that the future might be dropped after `config` +// had been dropped. This cannot, in fact, happen. + +async fn connect() { + let config = 666; + connect2(&config, "".to_string()).await +} + +async fn connect2(_config: &u32, _tls: String) { + unimplemented!() +} + +fn main() { } diff --git a/src/test/ui/async-await/issues/issue-64433.rs b/src/test/ui/async-await/issues/issue-64433.rs new file mode 100644 index 00000000000..ca819e78fb8 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-64433.rs @@ -0,0 +1,29 @@ +// Regression test for issue #64433. +// +// See issue-64391-2.rs for more details, as that was fixed by the +// same PR. +// +// check-pass + +#[derive(Debug)] +struct A<'a> { + inner: Vec<&'a str>, +} + +struct B {} + +impl B { + async fn something_with_a(&mut self, a: A<'_>) -> Result<(), String> { + println!("{:?}", a); + Ok(()) + } +} + +async fn can_error(some_string: &str) -> Result<(), String> { + let a = A { inner: vec![some_string, "foo"] }; + let mut b = B {}; + Ok(b.something_with_a(a).await.map(|_| ())?) +} + +fn main() { +} |
