rust-lang / rust

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

ICE "expect tcx.sess.has_errors return true" #104768

Closed jruderman closed 1 year ago

jruderman commented 1 year ago

Code

const A: &_ = 0_u32;

fn main() {}

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/visit.rs:103:17: expect tcx.sess.has_errors return true

Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/ff8c8dfbe66701531e3e5e335c28c544d0fbc945/compiler/rustc_errors/src/lib.rs:1560:9 stack backtrace: 0: 0x100b83152 - ::fmt::he02b81ee9fd93999 1: 0x100be1bba - core::fmt::write::h2defc6780b01b98f 2: 0x100b7551c - std::io::Write::write_fmt::hd14cefb8f7ff162a 3: 0x100b82f1a - std::sys_common::backtrace::print::hd794f53e9106805e 4: 0x100b86246 - std::panicking::default_hook::{{closure}}::h3f1a7d2a7e113922 5: 0x100b85f97 - std::panicking::default_hook::hc2ab762c436ea8e6 6: 0x10b61877d - rustc_driver[2fa5ced89a36b2bb]::DEFAULT_HOOK::{closure#0}::{closure#0} 7: 0x100b86a2d - std::panicking::rust_panic_with_hook::h6737e44fee662a10 8: 0x10fd09377 - std[a7bcc37ac91ea507]::panicking::begin_panic::::{closure#0} 9: 0x10fd02329 - std[a7bcc37ac91ea507]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 10: 0x1103fc5d9 - std[a7bcc37ac91ea507]::panicking::begin_panic:: 11: 0x10fd02319 - std[a7bcc37ac91ea507]::panic::panic_any:: 12: 0x10fcfa16d - ::bug::<&alloc[9e1d3100bc63c017]::string::String> 13: 0x10fcf9c37 - ::bug::<&alloc[9e1d3100bc63c017]::string::String> 14: 0x10fe41472 - rustc_middle[11e81625f7bbe50a]::ty::context::tls::with_context_opt::::{closure#0}, ()>::{closure#0}, ()> 15: 0x10fe425d1 - rustc_middle[11e81625f7bbe50a]::util::bug::opt_span_bug_fmt:: 16: 0x1103fdc5e - rustc_middle[11e81625f7bbe50a]::util::bug::bug_fmt 17: 0x10def65eb - ::enter::::{closure#0}::{closure#1}, &rustc_middle[11e81625f7bbe50a]::ty::context::TypeckResults> 18: 0x10de94d74 - rustc_hir_typeck[27eda5868db5c1c1]::diagnostic_only_typeck 19: 0x10ee05ff9 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::try_execute_query::> 20: 0x10eef62bc - rustc_query_system[5966864cd92ca7b0]::query::plumbing::get_query:: 21: 0x10e04aeb3 - rustc_hir_analysis[b49d33eca061cccf]::collect::type_of::infer_placeholder_type 22: 0x10e048d25 - rustc_hir_analysis[b49d33eca061cccf]::collect::type_of::type_of 23: 0x10ee27b35 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::try_execute_query::> 24: 0x10eefdee4 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::get_query:: 25: 0x10e0670b7 - rustc_hir_analysis[b49d33eca061cccf]::collect::convert_item 26: 0x10e05f1cc - ::visit_item 27: 0x10e02aec9 - ::visit_item_likes_in_module:: 28: 0x10e05e805 - rustc_hir_analysis[b49d33eca061cccf]::collect::collect_mod_item_types 29: 0x10ee0a895 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::try_execute_query::> 30: 0x10eef6025 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::get_query:: 31: 0x10e02c4e8 - ::track_errors:: 32: 0x10dfdcab8 - rustc_hir_analysis[b49d33eca061cccf]::check_crate 33: 0x10b6d479a - rustc_interface[ebeaf7db7192038f]::passes::analysis 34: 0x10ee83e8c - rustc_query_system[5966864cd92ca7b0]::query::plumbing::try_execute_query::>> 35: 0x10eefdff9 - rustc_query_system[5966864cd92ca7b0]::query::plumbing::get_query:: 36: 0x10b5dd612 - ::enter::> 37: 0x10b5ef4cd - rustc_span[8424830d8e8bf797]::with_source_map::, rustc_interface[ebeaf7db7192038f]::interface::run_compiler, rustc_driver[2fa5ced89a36b2bb]::run_compiler::{closure#1}>::{closure#0}::{closure#1}> 38: 0x10b5e5e8c - >::set::, rustc_driver[2fa5ced89a36b2bb]::run_compiler::{closure#1}>::{closure#0}, core[3d042c94762723bc]::result::Result<(), rustc_errors[a3b0880de9357bbd]::ErrorGuaranteed>> 39: 0x10b5aea3a - std[a7bcc37ac91ea507]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[2fa5ced89a36b2bb]::run_compiler::{closure#1}>::{closure#0}, core[3d042c94762723bc]::result::Result<(), rustc_errors[a3b0880de9357bbd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3d042c94762723bc]::result::Result<(), rustc_errors[a3b0880de9357bbd]::ErrorGuaranteed>> 40: 0x10b590ecb - <::spawn_unchecked_, rustc_driver[2fa5ced89a36b2bb]::run_compiler::{closure#1}>::{closure#0}, core[3d042c94762723bc]::result::Result<(), rustc_errors[a3b0880de9357bbd]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3d042c94762723bc]::result::Result<(), rustc_errors[a3b0880de9357bbd]::ErrorGuaranteed>>::{closure#1} as core[3d042c94762723bc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 41: 0x100b8fde7 - std::sys::unix::thread::Thread::new::thread_start::hc3ae91907c3ce551 42: 0x7ff816f934e1 - __pthread_start 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.67.0-nightly (ff8c8dfbe 2022-11-22) running on x86_64-apple-darwin query stack during panic: #0 [diagnostic_only_typeck] type-checking `A` #1 [type_of] computing type of `A` #2 [collect_mod_item_types] collecting item types in top-level module #3 [analysis] running analysis passes on this crate end of query stack error: aborting due to previous error ```

Regression

Regression in nightly-2022-11-20, from something in rollup 2f8d8040166a730d0da7bba0f2864f0ef7ff6364

Version

rustc 1.67.0-nightly (ff8c8dfbe 2022-11-22)
binary: rustc
commit-hash: ff8c8dfbe66701531e3e5e335c28c544d0fbc945
commit-date: 2022-11-22
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
matthiaskrgr commented 1 year ago

duplicate of https://github.com/rust-lang/rust/issues/104237

jruderman commented 1 year ago

Same message as #104237, but this is a more recent regression and happens in rustc (not just rustdoc), so it might be a separate bug