-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
fn main() {
let a = vec![1];
let b = &a[0];
panic!(b);
}Generates the error:
err.rs:3:14: 3:15 error: `a` does not live long enough
err.rs:3 let b = &a[0];
^
note: reference must be valid for the static lifetime...
err.rs:2:20: 6:2 note: ...but borrowed value is only valid for the block suffix following statement 0 at 2:19
This is quite confusing. The problem really is that we are trying to pass something to panic! / rt::begin_unwind that isn't static, but the error message doesn't implicate panic! at all.
Meta
rustc 1.0.0-dev (c6ca2205e 2015-03-19) (built 2015-03-19)
binary: rustc
commit-hash: c6ca2205eae522387237057812b7901a2c5d3906
commit-date: 2015-03-19
build-date: 2015-03-19
host: x86_64-apple-darwin
release: 1.0.0-dev
Originally from Stack Overflow
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.