Skip to content

items.static.const conflicts with actual behavior in stable Rust #1724

Closed as not planned
@obi1kenobi

Description

@obi1kenobi

items.static.const says:

Constants cannot refer to statics.

Yet the following works fine: playground

pub const A: i64 = 0;

pub static B: i64 = A + 1;

pub const C: i64 = B + 1;

This may have changed as a result of recent changes related to Rust-for-Linux such as the stabilization of const_refs_to_static: rust-lang/rust#119618

Depending on what the new rule is, there may also be a SemVer hazard here. For example, if the new rule is "consts may only refer to statics without interior mutability" then newly adding interior mutability to a pub static would appear to be a major breaking change. If so, we should consider updating the cargo SemVer reference as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions