Skip to content

ICE: libcore/option.rs:323 #37778

Closed
Closed
@JinShil

Description

@JinShil

I'm very much a beginner with Rust. I was trying to learn how to write macros when I encountered an ICE. I don't know what caused the error, but here's the simple code to reproduce it. It occurred after I added the return statements to the macro.

macro_rules! get_ms_bit_index {
    ($a: ident, $b: ident) => {
        if $a > $b { return $a } else { return $b }
    }
}

pub mod bitfield {
    pub const BIT_INDEX_0:        u32 = 8;
    pub const BIT_INDEX_1:        u32 = 0;
    pub const WORD_MS_BIT_INDEX:  u32 = get_ms_bit_index!(BIT_INDEX_0, BIT_INDEX_1);
}

fn main() { }

playpen link: https://is.gd/6tcbBT

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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