-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
e356983
commit b2c51c2
Showing
5 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} |