Skip to content

Regression: "temporary value does not live long enough" in a static item in Servo #54846

Open
@SimonSapin

Description

@SimonSapin

Reduced test case:

#![feature(const_fn)]
const fn require_static<T>(_: &'static T) {}
const fn foo() -> u32 { 0 }
pub static A: () = require_static(&foo());

rustc 1.31.0-nightly (5597ee8 2018-10-03): OK

rustc 1.31.0-nightly (8c4ad4e 2018-10-04):

error[E0597]: borrowed value does not live long enough
 --> a.rs:4:36
  |
4 | pub static A: () = require_static(&foo());
  |                                    ^^^^^- temporary value only lives until here
  |                                    |
  |                                    temporary value does not live long enough
  |
  = note: borrowed value must be valid for the static lifetime...

error: aborting due to previous error

Commit range: 5597ee8...8c4ad4e. #53851 seems relevant. @oli-obk, should we use #[rustc_promotable] in unstable code, despite the rustc_ prefix in its name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions