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

"0_DISCRIMINANT" is not a valid identifier #98158

Closed
JRAndreassen opened this issue Jun 16, 2022 · 5 comments
Closed

"0_DISCRIMINANT" is not a valid identifier #98158

JRAndreassen opened this issue Jun 16, 2022 · 5 comments
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

@JRAndreassen
Copy link

JRAndreassen commented Jun 16, 2022

Code

[package]
name = "enum_strum"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
strum_macros = "*"
strum = "*"
derive_more = "*"
#[allow(unused_imports)]
use strum_macros::{ EnumMessage, EnumIter, EnumString,  AsRefStr, IntoStaticStr, FromRepr};

#[allow(unused_imports)]
use strum::{ EnumCount, EnumMessage, EnumProperty, IntoEnumIterator, VariantNames, };

#[allow(unused_imports)]
use derive_more::{Add, Display as DisplayMore, TryInto, From, IsVariant, Deref, DerefMut, IntoIterator, AsRef};

#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, DisplayMore)]
#[derive(AsRefStr, IntoStaticStr, EnumString, EnumMessage, EnumIter, FromRepr)]
#[strum(ascii_case_insensitive)]
//#[serde_as]
//#[derive(SerializeDisplay, DeserializeFromStr)]
// #[derive(FromRepr)]
#[repr(i32)]
pub enum Tinyint { /* X Enum1: */
    #[strum(to_string = "0", serialize = "_0")]
    _0 = 0,
    #[strum(to_string = "1", serialize = "_1")]
    _1 = 1,

}

fn main() {
    println!("Hello, world!");
}

Meta

rustc --version --verbose:

rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-pc-windows-msvc
release: 1.61.0
LLVM version: 14.0.0

Error output

PS C:\Development\Rust\test\bug\enum_strum> cargo build
   Compiling enum_strum v0.1.0 (C:\Development\Rust\test\bug\enum_strum)
thread 'rustc' panicked at '`"0_DISCRIMINANT"` is not a valid identifier', compiler\rustc_expand\src\proc_macro_server.rs:332:13
stack backtrace:
   0:     0x7ff9d32a988f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h50aa8caf753a2b27
   1:     0x7ff9d32d4c3a - core::fmt::write::h838fc71521d9a769
   2:     0x7ff9d329c709 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h36f954dfa88567a7
   3:     0x7ff9d32aceab - std::panicking::default_hook::h14f77031689d5a65
   4:     0x7ff9d32aca9e - std::panicking::default_hook::h14f77031689d5a65
   5:     0x7ff98abe2ee6 - rustc_driver[644f353906beda0e]::pretty::print_after_hir_lowering
   6:     0x7ff9d32ad78a - std::panicking::rust_panic_with_hook::h093296cdc6b43259
   7:     0x7ff9d32ad4dd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h87de4eb99e2d660b
   8:     0x7ff9d32aa197 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h50aa8caf753a2b27
   9:     0x7ff9d32ad1b9 - rust_begin_unwind
  10:     0x7ff9d3312d15 - core::panicking::panic_fmt::h9a20e90cefbba781
  11:     0x7ff98eb31822 - <rustc_expand[c2b43a2c5b2d1cd5]::base::MacEager>::ty
  12:     0x7ff98ec0fdce - <proc_macro[3b1c66ee1f3fecb9]::bridge::TokenTree<rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Group, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Punct, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Ident, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Literal> as rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::ToInternal<rustc_ast[adca5a362ebeeebb]::tokenstream::TokenStream>>::to_internal
  13:     0x7ff98ec61771 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::macro_parser::NamedMatch as core[14ebc1417b592300]::fmt::Debug>::fmt
  14:     0x7ff98eb56321 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::metavar_expr::MetaVarExpr as core[14ebc1417b592300]::fmt::Debug>::fmt
  15:     0x7ff9dd5ca87c - proc_macro::bridge::closure::Closure::call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\closure.rs:27
  16:     0x7ff9dd5ca87c - proc_macro::bridge::client::impl$159::new::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:244
  17:     0x7ff9dd5ca87c - proc_macro::bridge::client::impl$9::with::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:335
  18:     0x7ff9dd5ca87c - proc_macro::bridge::client::impl$8::with::closure$0::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:293
  19:     0x7ff9dd5ca87c - proc_macro::bridge::scoped_cell::ScopedCell::replace
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\scoped_cell.rs:75
  20:     0x7ff9dd5ca87c - proc_macro::bridge::client::impl$8::with::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:291
  21:     0x7ff9dd5ca87c - std::thread::local::LocalKey::try_with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:442
  22:     0x7ff9dd5ca87c - std::thread::local::LocalKey::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:418
  23:     0x7ff9dd5ca87c - proc_macro::bridge::client::BridgeState::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:290
  24:     0x7ff9dd5ca87c - proc_macro::bridge::Bridge::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:328
  25:     0x7ff9dd5ca87c - proc_macro::bridge::client::Ident::new
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:237
  26:     0x7ff9dd5a2620 - enum$<proc_macro2::imp::Ident>::new
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.39\src\wrapper.rs:690
  27:     0x7ff9dd59abbc - proc_macro2::Ident::new
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.39\src\lib.rs:952
  28:     0x7ff9dd584d84 - quote::__private::mk_ident
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\quote-1.0.18\src\runtime.rs:404
  29:     0x7ff9dd46847e - strum_macros::macros::from_repr::from_repr_inner
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\strum_macros-0.24.1\src\macros\from_repr.rs:97
  30:     0x7ff9dd47c5fe - strum_macros::from_repr
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\strum_macros-0.24.1\src\lib.rs:468
  31:     0x7ff9dd4899ae - core::ops::function::FnOnce::call_once<proc_macro::TokenStream (*)(proc_macro::TokenStream),tuple$<proc_macro::TokenStream> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:227
  32:     0x7ff9dd4718f6 - proc_macro::bridge::client::impl$10::expand1::run::closure$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:409
  33:     0x7ff9dd470f42 - proc_macro::bridge::client::run_client::closure$0::closure$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStre
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:376
  34:     0x7ff9dd4bc158 - proc_macro::bridge::scoped_cell::impl$3::set::closure$0<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStre
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:80
  35:     0x7ff9dd4bc31c - proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >::replace<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::scoped_cell::impl$3::set::closure_env$0<enum$<proc_macro::bridge::client::B
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:75
  36:     0x7ff9dd4bc137 - proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >::set<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenS
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:80
  37:     0x7ff9dd47177f - proc_macro::bridge::client::impl$9::enter::closure$1<tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::ru
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:324
  38:     0x7ff9dd47dcf6 - std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> > >::try_with<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >,proc_macro::bridge::client
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:442
  39:     0x7ff9dd47d883 - std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> > >::with<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >,proc_macro::bridge::client::im
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:418
  40:     0x7ff9dd4a7e8e - proc_macro::bridge::Bridge::enter<tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<pr
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:324
  41:     0x7ff9dd470db2 - proc_macro::bridge::client::run_client::closure$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:369
  42:     0x7ff9dd4bccc1 - core::panic::unwind_safe::impl$23::call_once<tuple$<>,proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<pr
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\panic\unwind_safe.rs:271
  43:     0x7ff9dd48941b - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panicking.rs:492
  44:     0x7ff9dd48f873 - alloc::string::impl$11::extend::closure$0<core::str::iter::Chars>
  45:     0x7ff9dd48935b - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panicking.rs:456
  46:     0x7ff9dd489014 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::cl
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panic.rs:137
  47:     0x7ff9dd470c93 - proc_macro::bridge::client::run_client<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:368
  48:     0x7ff9dd4718ac - proc_macro::bridge::client::impl$10::expand1::run<proc_macro::TokenStream (*)(proc_macro::TokenStream)>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:409
  49:     0x7ff98ec5d7d7 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::macro_parser::NamedMatch as core[14ebc1417b592300]::fmt::Debug>::fmt
  50:     0x7ff98eb498a6 - <rustc_expand[c2b43a2c5b2d1cd5]::proc_macro::ProcMacroDerive as rustc_expand[c2b43a2c5b2d1cd5]::base::MultiItemModifier>::expand
  51:     0x7ff98eaf0414 - <rustc_expand[c2b43a2c5b2d1cd5]::expand::MacroExpander>::fully_expand_fragment
  52:     0x7ff98eaeedaf - <rustc_expand[c2b43a2c5b2d1cd5]::expand::MacroExpander>::expand_crate
  53:     0x7ff98accbc0b - <tracing_subscriber[7520e40ba33f8f7e]::util::TryInitError as core[14ebc1417b592300]::fmt::Display>::fmt
  54:     0x7ff98ad50e05 - <rustc_interface[897cdb8f2c10f1bf]::passes::LintStoreExpandImpl as rustc_expand[c2b43a2c5b2d1cd5]::base::LintStoreExpand>::pre_expansion_lint
  55:     0x7ff98acf2eb7 - <rustc_interface[897cdb8f2c10f1bf]::queries::Queries>::expansion
  56:     0x7ff98ac0c4d2 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  57:     0x7ff98ab987b0 - <rustc_driver[644f353906beda0e]::args::Error as core[14ebc1417b592300]::fmt::Debug>::fmt
  58:     0x7ff98ac2b390 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  59:     0x7ff98ab99ca7 - <rustc_driver[644f353906beda0e]::args::Error as core[14ebc1417b592300]::fmt::Debug>::fmt
  60:     0x7ff98ac08396 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  61:     0x7ff98aba4c68 - <chalk_engine[d6f38e9d841939be]::TableIndex>::increment
  62:     0x7ff9d32bcb4c - std::sys::windows::thread::Thread::new::h866e729703db88c5
  63:     0x7ffaa46d7034 - BaseThreadInitThunk
  64:     0x7ffaa5c42651 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.61.0 (fe5b13d68 2022-05-18) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
Backtrace

cargo build
   Compiling enum_strum v0.1.0 (C:\Development\Rust\test\bug\enum_strum)
thread 'rustc' panicked at '`"0_DISCRIMINANT"` is not a valid identifier', compiler\rustc_expand\src\proc_macro_server.rs:332:13
stack backtrace:
   0:     0x7ff9d32a988f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h50aa8caf753a2b27
   1:     0x7ff9d32d4c3a - core::fmt::write::h838fc71521d9a769
   2:     0x7ff9d329c709 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h36f954dfa88567a7
   3:     0x7ff9d32aceab - std::panicking::default_hook::h14f77031689d5a65
   4:     0x7ff9d32aca9e - std::panicking::default_hook::h14f77031689d5a65
   5:     0x7ff98d272ee6 - rustc_driver[644f353906beda0e]::pretty::print_after_hir_lowering
   6:     0x7ff9d32ad78a - std::panicking::rust_panic_with_hook::h093296cdc6b43259
   7:     0x7ff9d32ad4dd - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h87de4eb99e2d660b
   8:     0x7ff9d32aa197 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h50aa8caf753a2b27
   9:     0x7ff9d32ad1b9 - rust_begin_unwind
  10:     0x7ff9d3312d15 - core::panicking::panic_fmt::h9a20e90cefbba781
  11:     0x7ff9911c1822 - <rustc_expand[c2b43a2c5b2d1cd5]::base::MacEager>::ty
  12:     0x7ff99129fdce - <proc_macro[3b1c66ee1f3fecb9]::bridge::TokenTree<rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Group, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Punct, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Ident, rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::Literal> as rustc_expand[c2b43a2c5b2d1cd5]::proc_macro_server::ToInternal<rustc_ast[adca5a362ebeeebb]::tokenstream::TokenStream>>::to_internal
  13:     0x7ff9912f1771 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::macro_parser::NamedMatch as core[14ebc1417b592300]::fmt::Debug>::fmt
  14:     0x7ff9911e6321 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::metavar_expr::MetaVarExpr as core[14ebc1417b592300]::fmt::Debug>::fmt
  15:     0x7ff9dd38a87c - proc_macro::bridge::closure::Closure::call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\closure.rs:27
  16:     0x7ff9dd38a87c - proc_macro::bridge::client::impl$159::new::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:244
  17:     0x7ff9dd38a87c - proc_macro::bridge::client::impl$9::with::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:335
  18:     0x7ff9dd38a87c - proc_macro::bridge::client::impl$8::with::closure$0::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:293
  19:     0x7ff9dd38a87c - proc_macro::bridge::scoped_cell::ScopedCell::replace
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\scoped_cell.rs:75
  20:     0x7ff9dd38a87c - proc_macro::bridge::client::impl$8::with::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:291
  21:     0x7ff9dd38a87c - std::thread::local::LocalKey::try_with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:442
  22:     0x7ff9dd38a87c - std::thread::local::LocalKey::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:418
  23:     0x7ff9dd38a87c - proc_macro::bridge::client::BridgeState::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:290
  24:     0x7ff9dd38a87c - proc_macro::bridge::Bridge::with
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:328
  25:     0x7ff9dd38a87c - proc_macro::bridge::client::Ident::new
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\proc_macro\src\bridge\client.rs:237
  26:     0x7ff9dd362620 - enum$<proc_macro2::imp::Ident>::new
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.39\src\wrapper.rs:690
  27:     0x7ff9dd35abbc - proc_macro2::Ident::new
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-1.0.39\src\lib.rs:952
  28:     0x7ff9dd344d84 - quote::__private::mk_ident
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\quote-1.0.18\src\runtime.rs:404
  29:     0x7ff9dd22847e - strum_macros::macros::from_repr::from_repr_inner
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\strum_macros-0.24.1\src\macros\from_repr.rs:97
  30:     0x7ff9dd23c5fe - strum_macros::from_repr
                               at C:\Users\JR\.cargo\registry\src\github.com-1ecc6299db9ec823\strum_macros-0.24.1\src\lib.rs:468
  31:     0x7ff9dd2499ae - core::ops::function::FnOnce::call_once<proc_macro::TokenStream (*)(proc_macro::TokenStream),tuple$<proc_macro::TokenStream> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:227
  32:     0x7ff9dd2318f6 - proc_macro::bridge::client::impl$10::expand1::run::closure$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:409
  33:     0x7ff9dd230f42 - proc_macro::bridge::client::run_client::closure$0::closure$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStre
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:376
  34:     0x7ff9dd27c158 - proc_macro::bridge::scoped_cell::impl$3::set::closure$0<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStre
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:80
  35:     0x7ff9dd27c31c - proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >::replace<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::scoped_cell::impl$3::set::closure_env$0<enum$<proc_macro::bridge::client::B
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:75
  36:     0x7ff9dd27c137 - proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >::set<enum$<proc_macro::bridge::client::BridgeStateL>,tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenS
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\scoped_cell.rs:80
  37:     0x7ff9dd23177f - proc_macro::bridge::client::impl$9::enter::closure$1<tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::ru
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:324
  38:     0x7ff9dd23dcf6 - std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> > >::try_with<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >,proc_macro::bridge::client
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:442
  39:     0x7ff9dd23d883 - std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> > >::with<proc_macro::bridge::scoped_cell::ScopedCell<enum$<proc_macro::bridge::client::BridgeStateL> >,proc_macro::bridge::client::im
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:418
  40:     0x7ff9dd267e8e - proc_macro::bridge::Bridge::enter<tuple$<>,proc_macro::bridge::client::run_client::closure$0::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<pr
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:324
  41:     0x7ff9dd230db2 - proc_macro::bridge::client::run_client::closure$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:369
  42:     0x7ff9dd27ccc1 - core::panic::unwind_safe::impl$23::call_once<tuple$<>,proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<pr
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\panic\unwind_safe.rs:271
  43:     0x7ff9dd24941b - std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panicking.rs:492
  44:     0x7ff9dd24f873 - alloc::string::impl$11::extend::closure$0<core::str::iter::Chars>
  45:     0x7ff9dd24935b - std::panicking::try<tuple$<>,core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panicking.rs:456
  46:     0x7ff9dd249014 - std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<proc_macro::bridge::client::run_client::closure_env$0<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::cl
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\panic.rs:137
  47:     0x7ff9dd230c93 - proc_macro::bridge::client::run_client<proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::TokenStream,proc_macro::bridge::client::impl$10::expand1::run::closure_env$0<proc_macro::TokenStream (*)(proc_macro::TokenStream)> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:368
  48:     0x7ff9dd2318ac - proc_macro::bridge::client::impl$10::expand1::run<proc_macro::TokenStream (*)(proc_macro::TokenStream)>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\proc_macro\src\bridge\client.rs:409
  49:     0x7ff9912ed7d7 - <rustc_expand[c2b43a2c5b2d1cd5]::mbe::macro_parser::NamedMatch as core[14ebc1417b592300]::fmt::Debug>::fmt
  50:     0x7ff9911d98a6 - <rustc_expand[c2b43a2c5b2d1cd5]::proc_macro::ProcMacroDerive as rustc_expand[c2b43a2c5b2d1cd5]::base::MultiItemModifier>::expand
  51:     0x7ff991180414 - <rustc_expand[c2b43a2c5b2d1cd5]::expand::MacroExpander>::fully_expand_fragment
  52:     0x7ff99117edaf - <rustc_expand[c2b43a2c5b2d1cd5]::expand::MacroExpander>::expand_crate
  53:     0x7ff98d35bc0b - <tracing_subscriber[7520e40ba33f8f7e]::util::TryInitError as core[14ebc1417b592300]::fmt::Display>::fmt
  54:     0x7ff98d3e0e05 - <rustc_interface[897cdb8f2c10f1bf]::passes::LintStoreExpandImpl as rustc_expand[c2b43a2c5b2d1cd5]::base::LintStoreExpand>::pre_expansion_lint
  55:     0x7ff98d382eb7 - <rustc_interface[897cdb8f2c10f1bf]::queries::Queries>::expansion
  56:     0x7ff98d29c4d2 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  57:     0x7ff98d2287b0 - <rustc_driver[644f353906beda0e]::args::Error as core[14ebc1417b592300]::fmt::Debug>::fmt
  58:     0x7ff98d2bb390 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  59:     0x7ff98d229ca7 - <rustc_driver[644f353906beda0e]::args::Error as core[14ebc1417b592300]::fmt::Debug>::fmt
  60:     0x7ff98d298396 - <rustc_driver[644f353906beda0e]::Compilation as core[14ebc1417b592300]::fmt::Debug>::fmt
  61:     0x7ff98d234c68 - <chalk_engine[d6f38e9d841939be]::TableIndex>::increment
  62:     0x7ff9d32bcb4c - std::sys::windows::thread::Thread::new::h866e729703db88c5
  63:     0x7ffaa46d7034 - BaseThreadInitThunk
  64:     0x7ffaa5c42651 - RtlUserThreadStart

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.61.0 (fe5b13d68 2022-05-18) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack

@JRAndreassen JRAndreassen 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 Jun 16, 2022
@eggyal
Copy link
Contributor

eggyal commented Jun 16, 2022

Reduced example:

#[derive(strum_macros::FromRepr)]
pub enum Tinyint {
    _0,
}

These lines invoked by derive(strum_macros::FromRepr) construct an identifier from "_0_DISCRIMINANT".to_shouty_snake_case(). However, as documented, to_shouty_snake_case() drops the leading underscore resulting in an attempt to construct the invalid identifier 0_DISCRIMINANT. Simply trying to construct such an ident causes the ICE; for example, it can be witnessed from merely invoking the following proc macro:

use proc_macro::{Ident, Span, TokenStream};

#[proc_macro]
pub fn example(_: TokenStream) -> TokenStream {
    Ident::new("0_DISCRIMINANT", Span::call_site());
    TokenStream::new()
}                                                                                                   

Duplicate of #59998

@compiler-errors
Copy link
Member

This doesn't seem like a rustc bug, since 0_DISCRIMINANT is, in fact, an invalid ident. If it's not a bug, then could we close this one?

@eggyal
Copy link
Contributor

eggyal commented Jun 16, 2022

@compiler-errors: it still shouldn't ICE though; but I think that's a dupe of the issue mentioned above?

@MolotovCherry
Copy link

MolotovCherry commented Jun 29, 2022

Related / dupe issues #94913 #59998
Yeah, while it is indeed an invalid ident, it shouldn't be doing an ICE on it. The internal compiler code detects an invalid ident properly, but it doesn't handle what happens when there is one, it simply calls panic! instead of printing a message to the user and so on

Currently related line:

panic!("`{:?}` is not a valid identifier", string)

@JohnTitor
Copy link
Member

Triage: As mentioned above this is a duplicate of #59998 and fixed by #99944. The PR has a regression test so we can just close this issue as fixed. Thanks for reporting!

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

No branches or pull requests

5 participants