Skip to content

error: internal compiler error: src/librustc_const_eval/pattern.rs:283: encountered errors lowering pattern #42285

Closed
@U007D

Description

@U007D

I was trying to do something admittedly a little weird. 1) match foo.into() { } where foo is Into<String>. 2) Declare a const empty string to avoid creating a local temporary to match against (defined in a different module): pub const EMPTY_STRING: String = String::new();.

The offending code:

pub struct HexByteString(String);

impl HexByteString {
    pub fn new<T: Into<String>>(init_value: T) -> Result<HexByteString> {
        match init_value.into() {
            consts::EMPTY_STRING => Err(Error::EmptyValue(msgs::ERR_EMPTY_VALUE.to_string())),
            s @ _ => Ok(HexByteString(s)),
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions