rust-lang / rust

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

rustc panic #98170

Closed rickardnorlander closed 2 years ago

rickardnorlander commented 2 years ago

Code

pub struct MyStruct<'a> {
    field: &'a [u32],
}

impl MyStruct<'_> {
    pub fn new<'a>(field: &'a[u32]) -> MyStruct<'a> {
    Self{field}
    }
}

fn main() {
}

Meta

rustc 1.63.0-nightly (b31f9cc22 2022-06-15)
binary: rustc
commit-hash: b31f9cc22bcd720b37ddf927afe378108a5b9a54
commit-date: 2022-06-15
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

Compiling crash_repro v0.1.0 (/home/rickard/repro)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_borrowck/src/diagnostics/region_errors.rs:683:52
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0-nightly (b31f9cc22 2022-06-15) running on x86_64-unknown-linux-gnu

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:
#0 [mir_borrowck] borrow-checking `<impl at src/main.rs:5:1: 9:2>::new`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `crash_repro`
Backtrace

``` stack backtrace: 0: rust_begin_unwind at /rustc/b31f9cc22bcd720b37ddf927afe378108a5b9a54/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/b31f9cc22bcd720b37ddf927afe378108a5b9a54/library/core/src/panicking.rs:142:14 2: core::panicking::panic at /rustc/b31f9cc22bcd720b37ddf927afe378108a5b9a54/library/core/src/panicking.rs:48:5 3: ::report_general_error 4: rustc_borrowck::do_mir_borrowck 5: rustc_borrowck::mir_borrowck 6: >::call_once 7: >::with_task:: 8: rustc_query_system::query::plumbing::try_execute_query::> 9: ::mir_borrowck 10: ::par_body_owners:: 11: ::time::<(), rustc_interface::passes::analysis::{closure#2}> 12: rustc_interface::passes::analysis 13: >::with_task::> 14: rustc_query_system::query::plumbing::try_execute_query::>> 15: rustc_query_system::query::plumbing::get_query:: 16: ::enter::> 17: ::enter::, rustc_errors::ErrorGuaranteed>> 18: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 19: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>> ```

rickardnorlander commented 2 years ago

Changing Self{field} to MyStruct{field} makes it build btw.

jhpratt commented 2 years ago

I haven't done a search for the exact commit, but on the playground this regressed between beta and nightly.

@rustbot label +regression-from-stable-to-nightly

compiler-errors commented 2 years ago

This is due to the NLL stabilization PR #95565, since it manifests with #![feature(nll)] on 1.61 (with env BOOTSTRAP_RUSTC=1 to allow feature flags). I'll be looking at it in a few hours when I get home!