Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign updropck seems overconservative when dealing with matches at the end of a block #22252
Comments
sfackler
added
the
A-destructors
label
Feb 13, 2015
This comment has been minimized.
This comment has been minimized.
|
This may be a dup of #21114 |
This comment has been minimized.
This comment has been minimized.
|
I think this might be a consequence of our rules for r-value temporaries, where the temporaries in the expression at the end of a block are assigned a lifetime longer than that of the But then again, that answer is not very satisfying without an example of what kind of unsoundness this is supposedly preventing. (I do not have an example ready on hand, but you've given me a place to start.) |
This comment has been minimized.
This comment has been minimized.
|
cc #22321 |
This comment has been minimized.
This comment has been minimized.
|
also, cc #12032 ;) |
This comment has been minimized.
This comment has been minimized.
theemathas
commented
Feb 23, 2015
|
The problem does not require a Simpler reproduction code: #![feature(unsafe_destructor)]
struct Foo;
struct FooRef<'a>(&'a Foo);
impl<'a> FooRef<'a> {
fn borrow(&self) {}
}
#[unsafe_destructor]
impl<'a> Drop for FooRef<'a> {
fn drop(&mut self) {}
}
fn main() {
let x = Foo;
FooRef(&x).borrow()
}The error: <anon>:17:13: 17:14 error: `x` does not live long enough
<anon>:17 FooRef(&x).borrow()
^
<anon>:15:11: 18:2 note: reference must be valid for the destruction scope surrounding block at 15:10...
<anon>:15 fn main() {
<anon>:16 let x = Foo;
<anon>:17 FooRef(&x).borrow()
<anon>:18 }
<anon>:16:16: 18:2 note: ...but borrowed value is only valid for the block suffix following statement 0 at 16:15
<anon>:16 let x = Foo;
<anon>:17 FooRef(&x).borrow()
<anon>:18 } |
worr
added a commit
to worr/yup-oauth2
that referenced
this issue
May 11, 2015
worr
added a commit
to worr/yup-oauth2
that referenced
this issue
May 11, 2015
worr
added a commit
to worr/yup-oauth2
that referenced
this issue
May 11, 2015
This was referenced May 11, 2015
SimonSapin
referenced this issue
Jul 29, 2015
Merged
Fix CSSStyleDeclaration::setPropertyPriority and some refactoring #6741
Ryman
referenced this issue
May 9, 2016
Closed
Implicit return leads to "does not live long enough" error. #31439
This comment has been minimized.
This comment has been minimized.
|
Triage: no change, at least for the example provided by @theemathas |
This comment has been minimized.
This comment has been minimized.
|
This looks like a duplicate of #33490 - on MIR it would be a segfault, on trans it (incorrectly) isn't. |
arielb1
closed this
May 24, 2016
This comment has been minimized.
This comment has been minimized.
|
@arielb1 This is a bug about a compilation error, not a runtime failure, so I don't think this is a duplicate of that issue (which was also filed a year and a half after this one). |
This comment has been minimized.
This comment has been minimized.
|
The issues have the same root cause - borrowck/MIR have a notion of destruction order that makes this code obviously wrong. Trans uses a different destruction order, but that is problematic. |
This comment has been minimized.
This comment has been minimized.
|
#33490 is closed but this issue still exists in nightly. Without the |
This comment has been minimized.
This comment has been minimized.
|
#33490 seems open to me? |
This comment has been minimized.
This comment has been minimized.
|
Oops, I meant that comments like #33490 (comment) claimed that MIR now behaves correctly and that only old trans was still broken. |
sfackler commentedFeb 13, 2015
Adding anything after the match (like
;or()) causes the error to go away.cc @pnkfelix