Skip to content

Panic within syntax extension triggers ICE #17507

Description

@aochagavia

This code ICEs when the function in the crate x, marked with #[plugin_registrar] panics:

/// Crate x
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
    panic!()
}

/// Another crate
#[phase(plugin)] extern crate x;

This code ICEs when the macro expansion fails

/// Crate x
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
    reg.register_macro("wrong", expand);
}

fn expand(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) -> Box<MacResult + 'static> {
    panic!()
}

/// Another crate
wrong!()

It would be nice to tell the user that the plugin registrar has panicked or that the macro expansion has panicked, respectively.

If there is a simple way to "catch" a panic! I would like to hear about it and fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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