Skip to content

Support early const eval for inline const{} expressions #21080

@BergmannAtmet

Description

@BergmannAtmet

Related:
https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/const.20binding.20vs.2E.20const.7B.7D.20evaluation/near/558550788

Const eval is not guaranteed to be done at check time, especially with const{} expressions.

For example:

// check error
const X: NonZeroU32 = NonZeroU32::new(0).unwrap();
// check success, build error
let x: NonZeroU32 = const{NonZeroU32::new(0).unwrap()};

rust-analyzer catching such errors would be a great addition.


I hope this is not a duplicate, since it's not easy to search for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-featureCategory: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions