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 "token_lit in from_mac_args: InvalidIntSuffix" #104620

Closed
jruderman opened this issue Nov 19, 2022 · 6 comments · Fixed by #104751
Closed

ICE "token_lit in from_mac_args: InvalidIntSuffix" #104620

jruderman opened this issue Nov 19, 2022 · 6 comments · Fixed by #104751
Assignees
Labels
C-bug Category: This is a bug. 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

@jruderman
Copy link
Contributor

Code

#[a=5z]

Error output

thread 'rustc' panicked at 'token_lit in from_mac_args: InvalidIntSuffix', compiler/rustc_ast/src/attr/mod.rs:622:63
Backtrace

stack backtrace:
   0:        0x10cf22c52 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h65371da71ea634a1
   1:        0x10cf816aa - core::fmt::write::h42d20afb3c5ee095
   2:        0x10cf14f0c - std::io::Write::write_fmt::h8d5b26d0e53ddd7f
   3:        0x10cf22a1a - std::sys_common::backtrace::print::hb5fe5178795d9f17
   4:        0x10cf25d46 - std::panicking::default_hook::{{closure}}::hff2fd60e97cc3869
   5:        0x10cf25a97 - std::panicking::default_hook::hc3f9a1de84e0ed9d
   6:        0x119c7aaed - rustc_driver[13343b5551cdacdb]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10cf2652d - std::panicking::rust_panic_with_hook::h1c5a191a8000993f
   8:        0x10cf262d3 - std::panicking::begin_panic_handler::{{closure}}::hd5b348ff58d0d76f
   9:        0x10cf230e8 - std::sys_common::backtrace::__rust_end_short_backtrace::h724f40d3ad4af19e
  10:        0x10cf25f9d - _rust_begin_unwind
  11:        0x10cfae443 - core::panicking::panic_fmt::hc08710230bc1c166
  12:        0x10cfae705 - core::result::unwrap_failed::h55bd37e311048987
  13:        0x11e807492 - <rustc_ast[2d6df22e047a2d72]::ast::MetaItemKind>::from_mac_args
  14:        0x11e806617 - <rustc_ast[2d6df22e047a2d72]::ast::Attribute>::meta_kind
  15:        0x11dea254f - <rustc_parse[384f70a722f87e00]::parser::Parser>::parse_item_common
  16:        0x11dea00b7 - <rustc_parse[384f70a722f87e00]::parser::Parser>::parse_mod
  17:        0x11df25dba - rustc_parse[384f70a722f87e00]::parse_crate_from_file
  18:        0x119cfbf75 - <rustc_session[d3dc83f7882946da]::session::Session>::time::<core[5f16df7105d54e]::result::Result<rustc_ast[2d6df22e047a2d72]::ast::Crate, rustc_errors[56d5964ce0535c75]::diagnostic_builder::DiagnosticBuilder<rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>, rustc_interface[bc80ce5eea40f24e]::passes::parse::{closure#0}>
  19:        0x119d327b0 - rustc_interface[bc80ce5eea40f24e]::passes::parse
  20:        0x119d152ee - <rustc_interface[bc80ce5eea40f24e]::queries::Queries>::parse
  21:        0x119c50c15 - rustc_span[3cd6c9c9c366901b]::with_source_map::<core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>, rustc_interface[bc80ce5eea40f24e]::interface::run_compiler<core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>, rustc_driver[13343b5551cdacdb]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  22:        0x119c4822c - <scoped_tls[9f05bfe7696cff9b]::ScopedKey<rustc_span[3cd6c9c9c366901b]::SessionGlobals>>::set::<rustc_interface[bc80ce5eea40f24e]::interface::run_compiler<core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>, rustc_driver[13343b5551cdacdb]::run_compiler::{closure#1}>::{closure#0}, core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>
  23:        0x119c1019a - std[b8dd7466c60cfdf8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bc80ce5eea40f24e]::util::run_in_thread_pool_with_globals<rustc_interface[bc80ce5eea40f24e]::interface::run_compiler<core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>, rustc_driver[13343b5551cdacdb]::run_compiler::{closure#1}>::{closure#0}, core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>
  24:        0x119bf296b - <<std[b8dd7466c60cfdf8]::thread::Builder>::spawn_unchecked_<rustc_interface[bc80ce5eea40f24e]::util::run_in_thread_pool_with_globals<rustc_interface[bc80ce5eea40f24e]::interface::run_compiler<core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>, rustc_driver[13343b5551cdacdb]::run_compiler::{closure#1}>::{closure#0}, core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5f16df7105d54e]::result::Result<(), rustc_errors[56d5964ce0535c75]::ErrorGuaranteed>>::{closure#1} as core[5f16df7105d54e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:        0x10cf2f8e7 - std::sys::unix::thread::Thread::new::thread_start::h459496ec4dc9999f
  26:     0x7ff80d84d4e1 - __pthread_start

Regression

Regression in nightly-2022-11-18 from bebd57a (#102944)

Version

rustc 1.67.0-nightly (b833ad56f 2022-11-18)
binary: rustc
commit-hash: b833ad56f46a0bbe0e8729512812a161e7dae28a
commit-date: 2022-11-18
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@jruderman jruderman added C-bug Category: This is a bug. 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. labels Nov 19, 2022
@matthiaskrgr
Copy link
Member

This makes me wonder if we could just create a superset of a set of chars and feed these into rustc, hmm.

@chenyukang
Copy link
Member

This makes me wonder if we could just create a superset of a set of chars and feed these into rustc, hmm.

Can we just report_lit_error here?

@compiler-errors
Copy link
Member

cc @nnethercote

@nnethercote nnethercote self-assigned this Nov 22, 2022
@nnethercote
Copy link
Contributor

I'll take a look, thanks for the heads up.

@nnethercote
Copy link
Contributor

nnethercote commented Nov 22, 2022

@petrochenkov: I changed the test input to the following, to avoid an "expected item after attributes" error:

#![a=5z]
fn main() {}

With rust 1.64.0 I get these errors:

error: invalid suffix `z` for number literal
 --> j.rs:1:6
  |
1 | #![a=5z]
  |      ^^ invalid suffix `z`
  |
  = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)

error: cannot find attribute `a` in this scope
 --> j.rs:1:4
  |
1 | #![a=5z]
  |    ^

If I change from_mac_args to return None if Lit::from_token_lit fails, then I get these errors:

error: unexpected expression: `5z`
 --> j.rs:1:6
  |
1 | #![a=5z]
  |      ^^

error: cannot find attribute `a` in this scope
 --> j.rs:1:4
  |
1 | #![a=5z]
  | 

Do you think that is reasonable behaviour?

@petrochenkov
Copy link
Contributor

Both seem fine, I'd do whatever is simpler to implement.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Nov 23, 2022
…nkov

Fix an ICE parsing a malformed attribute.

Fixes rust-lang#104620.

r? `@petrochenkov`
@bors bors closed this as completed in 7c3f631 Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. 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

Successfully merging a pull request may close this issue.

6 participants