Skip to content

Inconsistent macro repeat operator leads to panic on nightly #61033

New issue

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

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

Already on GitHub? # to your account

Closed
birkenfeld opened this issue May 22, 2019 · 6 comments · Fixed by #61046
Closed

Inconsistent macro repeat operator leads to panic on nightly #61033

birkenfeld opened this issue May 22, 2019 · 6 comments · Fixed by #61046
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@birkenfeld
Copy link
Contributor

Given this test file:

macro_rules! test {
    ($x:ident, $($tt:tt)*) => { $($tt)+ }
}

fn main() {
    test!(x,)
}

stable Rust errors like this:

error: this must repeat at least once
 --> x.rs:2:34
  |
2 |     ($x:ident, $($tt:tt)*) => { $($tt)+ }
  |                                  ^^^^^

error: aborting due to previous error

while on 1.36.0-nightly (50a0def 2019-05-21) running on x86_64-unknown-linux-gnu:

error: internal compiler error: this must repeat at least once
 --> x.rs:2:34
  |
2 |     ($x:ident, $($tt:tt)*) => { $($tt)+ }
  |                                  ^^^^^

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:572:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
@oli-obk oli-obk added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 22, 2019
@oli-obk
Copy link
Contributor

oli-obk commented May 22, 2019

caused by #60620 cc @mark-i-m

@petrochenkov
Copy link
Contributor

Yay, we have a test case.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2019
@mark-i-m
Copy link
Member

Hmm... interesting... yeah, I guess we have a test case. I will open a PR to revert #60620 and add the test case. Thanks @birkenfeld !

But this raises a bigger point that has been growing on me for a while now: there are a ton of checks that are currently only done at macro invocation time (or are not done at all) that really would make more sense to do a macro definition time.

So far, I have been holding off on attempting to fix these because they could involve building a whole language, and it seems that at some point we want to just use macro macros... @petrochenkov @oli-obk Thoughts?

@mark-i-m
Copy link
Member

Opened #61046

@petrochenkov
Copy link
Contributor

there are a ton of checks that are currently only done at macro invocation time (or are not done at all) that really would make more sense to do a macro definition time.

If the defined macro produces an error with any possible input, then we should probably report it at definition time, at least as a quality of implementation measure (perhaps as a warning for a start).

I have more confidence in reporting errors related to the macro definition language itself (meta-variables, repetitions, etc.), than in errors for produced tokens (which are not necessarily supposed to be Rust code, with eager expansion they may be consumed by another macro, for example).

@mark-i-m
Copy link
Member

@petrochenkov Ok, makes sense. I will open another issue with these items so we can track them.

Centril added a commit to Centril/rust that referenced this issue May 23, 2019
# for free to join this conversation on GitHub. Already have an account? # 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, ..) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants