diff options
| author | bors <bors@rust-lang.org> | 2020-04-19 10:01:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-04-19 10:01:16 +0000 |
| commit | 36b1a9296cde2b773771710e9bbd608fd2eca35f (patch) | |
| tree | 947177af14398a42dc1727bd075488b53cd65f63 /src/test/ui/generator | |
| parent | e7497a8ccb8885823e413f4e3a54412812b60528 (diff) | |
| parent | ae533151c3a29be2edb71398b7d9ed6e51e77f25 (diff) | |
| download | rust-36b1a9296cde2b773771710e9bbd608fd2eca35f.tar.gz rust-36b1a9296cde2b773771710e9bbd608fd2eca35f.zip | |
Auto merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper
Make `needs_drop` less pessimistic on generators Generators only have non-trivial drop logic when they may store (in upvars or across yields) a type that does. This prevents generation of some unnecessary MIR in simple generators. There might be some impact on compile times, but this is probably limited in real-world applications. ~~This builds off of https://github.com/rust-lang/rust/pull/69814 since that contains some fixes that are made relevant by *this* PR (see https://github.com/rust-lang/rust/pull/69814#issuecomment-599147269).~~ (this has been merged)
Diffstat (limited to 'src/test/ui/generator')
| -rw-r--r-- | src/test/ui/generator/borrowing.stderr | 15 | ||||
| -rw-r--r-- | src/test/ui/generator/retain-resume-ref.stderr | 7 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/test/ui/generator/borrowing.stderr b/src/test/ui/generator/borrowing.stderr index 83987e19839..38e1ace8c4e 100644 --- a/src/test/ui/generator/borrowing.stderr +++ b/src/test/ui/generator/borrowing.stderr @@ -1,19 +1,16 @@ error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:9:33 | +LL | let _b = { + | -- borrow later stored here +LL | let a = 3; LL | Pin::new(&mut || yield &a).resume(()) - | ----------^ - | | | - | | borrowed value does not live long enough + | -- ^ borrowed value does not live long enough + | | | value captured here by generator - | a temporary with access to the borrow is created here ... LL | LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator - | | - | `a` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. + | - `a` dropped here while still borrowed error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:16:20 diff --git a/src/test/ui/generator/retain-resume-ref.stderr b/src/test/ui/generator/retain-resume-ref.stderr index bc715c7030e..e33310d12d9 100644 --- a/src/test/ui/generator/retain-resume-ref.stderr +++ b/src/test/ui/generator/retain-resume-ref.stderr @@ -4,10 +4,9 @@ error[E0499]: cannot borrow `thing` as mutable more than once at a time LL | gen.as_mut().resume(&mut thing); | ---------- first mutable borrow occurs here LL | gen.as_mut().resume(&mut thing); - | ^^^^^^^^^^ second mutable borrow occurs here -LL | -LL | } - | - first borrow might be used here, when `gen` is dropped and runs the destructor for generator + | ------ ^^^^^^^^^^ second mutable borrow occurs here + | | + | first borrow later used by call error: aborting due to previous error |
