-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regression - temporary value dropped while borrowed with static slice (as used by rust-phf) #70584
Comments
Notes:
|
Minimized: pub struct Slice<T: 'static>(&'static [T]);
static CONTENT: &'static [u8] = b"";
pub static CONTENT_MAP: Slice<&'static [u8]> = {
Slice(&[
CONTENT,
])
};
|
This happens on both 1.41.0 and 1.41.1, so it's not fallout from #69145 (which fixed #69114 in that release). There's no entry in the release notes or blog post for 1.41.0 that indicates that this is expected fallout. cc @matthewjasper anyways re: borrowck |
This issue was briefly discussed in our pre triage meeting. Tagging as |
So... the bug is fairly simple, albeit not easy to fix. The problem is that any use of a static anywhere like let x = STATIC; becomes const STATIC_REF: &'static Type = &STATIC;
let tmp = STATIC_REF;
let x = *tmp; This has various positive effects on rustc, making many implementation things easier, but it also means that it broke promoting reading from statics within other statics, because we will never ever support promoting |
The below code compiles in 1.40.0 but not in 1.42.0 (stable). (minimized example from rust-phf)
When built in 1.42.0, it produces the following error:
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
The text was updated successfully, but these errors were encountered: