rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.95k stars 12.53k forks source link

ICE: `parser_range.start >= start_pos && parser_range.end >= start_pos` #129166

Closed matthiaskrgr closed 1 week ago

matthiaskrgr commented 1 month ago

auto-reduced (treereduce-rust):

fn main() {
    let _ = #[cfg_eval]
    #[cfg( = , , )]
    0;
}

original:

#![feature(cfg_eval)]
#![feature(stmt_expr_attributes)]

fn main() {
    let _ = #[cfg_eval] #[cfg(name = "...", cfg(FALSE), cfg(FALSE))] 0;
    //~^ ERROR removing an expression is not supported in this position
}

Version information

rustc 1.82.0-nightly (a73bc4a13 2024-08-16)
binary: rustc
commit-hash: a73bc4a131d94eba633c4c572a28e0bf94a67530
commit-date: 2024-08-16
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

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

Program output

``` error[E0658]: attributes on expressions are experimental --> /tmp/icemaker_global_tempdir.P8GwvQiqbOKy/rustc_testrunner_tmpdir_reporting.kwFlrMqR8nnW/mvce.rs:2:13 | 2 | let _ = #[cfg_eval] | ^^^^^^^^^^^ | = note: see issue #15701 for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on 2024-08-16; consider upgrading it if it is out of date error: expected unsuffixed literal, found `=` --> /tmp/icemaker_global_tempdir.P8GwvQiqbOKy/rustc_testrunner_tmpdir_reporting.kwFlrMqR8nnW/mvce.rs:3:12 | 3 | #[cfg( = , , )] | ^ error[E0658]: use of unstable library feature 'cfg_eval': `cfg_eval` is a recently implemented feature --> /tmp/icemaker_global_tempdir.P8GwvQiqbOKy/rustc_testrunner_tmpdir_reporting.kwFlrMqR8nnW/mvce.rs:2:15 | 2 | let _ = #[cfg_eval] | ^^^^^^^^ | = note: see issue #82679 for more information = help: add `#![feature(cfg_eval)]` to the crate attributes to enable = note: this compiler was built on 2024-08-16; consider upgrading it if it is out of date thread 'rustc' panicked at compiler/rustc_parse/src/parser/mod.rs:241:9: assertion failed: parser_range.start >= start_pos && parser_range.end >= start_pos stack backtrace: 0: 0x766de83ac32d - ::fmt::hbb42d93700eab6e5 1: 0x766de8a05297 - core::fmt::write::hede989e4e7d14b6d 2: 0x766de998cd51 - std::io::Write::write_fmt::h7a42f27b08b157f5 3: 0x766de83aea0b - std::panicking::default_hook::{{closure}}::hc8a48bf7f87d4f00 4: 0x766de83ae67e - std::panicking::default_hook::h722ce6f9c5e65f69 5: 0x766de7543fb9 - std[5f115fdff94c2120]::panicking::update_hook::>::{closure#0} 6: 0x766de83af327 - std::panicking::rust_panic_with_hook::h6b96b15aea6f391f 7: 0x766de83aefb3 - std::panicking::begin_panic_handler::{{closure}}::h78f98703de9c52d7 8: 0x766de83ac7e9 - std::sys::backtrace::__rust_end_short_backtrace::he797a316ee99c3ac 9: 0x766de83aecb4 - rust_begin_unwind 10: 0x766de55e1c93 - core::panicking::panic_fmt::hfd35dc75e555f48a 11: 0x766de54a457c - core::panicking::panic::hec3c35fa0f838a8a 12: 0x766de8f8e90e - ::parse_expr_force_collect 13: 0x766de73631b6 - <::configure_annotatable::{closure#5} as core[83194bb5562a103a]::ops::function::FnOnce<(&mut rustc_parse[5e692a80545cfc79]::parser::Parser,)>>::call_once 14: 0x766de9927604 - rustc_builtin_macros[cd55725283bcdb35]::cfg_eval::cfg_eval 15: 0x766de73570a5 - ::expand 16: 0x766de50c17e8 - ::fully_expand_fragment 17: 0x766de9b7f05f - ::expand_crate 18: 0x766de8f70e55 - rustc_interface[aec65d594c25cb1a]::passes::resolver_for_lowering_raw 19: 0x766de8f703db - rustc_query_impl[4f1661ee14cf0c15]::plumbing::__rust_begin_short_backtrace::> 20: 0x766de8f703c9 - >::call_once 21: 0x766de9963dd2 - rustc_query_system[df9560578d31cea0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[4f1661ee14cf0c15]::plumbing::QueryCtxt, false> 22: 0x766de9963a6d - rustc_query_impl[4f1661ee14cf0c15]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace 23: 0x766de97d7e5e - rustc_interface[aec65d594c25cb1a]::interface::run_compiler::, rustc_driver_impl[818abaa6828b5c02]::run_compiler::{closure#0}>::{closure#1} 24: 0x766de987a804 - std[5f115fdff94c2120]::sys::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[818abaa6828b5c02]::run_compiler::{closure#0}>::{closure#1}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>>::{closure#0}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>> 25: 0x766de987ae70 - <::spawn_unchecked_, rustc_driver_impl[818abaa6828b5c02]::run_compiler::{closure#0}>::{closure#1}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>>::{closure#0}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[83194bb5562a103a]::result::Result<(), rustc_span[3220205ed180bad]::ErrorGuaranteed>>::{closure#1} as core[83194bb5562a103a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 26: 0x766de987b1eb - std::sys::pal::unix::thread::Thread::new::thread_start::h48acfbfeb014780f 27: 0x766deafdc39d - 28: 0x766deb06149c - 29: 0x0 - 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.82.0-nightly (a73bc4a13 2024-08-16) 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`. ```

@rustbot label +F-cfg_eval +F-stmt_expr_attributes

matthiaskrgr commented 1 month ago
fn main() {
    #[cfg_eval]#[cfg]0
}
matthiaskrgr commented 1 month ago

128725 cc @nnethercote