Skip to content

ICE: non-lifetime passed to :lifetime #50381

Closed

Description

@durka

This code crashes the compiler. However, the location of the error is pointed out, which is nice.

#![feature(macro_lifetime_matcher)]

macro_rules! m { ($x:lifetime) => { } }

m!(a);
error: internal compiler error: not a lifetime
 --> src/main.rs:5:8
  |
5 |     m!(a);
  |        ^

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:491:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error

cc #50380 @ricochet1k

Activity

  1. kennytm commented on May 2, 2018

    @kennytm
    Member

    cc #34303.

  2. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 2, 2018
  3. estebank commented on May 2, 2018

    @estebank
    Contributor

    The error occurs during parsing a lifetime unconditionally, which is used during macro parsing:

    "lifetime" => token::NtLifetime(p.expect_lifetime().ident),

    I would modify the code above to preemptively use check_lifetime(), and if false, emit an appropriate diagnostic error.


    Also, if this is your first contribution to rustc, https://forge.rust-lang.org/ contains quite a bit of information on how to set up your environment. If you need extra help, feel free to reach out to anyone in the team, here or in gitter.

  4. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-parserArea: The lexing & parsing of Rust source code to an AST
    on May 2, 2018
  5. rleungx commented on May 3, 2018

    @rleungx
    Contributor

    I'm interested in taking this issue.

  6. added a commit that references this issue on May 3, 2018
    bab812d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-parserArea: The lexing & parsing of Rust source code to an ASTE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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