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: failed to reparse #139445

Closed
matthiaskrgr opened this issue Apr 6, 2025 · 2 comments
Closed

ICE: failed to reparse #139445

matthiaskrgr opened this issue Apr 6, 2025 · 2 comments
Assignees
Labels
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn main() {
    let mut c;

    assert_eq!(a::call2<'u, 'a, F>, 1234);
}

original:

struct Struct<S, T> {
    a: S,
    b: T,
}

fn main() {
    let (mut a, b);
    let mut c;
    let d = Struct { a: 0, b: 1 };
    Struct { a, b, c } = Struct { a: 0, b: 1 }; //~ ERROR does not have a field named `c`
    assert_eq!(a::call2<'u, 'a, F>, 1234); //~ ERROR pattern does not mention field `b`
    //~| ERROR expected identifier, found reserved identifier `_`
    Struct { a, ..z2 } = Struct { a: 1, b: 2 };
    //~^ ERROR functional record updates are not allowed in destructuring assignments
    Struct { a, .. }; //~ ERROR base expression required after `..`
}

Version information

rustc 1.88.0-nightly (1de931283 2025-04-06)
binary: rustc
commit-hash: 1de931283df18f3af4922fe9a96adcc8936ac42e
commit-date: 2025-04-06
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

self.bump();
// Recovery is disabled when parsing macro arguments, so it must
// also be disabled when reparsing pasted macro arguments,
// otherwise we get inconsistent results (e.g. #137874).
let res = self.with_recovery(Recovery::Forbidden, |this| {
f(this).expect("failed to reparse {mv_kind:?}")
});
if let token::CloseDelim(delim) = self.token.kind
&& let Delimiter::Invisible(InvisibleOrigin::MetaVar(mv_kind)) = delim
&& match_mv_kind(mv_kind)
{

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected `while`, `for`, `loop` or `{` after a label
 --> /tmp/icemaker_global_tempdir.JH8ZEyq8otjH/rustc_testrunner_tmpdir_reporting.h7pzT4t4mPph/mvce.rs:4:27
  |
4 |     assert_eq!(a::call2<'u, 'a, F>, 1234);
  |                           ^ expected `while`, `for`, `loop` or `{` after a label

error: expected `while`, `for`, `loop` or `{` after a label
 --> /tmp/icemaker_global_tempdir.JH8ZEyq8otjH/rustc_testrunner_tmpdir_reporting.h7pzT4t4mPph/mvce.rs:4:31
  |
4 |     assert_eq!(a::call2<'u, 'a, F>, 1234);
  |                               ^ expected `while`, `for`, `loop` or `{` after a label

error: expected `while`, `for`, `loop` or `{` after a label
 --> /tmp/icemaker_global_tempdir.JH8ZEyq8otjH/rustc_testrunner_tmpdir_reporting.h7pzT4t4mPph/mvce.rs:4:5
  |
4 |     assert_eq!(a::call2<'u, 'a, F>, 1234);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `while`, `for`, `loop` or `{` after a label
  |
  = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)


thread 'rustc' panicked at compiler/rustc_parse/src/parser/mod.rs:786:25:
failed to reparse {mv_kind:?}: Some(DiagInner { level: Error, messages: [(Str("expected expression, found ``"), NoStyle)], code: None, lint_id: None, span: MultiSpan { primary_spans: [/home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/macros/mod.rs:57:17: 57:22 (#4)], span_labels: [(/home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/macros/mod.rs:57:17: 57:22 (#4), Str("expected expression"))] }, children: [], suggestions: Enabled([]), args: {}, sort_span: /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/macros/mod.rs:57:17: 57:22 (#4), is_lint: None, long_ty_path: None, emitted_at: DiagLocation { file: "compiler/rustc_parse/src/parser/diagnostics.rs", line: 2393, col: 34 } })
stack backtrace:
   0:     0x77c727894703 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h17a82c1e4262b993
   1:     0x77c728006111 - core::fmt::write::ha356953bd35d22ed
   2:     0x77c7293ec191 - std::io::Write::write_fmt::h70957b67820ef10c
   3:     0x77c727894562 - std::sys::backtrace::BacktraceLock::print::h874892c1f8b64952
   4:     0x77c72789804a - std::panicking::default_hook::{{closure}}::ha45d88db4a7da1c9
   5:     0x77c727897bcf - std::panicking::default_hook::h455b2036d00abb9e
   6:     0x77c7268f2ac3 - std[ff77399157f2e3bd]::panicking::update_hook::<alloc[c0810c7e581b39d]::boxed::Box<rustc_driver_impl[c97d372510f3a631]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x77c7278988c3 - std::panicking::rust_panic_with_hook::hfa17a275c3ae0e04
   8:     0x77c7278985ba - std::panicking::begin_panic_handler::{{closure}}::h5d63d79094a75fde
   9:     0x77c727894bd9 - std::sys::backtrace::__rust_end_short_backtrace::h7983c26ddc3b68d2
  10:     0x77c72789827d - __rustc[1d1bf72e3c1d98cf]::rust_begin_unwind
  11:     0x77c724297800 - core::panicking::panic_fmt::h31dfe277ad6692b2
  12:     0x77c724478746 - core::result::unwrap_failed::h7eeb7fad7101bd4f
  13:     0x77c7288f5a7c - <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens_for_expr::<<rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
  14:     0x77c7288cf21f - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_prefix
  15:     0x77c7288c8a56 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens::<rustc_ast[20c80cea4dd33402]::ptr::P<rustc_ast[20c80cea4dd33402]::ast::Expr>, <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens_for_expr<<rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_prefix::{closure#7}>::{closure#0}>
  16:     0x77c7288cf2b0 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_prefix
  17:     0x77c7288cbad8 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_assoc_with
  18:     0x77c7288d6177 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens_for_expr::<<rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
  19:     0x77c7288cf21f - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_prefix
  20:     0x77c7288cbad8 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_assoc_with
  21:     0x77c7288e0af5 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens_for_expr::<<rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_dot_or_call::{closure#0}>
  22:     0x77c7288cf21f - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_prefix
  23:     0x77c7288cbad8 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_expr_assoc_with
  24:     0x77c7288ae34c - <rustc_parse[d98407f81c1c930e]::parser::Parser>::collect_tokens::<rustc_ast[20c80cea4dd33402]::ptr::P<rustc_ast[20c80cea4dd33402]::ast::Expr>, <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_stmt_without_recovery::{closure#6}>
  25:     0x77c7288af76f - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_stmt_without_recovery
  26:     0x77c728b3b722 - <rustc_parse[d98407f81c1c930e]::parser::Parser>::parse_full_stmt
  27:     0x77c728b382a8 - <rustc_expand[3764d10bfe44683]::mbe::macro_rules::ParserAnyMacro>::make
  28:     0x77c729384b32 - <rustc_expand[3764d10bfe44683]::expand::MacroExpander>::fully_expand_fragment
  29:     0x77c729373f4d - <rustc_expand[3764d10bfe44683]::expand::MacroExpander>::expand_crate
  30:     0x77c72880cb25 - rustc_interface[5e09446742ca674e]::passes::resolver_for_lowering_raw
  31:     0x77c72880bf21 - rustc_query_impl[c9170f90b2b49a1e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c9170f90b2b49a1e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5ef2b07f0bf9281b]::query::erase::Erased<[u8; 16usize]>>
  32:     0x77c72880bf0f - <rustc_query_impl[c9170f90b2b49a1e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[ad9c8bd38939abda]::ops::function::FnOnce<(rustc_middle[5ef2b07f0bf9281b]::ty::context::TyCtxt, ())>>::call_once
  33:     0x77c728ff5451 - rustc_query_system[dd895b260cdb9224]::query::plumbing::try_execute_query::<rustc_query_impl[c9170f90b2b49a1e]::DynamicConfig<rustc_query_system[dd895b260cdb9224]::query::caches::SingleCache<rustc_middle[5ef2b07f0bf9281b]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c9170f90b2b49a1e]::plumbing::QueryCtxt, false>
  34:     0x77c728ff4fc0 - rustc_query_impl[c9170f90b2b49a1e]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  35:     0x77c7291895f1 - rustc_interface[5e09446742ca674e]::passes::create_and_enter_global_ctxt::<core[ad9c8bd38939abda]::option::Option<rustc_interface[5e09446742ca674e]::queries::Linker>, rustc_driver_impl[c97d372510f3a631]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  36:     0x77c72917a239 - rustc_interface[5e09446742ca674e]::interface::run_compiler::<(), rustc_driver_impl[c97d372510f3a631]::run_compiler::{closure#0}>::{closure#1}
  37:     0x77c72913438f - std[ff77399157f2e3bd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5e09446742ca674e]::util::run_in_thread_with_globals<rustc_interface[5e09446742ca674e]::util::run_in_thread_pool_with_globals<rustc_interface[5e09446742ca674e]::interface::run_compiler<(), rustc_driver_impl[c97d372510f3a631]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x77c729134c6b - <<std[ff77399157f2e3bd]::thread::Builder>::spawn_unchecked_<rustc_interface[5e09446742ca674e]::util::run_in_thread_with_globals<rustc_interface[5e09446742ca674e]::util::run_in_thread_pool_with_globals<rustc_interface[5e09446742ca674e]::interface::run_compiler<(), rustc_driver_impl[c97d372510f3a631]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ad9c8bd38939abda]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x77c72913606b - std::sys::pal::unix::thread::Thread::new::thread_start::h0ea666365484af3d
  40:     0x77c722ea370a - <unknown>
  41:     0x77c722f27aac - <unknown>
  42:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (1de931283 2025-04-06) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 3 previous errors


@matthiaskrgr matthiaskrgr 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 Apr 6, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 6, 2025
@matthiaskrgr matthiaskrgr changed the title ICE: `failed to repase ICE: failed to repase Apr 6, 2025
@matthiaskrgr
Copy link
Member Author

mvce

fn main() {
    assert_eq!('u, 'a,)
}

comma at the end is load bearing for the ice

@matthiaskrgr
Copy link
Member Author

bisects to #139341 😆 cc @nnethercote

@saethlin saethlin changed the title ICE: failed to repase ICE: failed to reparse Apr 6, 2025
nnethercote added a commit to nnethercote/rust that referenced this issue Apr 6, 2025
This can happen when invalid syntax is passed to a declarative macro. We
shouldn't be too strict about the token stream position once the parser
has rejected the invalid syntax.

Fixes rust-lang#139248 and rust-lang#139445.
@nnethercote nnethercote self-assigned this Apr 6, 2025
nnethercote added a commit to nnethercote/rust that referenced this issue Apr 6, 2025
This can happen when invalid syntax is passed to a declarative macro. We
shouldn't be too strict about the token stream position once the parser
has rejected the invalid syntax.

Fixes rust-lang#139248 and rust-lang#139445.
nnethercote added a commit to nnethercote/rust that referenced this issue Apr 6, 2025
This can happen when invalid syntax is passed to a declarative macro. We
shouldn't be too strict about the token stream position once the parser
has rejected the invalid syntax.

Fixes rust-lang#139248 and rust-lang#139445.
nnethercote added a commit to nnethercote/rust that referenced this issue Apr 7, 2025
Fixes rust-lang#139445.

The additional errors aren't great but the first one is still good and
it's the most important, and imperfect errors are better than ICEing.
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 7, 2025
…5, r=<try>

Allow for reparsing failure when reparsing a pasted metavar.

Allow for reparsing failure when reparsing a pasted metavar.

Fixes rust-lang#139445.

The additional errors aren't great but the first one is still good and
it's the most important, and imperfect errors are better than ICEing.

r? `@petrochenkov`
@jieyouxu jieyouxu added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 7, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 8, 2025
…445, r=petrochenkov

Allow for reparsing failure when reparsing a pasted metavar.

Fix some metavar reparsing issues.

Fixes rust-lang#139248 and rust-lang#139445.

r? `@petrochenkov`
@bors bors closed this as completed in e177921 Apr 8, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 8, 2025
Rollup merge of rust-lang#139464 - nnethercote:fix-139248-AND-fix-139445, r=petrochenkov

Allow for reparsing failure when reparsing a pasted metavar.

Fix some metavar reparsing issues.

Fixes rust-lang#139248 and rust-lang#139445.

r? `@petrochenkov`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) ❄️ 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