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: macro expansion using expr fragment as identifier #65122

Closed
RustyYato opened this issue Oct 5, 2019 · 2 comments · Fixed by #65123
Closed

ICE: macro expansion using expr fragment as identifier #65122

RustyYato opened this issue Oct 5, 2019 · 2 comments · Fixed by #65123
Assignees
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. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RustyYato
Copy link
Contributor

Regression from stable to nightly

macro_rules! mac {
    ($eval:expr) => {
        let mut $eval = ();
    };
}

fn foo() {
    mac! { does_not_exist!() }
}

backtrace

thread 'rustc' panicked at 'visit_mac disabled by default', src/libsyntax/mut_visit.rs:210:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.51.al-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.51.al-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  12: std::panicking::begin_panic
  13: syntax::mut_visit::MutVisitor::visit_mac
  14: syntax::mut_visit::noop_visit_expr
  15: syntax::parse::parser::pat::<impl syntax::parse::parser::Parser>::parse_pat_with_range_pat
  16: syntax::parse::parser::pat::<impl syntax::parse::parser::Parser>::parse_pat_with_or
  17: syntax::parse::parser::pat::<impl syntax::parse::parser::Parser>::parse_top_pat
  18: syntax::parse::parser::stmt::<impl syntax::parse::parser::Parser>::parse_stmt_without_recovery
  19: syntax::parse::parser::stmt::<impl syntax::parse::parser::Parser>::parse_full_stmt
  20: syntax::ext::expand::<impl syntax::parse::parser::Parser>::parse_ast_fragment
  21: syntax::ext::mbe::macro_rules::ParserAnyMacro::make
  22: syntax::ext::expand::<impl syntax::ext::base::MacResult for syntax::ext::mbe::macro_rules::ParserAnyMacro>::make_stmts
  23: syntax::ext::expand::AstFragmentKind::make_from
  24: syntax::ext::expand::MacroExpander::fully_expand_fragment
  25: syntax::ext::expand::MacroExpander::expand_crate
  26: rustc_interface::passes::configure_and_expand_inner::{{closure}}
  27: rustc::util::common::time
  28: rustc_interface::passes::configure_and_expand_inner
  29: rustc_interface::passes::configure_and_expand::{{closure}}
  30: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  31: rustc_interface::queries::Query<T>::compute
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::expansion
  33: rustc_interface::interface::run_compiler_in_existing_thread_pool
  34: std::thread::local::LocalKey<T>::with
  35: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0-nightly (2daa404e9 2019-10-02) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden
@Centril Centril added regression-from-stable-to-beta Performance or correctness regression from stable to beta. A-parser Area: The parsing of Rust source code to an AST. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 5, 2019
@Centril Centril self-assigned this Oct 5, 2019
@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated A-diagnostics Area: Messages for errors, warnings, and lints labels Oct 5, 2019
@Centril
Copy link
Contributor

Centril commented Oct 5, 2019

Fixed in #65122.

@RustyYato
Copy link
Contributor Author

@Centril I think you mean #65123

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Oct 5, 2019
tmandry added a commit to tmandry/rust that referenced this issue Oct 5, 2019
…ebank

Account for macro invocation in `let mut $pat` diagnostic.

Fixes rust-lang#65122.

r? @estebank
@bors bors closed this as completed in f5c8e12 Oct 6, 2019
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. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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.

3 participants