rust-lang / rust

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

ICE: no type for node #101623

Closed yshui closed 2 years ago

yshui commented 2 years ago

Code

I tried this code:

pub struct Stuff {
    inner: *mut (),
}

pub struct Wrap<T>(T);

fn fun<T>(t: T) -> Wrap<T> {
    todo!()
}

pub trait Trait<'de> {
    fn do_stuff(_: Wrap<&'de mut Self>);
}

impl<'a> Trait<'a> for () {
    fn do_stuff(_: Wrap<&'a mut Self>) {}
}

 fn fun2(t: &mut Stuff) -> () {
     let Stuff { inner, .. } = t;
     Trait::do_stuff({ fun(&mut *inner) });
 }

Version

searched nightlies: from nightly-2022-08-18 to nightly-2022-09-09 regressed nightly: nightly-2022-08-23 searched commit range: https://github.com/rust-lang/rust/compare/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01...015a824f2dffe32707fceb59c47effaf7b73486c regressed commit: https://github.com/rust-lang/rust/commit/0b71ffca18a9f4a9515773b2c23d13f501d1e08f

bisected with cargo-bisect-rustc v0.6.4 Host triple: x86_64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc ice ```

Backtrace

Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/compiler/rustc_errors/src/lib.rs:1460:9 stack backtrace: 0: 0x7f9f39479eb0 - std::backtrace_rs::backtrace::libunwind::trace::hd4d72bf9fe10967c at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 1: 0x7f9f39479eb0 - std::backtrace_rs::backtrace::trace_unsynchronized::h6503f59b8cbe2ed6 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f9f39479eb0 - std::sys_common::backtrace::_print_fmt::h589945bf8bc39343 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/sys_common/backtrace.rs:66:5 3: 0x7f9f39479eb0 - ::fmt::h2f4d863594a68c91 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/sys_common/backtrace.rs:45:22 4: 0x7f9f394d4efe - core::fmt::write::h9fd78932fc37b51c at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/core/src/fmt/mod.rs:1202:17 5: 0x7f9f3946a595 - std::io::Write::write_fmt::h6066f9f8807a65d2 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/io/mod.rs:1679:15 6: 0x7f9f3947cb63 - std::sys_common::backtrace::_print::h355143466bed5429 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/sys_common/backtrace.rs:48:5 7: 0x7f9f3947cb63 - std::sys_common::backtrace::print::hb82c149c248573a7 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/sys_common/backtrace.rs:35:9 8: 0x7f9f3947cb63 - std::panicking::default_hook::{{closure}}::h9412e92c58f99121 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/panicking.rs:295:22 9: 0x7f9f3947c84f - std::panicking::default_hook::h1a8b46d36ee22d51 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/panicking.rs:314:9 10: 0x7f9f3bce0101 - rustc_driver[8f3cca79f91367d]::DEFAULT_HOOK::{closure#0}::{closure#0} 11: 0x7f9f3947d39d - std::panicking::rust_panic_with_hook::he6adbff8aae13c88 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/panicking.rs:702:17 12: 0x7f9f3cc91e11 - std[dce46a4773fb9772]::panicking::begin_panic::::{closure#0} 13: 0x7f9f3cc91436 - std[dce46a4773fb9772]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 14: 0x7f9f3cc913d6 - std[dce46a4773fb9772]::panicking::begin_panic:: 15: 0x7f9f3cc913c6 - std[dce46a4773fb9772]::panic::panic_any:: 16: 0x7f9f3cc8f0ad - ::bug::<&alloc[c797b21ee8d71470]::string::String> 17: 0x7f9f3cc8ebb0 - ::bug::<&alloc[c797b21ee8d71470]::string::String> 18: 0x7f9f3cd6aa4d - rustc_middle[a60e78b424f055fe]::ty::context::tls::with_context_opt::::{closure#0}, ()>::{closure#0}, ()> 19: 0x7f9f3cd6bea6 - rustc_middle[a60e78b424f055fe]::util::bug::opt_span_bug_fmt:: 20: 0x7f9f3a6623a3 - rustc_middle[a60e78b424f055fe]::util::bug::bug_fmt 21: 0x7f9f3abf965d - ::expr_ty_adjusted 22: 0x7f9f3cafd584 - ::note_obligation_cause_code:: 23: 0x7f9f3cb0ca7f - ::note_obligation_cause 24: 0x7f9f3cb03e58 - ::report_selection_error 25: 0x7f9f3cb103fa - ::report_fulfillment_error 26: 0x7f9f3cb026e3 - ::report_fulfillment_errors 27: 0x7f9f3a8db782 - ::check_argument_types 28: 0x7f9f3a87dd12 - ::check_call 29: 0x7f9f3a83f3d3 - ::check_expr_with_expectation_and_args 30: 0x7f9f3a878cd6 - ::check_block_with_expected 31: 0x7f9f3a83f4fc - ::check_expr_with_expectation_and_args 32: 0x7f9f3a8d7994 - ::check_argument_types 33: 0x7f9f3a87dd12 - ::check_call 34: 0x7f9f3a83f3d3 - ::check_expr_with_expectation_and_args 35: 0x7f9f3a878b1c - ::check_block_with_expected 36: 0x7f9f3a83f4fc - ::check_expr_with_expectation_and_args 37: 0x7f9f3aa36ee6 - ::check_return_expr 38: 0x7f9f3aa3475e - rustc_typeck[73db7158453d7c81]::check::check::check_fn 39: 0x7f9f3aa25e9e - ::enter::::{closure#1}, &rustc_middle[a60e78b424f055fe]::ty::context::TypeckResults> 40: 0x7f9f3aa23f8f - rustc_typeck[73db7158453d7c81]::check::typeck 41: 0x7f9f3b597f8d - >::with_task:: 42: 0x7f9f3b590824 - rustc_query_system[2fad7ab5aded87ba]::query::plumbing::try_execute_query::> 43: 0x7f9f3bc1aff3 - ::typeck 44: 0x7f9f3ba6ace7 - rustc_data_structures[22f783ec505e1d99]::sync::par_for_each_in::<&[rustc_span[5934fe088b167bef]::def_id::LocalDefId], ::par_body_owners::{closure#0}> 45: 0x7f9f3ba6aaa3 - rustc_typeck[73db7158453d7c81]::check::typeck_item_bodies 46: 0x7f9f3b96f255 - >::with_task:: 47: 0x7f9f3b96e23e - rustc_query_system[2fad7ab5aded87ba]::query::plumbing::try_execute_query::> 48: 0x7f9f3b96dc4c - rustc_query_system[2fad7ab5aded87ba]::query::plumbing::get_query:: 49: 0x7f9f3b03311f - ::time::<(), rustc_typeck[73db7158453d7c81]::check_crate::{closure#7}> 50: 0x7f9f3b032cdf - rustc_typeck[73db7158453d7c81]::check_crate 51: 0x7f9f3b0322a7 - rustc_interface[a2838c864f6eb7ab]::passes::analysis 52: 0x7f9f3baba4c2 - >::with_task::> 53: 0x7f9f3bab9b8a - rustc_query_system[2fad7ab5aded87ba]::query::plumbing::try_execute_query::>> 54: 0x7f9f3bab9659 - rustc_query_system[2fad7ab5aded87ba]::query::plumbing::get_query:: 55: 0x7f9f3aabb1b7 - ::enter::> 56: 0x7f9f3aaaebec - rustc_interface[a2838c864f6eb7ab]::interface::create_compiler_and_run::, rustc_driver[8f3cca79f91367d]::run_compiler::{closure#1}> 57: 0x7f9f3aaad531 - >::set::, rustc_driver[8f3cca79f91367d]::run_compiler::{closure#1}>::{closure#0}, core[3035f67f4d4c8105]::result::Result<(), rustc_errors[724a1349d7209c57]::ErrorGuaranteed>> 58: 0x7f9f3aaad21f - std[dce46a4773fb9772]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[8f3cca79f91367d]::run_compiler::{closure#1}>::{closure#0}, core[3035f67f4d4c8105]::result::Result<(), rustc_errors[724a1349d7209c57]::ErrorGuaranteed>>::{closure#0}, core[3035f67f4d4c8105]::result::Result<(), rustc_errors[724a1349d7209c57]::ErrorGuaranteed>> 59: 0x7f9f3bb4a610 - <::spawn_unchecked_, rustc_driver[8f3cca79f91367d]::run_compiler::{closure#1}>::{closure#0}, core[3035f67f4d4c8105]::result::Result<(), rustc_errors[724a1349d7209c57]::ErrorGuaranteed>>::{closure#0}, core[3035f67f4d4c8105]::result::Result<(), rustc_errors[724a1349d7209c57]::ErrorGuaranteed>>::{closure#1} as core[3035f67f4d4c8105]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 60: 0x7f9f39487173 - as core::ops::function::FnOnce>::call_once::h2546ce459201572e at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/alloc/src/boxed.rs:1940:9 61: 0x7f9f39487173 - as core::ops::function::FnOnce>::call_once::ha02ec324858dc3c8 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/alloc/src/boxed.rs:1940:9 62: 0x7f9f39487173 - std::sys::unix::thread::Thread::new::thread_start::h9bd74d28238bdb06 at /rustc/1120c5e01df508de64fe6642f22fadeb574afd6d/library/std/src/sys/unix/thread.rs:108:17 63: 0x7f9f391d36a3 - 64: 0x7f9f3925952c - 65: 0x0 - ```

yshui commented 2 years ago

Regression introduced in: https://github.com/rust-lang/rust/pull/100654

yshui commented 2 years ago

This block around fun(&mut *inner) is crucial to trigger the ICE.

apiraino commented 2 years ago

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium