Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: non-lifetime passed to :lifetime #50381

Closed
durka opened this issue May 2, 2018 · 3 comments
Closed

ICE: non-lifetime passed to :lifetime #50381

durka opened this issue May 2, 2018 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@durka
Copy link
Contributor

durka commented May 2, 2018

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

@kennytm
Copy link
Member

kennytm commented May 2, 2018

cc #34303.

@kennytm kennytm added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 2, 2018
@estebank
Copy link
Contributor

estebank commented May 2, 2018

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.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST. labels May 2, 2018
@rleungx
Copy link
Contributor

rleungx commented May 3, 2018

I'm interested in taking this issue.

kennytm added a commit to kennytm/rust that referenced this issue May 3, 2018
check if the token is a lifetime before parsing

Fixes rust-lang#50381.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-parser Area: The parsing of Rust source code to an AST. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants