-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
The below code compiles in 1.40.0 but not in 1.42.0 (stable). (minimized example from rust-phf)
pub enum Slice<T: 'static> {
Static(&'static [T]),
}
pub struct Map<K: 'static, V: 'static> {
pub entries: Slice<(K, V)>,
}
static CONTENT : & 'static [ u8 ] = b"a";
pub static CONTENT_MAP: Map<&'static str, &'static [u8]> = {
Map {
entries: Slice::Static(&[
("content", CONTENT),
]),
}
};
When built in 1.42.0, it produces the following error:
error[E0716]: temporary value dropped while borrowed
--> src/lib.rs:13:33
|
13 | entries: Slice::Static(&[
| ________________________________-^
| |________________________________|
| ||
14 | || ("content", CONTENT),
15 | || ]),
| || ^
| ||_________|
| |__________creates a temporary which is freed while still in use
| cast requires that borrow lasts for `'static`
16 | }
17 | };
| - temporary value is freed at the end of this statement
The same error occurs using nightly.
There's an issue from January mentioning this build error on the rust-phf repo (seems to occur in 1.41.0+), but no followup discussion/work that I could find. rust-phf/rust-phf#187
kornelski and msinojia
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.