Skip to content

ICE: in tokenstream with contracts in impl #140683

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

Open
matthiaskrgr opened this issue May 5, 2025 · 1 comment
Open

ICE: in tokenstream with contracts in impl #140683

matthiaskrgr opened this issue May 5, 2025 · 1 comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. F-contracts `#![feature(contracts)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

snippet:

impl T {
#[core::contracts::ensures]
  fn b() { (loop) }
}

Version information

rustc 1.88.0-nightly (243c5a35e 2025-05-05)
binary: rustc
commit-hash: 243c5a35e18b2634892fe7091d5ee888a18f77f5
commit-date: 2025-05-05
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4

Possibly related line of code:

if let Some(delim) = kind.open_delim() {
stack_rest.push(mem::replace(
&mut stack_top,
FrameData { open_delim_sp: Some((delim, span, spacing)), inner: vec![] },
));
} else if let Some(delim) = kind.close_delim() {
let frame_data = mem::replace(&mut stack_top, stack_rest.pop().unwrap());
let (open_delim, open_sp, open_spacing) = frame_data.open_delim_sp.unwrap();
assert!(
open_delim.eq_ignoring_invisible_origin(&delim),
"Mismatched open/close delims: open={open_delim:?} close={span:?}"
);
let dspan = DelimSpan::from_pair(open_sp, span);

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

Program output

error: expected `{`, found `)`
 --> /tmp/icemaker_global_tempdir.QK3qBTtK0qNE/rustc_testrunner_tmpdir_reporting.enN8ewTmyed4/mvce.rs:3:17
  |
3 |   fn b() { (loop) }
  |             ----^ expected `{`
  |             |
  |             while parsing this `loop` expression

error: non-item in item list
 --> /tmp/icemaker_global_tempdir.QK3qBTtK0qNE/rustc_testrunner_tmpdir_reporting.enN8ewTmyed4/mvce.rs:4:1
  |
1 | impl T {
  |        - item list starts here
...
4 | }
  | ^
  | |
  | non-item starts here
  | item list ends here

error[E0658]: use of unstable library feature `contracts`
 --> /tmp/icemaker_global_tempdir.QK3qBTtK0qNE/rustc_testrunner_tmpdir_reporting.enN8ewTmyed4/mvce.rs:2:3
  |
2 | #[core::contracts::ensures]
  |   ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
  = help: add `#![feature(contracts)]` to the crate attributes to enable
  = note: this compiler was built on 2025-05-05; consider upgrading it if it is out of date


thread 'rustc' panicked at compiler/rustc_ast/src/tokenstream.rs:376:84:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7561c0316a23 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h65551383c9634971
   1:     0x7561c0a059c7 - core::fmt::write::hd1d7d7de509062df
   2:     0x7561c1a3f891 - std::io::Write::write_fmt::h1a04e49834da160b
   3:     0x7561c0316882 - std::sys::backtrace::BacktraceLock::print::h793cee02245d5081
   4:     0x7561c031a6ca - std::panicking::default_hook::{{closure}}::h6ae00f240727be43
   5:     0x7561c031a24f - std::panicking::default_hook::h156478d29cf850ba
   6:     0x7561bf35bbc3 - std[cfdcd004f7c3d133]::panicking::update_hook::<alloc[88013fdaa6ac049f]::boxed::Box<rustc_driver_impl[a5b7631e7267f98a]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7561c031af43 - std::panicking::rust_panic_with_hook::h6ba9ecd60a752a68
   8:     0x7561c031ac06 - std::panicking::begin_panic_handler::{{closure}}::hed14983a4f5394ce
   9:     0x7561c0316ee9 - std::sys::backtrace::__rust_end_short_backtrace::h8d5f45e9eb074764
  10:     0x7561c031a8fd - __rustc[4726726be74f3c21]::rust_begin_unwind
  11:     0x7561bcc7d0a0 - core::panicking::panic_fmt::hecec6a54a644e96f
  12:     0x7561bcc811dc - core::panicking::panic::h76c2dcb84ba8059c
  13:     0x7561bcc7dad9 - core::option::unwrap_failed::hf1f8fd1804847760
  14:     0x7561c1580091 - <rustc_ast[ac699b453b946b68]::tokenstream::LazyAttrTokenStream>::to_attr_token_stream
  15:     0x7561c157a3f8 - rustc_ast[ac699b453b946b68]::tokenstream::attrs_and_tokens_to_token_trees
  16:     0x7561c149bfd6 - <rustc_expand[6b8c5499bcda7afa]::base::Annotatable>::to_tokens
  17:     0x7561c1dc08aa - <rustc_expand[6b8c5499bcda7afa]::expand::MacroExpander>::fully_expand_fragment
  18:     0x7561c1d67f37 - <rustc_expand[6b8c5499bcda7afa]::expand::MacroExpander>::expand_crate
  19:     0x7561c11cccf0 - rustc_interface[d28e3ca032370179]::passes::resolver_for_lowering_raw
  20:     0x7561c11cc08d - rustc_query_impl[a8d7657d34aae950]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a8d7657d34aae950]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3bd5ba83e8545365]::query::erase::Erased<[u8; 16usize]>>
  21:     0x7561c11cc079 - <rustc_query_impl[a8d7657d34aae950]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[f9132cdcabd89819]::ops::function::FnOnce<(rustc_middle[3bd5ba83e8545365]::ty::context::TyCtxt, ())>>::call_once
  22:     0x7561c1939bc7 - rustc_query_system[7470c717dfa77ba1]::query::plumbing::try_execute_query::<rustc_query_impl[a8d7657d34aae950]::DynamicConfig<rustc_query_system[7470c717dfa77ba1]::query::caches::SingleCache<rustc_middle[3bd5ba83e8545365]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[a8d7657d34aae950]::plumbing::QueryCtxt, false>
  23:     0x7561c193974f - rustc_query_impl[a8d7657d34aae950]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7561c1c462b1 - rustc_interface[d28e3ca032370179]::passes::create_and_enter_global_ctxt::<core[f9132cdcabd89819]::option::Option<rustc_interface[d28e3ca032370179]::queries::Linker>, rustc_driver_impl[a5b7631e7267f98a]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  25:     0x7561c1a7e6a6 - rustc_interface[d28e3ca032370179]::interface::run_compiler::<(), rustc_driver_impl[a5b7631e7267f98a]::run_compiler::{closure#0}>::{closure#1}
  26:     0x7561c1a39dfe - std[cfdcd004f7c3d133]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d28e3ca032370179]::util::run_in_thread_with_globals<rustc_interface[d28e3ca032370179]::util::run_in_thread_pool_with_globals<rustc_interface[d28e3ca032370179]::interface::run_compiler<(), rustc_driver_impl[a5b7631e7267f98a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  27:     0x7561c1a3a274 - <<std[cfdcd004f7c3d133]::thread::Builder>::spawn_unchecked_<rustc_interface[d28e3ca032370179]::util::run_in_thread_with_globals<rustc_interface[d28e3ca032370179]::util::run_in_thread_pool_with_globals<rustc_interface[d28e3ca032370179]::interface::run_compiler<(), rustc_driver_impl[a5b7631e7267f98a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f9132cdcabd89819]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:     0x7561c1a3b66b - std::sys::pal::unix::thread::Thread::new::thread_start::h7658bcd938bdd684
  29:     0x7561bb8a370a - <unknown>
  30:     0x7561bb927aac - <unknown>
  31:                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 (243c5a35e 2025-05-05) 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

For more information about this error, try `rustc --explain E0658`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels May 5, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 5, 2025
@matthiaskrgr matthiaskrgr added F-contracts `#![feature(contracts)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 5, 2025
@moxian
Copy link
Contributor

moxian commented May 6, 2025

@rustbot label: +S-has-mcve +S-has-bisection +A-parser -needs-triage

@rustbot rustbot added A-parser Area: The lexing & parsing of Rust source code to an AST S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The lexing & parsing of Rust source code to an AST C-bug Category: This is a bug. F-contracts `#![feature(contracts)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-bisection Status: a bisection has been found for this issue S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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

3 participants