Skip to content
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

Simple array of borrowing structs panics compiler #80371

Closed
kennethuil opened this issue Dec 26, 2020 · 3 comments · Fixed by #80404
Closed

Simple array of borrowing structs panics compiler #80371

kennethuil opened this issue Dec 26, 2020 · 3 comments · Fixed by #80404
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@kennethuil
Copy link

Code

pub struct Header<'a> {
    pub value: &'a [u8],
}

pub fn test() {
    let headers = [Header{value: &[]}; 128];
}

Meta

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-pc-windows-msvc
release: 1.48.0
LLVM version: 11.0

also seen in nightly:

rustc 1.50.0-nightly (0edce6f4b 2020-12-24)
binary: rustc
commit-hash: 0edce6f4bbb4514482537f569f0b8ef48e71e0a0
commit-date: 2020-12-24
host: x86_64-pc-windows-msvc
release: 1.50.0-nightly

Error output

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.48.0 (7eac88abb 2020-11-16) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --crate-type rlib --crate-type lib

query stack during panic:
#0 [mir_borrowck] borrow-checking `test`
#1 [analysis] running analysis passes on this crate
end of query stack
Backtrace

thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler\rustc_mir\src\transform\check_consts\qualifs.rs:248:9
stack backtrace:
   0:     0x7ff922a5a4a9 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hba5f685a77e920dc
   1:     0x7ff922a8748b - core::fmt::write::h7e2938de326daa9d
   2:     0x7ff922a4b998 - <std::io::IoSlice as core::fmt::Debug>::fmt::h6db1280adf9c872d
   3:     0x7ff922a5f8d4 - std::panicking::take_hook::hfb0d507d25fcd861
   4:     0x7ff922a5f4b8 - std::panicking::take_hook::hfb0d507d25fcd861
   5:     0x7ff9188faa45 - rustc_driver::report_ice::he237f3b59ed412a9
   6:     0x7ff922a60330 - std::panicking::rust_panic_with_hook::h67dee359ed61e799
   7:     0x7ff91bb286f4 - <rustc_mir::transform::MirSource as core::fmt::Debug>::fmt::hd5f962f5ee0af2ac
   8:     0x7ff91bb2858f - <rustc_mir::transform::MirSource as core::fmt::Debug>::fmt::hd5f962f5ee0af2ac
   9:     0x7ff91bb285ed - <rustc_mir::transform::MirSource as core::fmt::Debug>::fmt::hd5f962f5ee0af2ac
  10:     0x7ff91b82b49a - <rustc_mir::transform::check_consts::qualifs::CustomEq as rustc_mir::transform::check_consts::qualifs::Qualif>::in_adt_inherently::ha2a1515541536c41
  11:     0x7ff91b9ae5ce - rustc_mir::transform::promote_consts::collect_temps_and_candidates::h1bf2d5c6561d559e
  12:     0x7ff91b9af3fa - rustc_mir::transform::promote_consts::collect_temps_and_candidates::h1bf2d5c6561d559e
  13:     0x7ff91b9af3e2 - rustc_mir::transform::promote_consts::collect_temps_and_candidates::h1bf2d5c6561d559e
  14:     0x7ff91b9aeee7 - rustc_mir::transform::promote_consts::collect_temps_and_candidates::h1bf2d5c6561d559e
  15:     0x7ff91b9af075 - rustc_mir::transform::promote_consts::collect_temps_and_candidates::h1bf2d5c6561d559e
  16:     0x7ff91b9b4ed3 - rustc_mir::transform::promote_consts::promote_candidates::h98a0dd31ad25d6b2
  17:     0x7ff91b7b09bb - <rustc_mir::borrow_check::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body::h5ea3273fde4f4bc1
  18:     0x7ff91b7b47e5 - <rustc_mir::borrow_check::type_check::TypeVerifier as rustc_middle::mir::visit::Visitor>::visit_body::h5ea3273fde4f4bc1
  19:     0x7ff91b7a7456 - <rustc_mir::interpret::validity::PathElem as core::fmt::Debug>::fmt::h128e031426748928
  20:     0x7ff91ba0fd5a - <rustc_mir::borrow_check::invalidation::InvalidationGenerator as rustc_middle::mir::visit::Visitor>::visit_terminator::hfdaff8c21da2232f
  21:     0x7ff91bb848a7 - rustc_mir::borrow_check::provide::h7202fa8cdf50afb4
  22:     0x7ff91b6b56a4 - <rustc_mir_build::thir::pattern::_match::split_grouped_constructors::Border as core::fmt::Debug>::fmt::h9321f32f80e86e78
  23:     0x7ff91bb819c0 - rustc_mir::borrow_check::provide::h7202fa8cdf50afb4
  24:     0x7ff91bb513ff - <rustc_mir::util::storage::AlwaysLiveLocals as core::fmt::Debug>::fmt::h35f8a9f8cd51d351
  25:     0x7ff918b17f3e - rustc_interface::interface::parse_cfgspecs::h47201cf071ea3adb
  26:     0x7ff918ac4ad8 - <rls_span::OneIndexed as core::fmt::Debug>::fmt::hc2e3aeb3277dd105
  27:     0x7ff918b1845d - rustc_interface::interface::parse_cfgspecs::h47201cf071ea3adb
  28:     0x7ff918ab5e20 - <rls_span::OneIndexed as core::fmt::Debug>::fmt::hc2e3aeb3277dd105
  29:     0x7ff918ac18bf - <rls_span::OneIndexed as core::fmt::Debug>::fmt::hc2e3aeb3277dd105
  30:     0x7ff918afd454 - <rls_span::OneIndexed as core::fmt::Debug>::fmt::hc2e3aeb3277dd105
  31:     0x7ff918b39b9d - rustc_interface::passes::QueryContext::print_stats::h581fbf5f23b6b495
  32:     0x7ff918972c70 - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  33:     0x7ff918934eb7 - rustc_span::MultiSpan::primary_spans::h1017427bb4c1e209
  34:     0x7ff918945216 - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  35:     0x7ff9188da209 - <rustc_incremental::assert_dep_graph::GraphvizDepGraph as rustc_graphviz::GraphWalk>::source::ha7402f5059c5d3e9
  36:     0x7ff918972dfb - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  37:     0x7ff918941eaa - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  38:     0x7ff91891a6dc - rustc_span::MultiSpan::primary_spans::h1017427bb4c1e209
  39:     0x7ff91893d0b4 - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  40:     0x7ff918945d53 - <rustc_expand::mbe::macro_parser::MatcherPosHandle as core::ops::deref::DerefMut>::deref_mut::h5acc804ee7cddfed
  41:     0x7ff9188c8b53 - chalk_engine::TimeStamp::increment::h4493be1e979912d6
  42:     0x7ff922a70207 - std::sys::windows::thread::Thread::new::hb28370ce7bd0d890
  43:     0x7ff9af697034 - BaseThreadInitThunk
  44:     0x7ff9b159d0d1 - RtlUserThreadStart

@kennethuil kennethuil added C-bug Category: This is a bug. 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. labels Dec 26, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 26, 2020

This also panics on 1.50.0-nightly (bb1fbbf 2020-12-22) and if you change 'a to 'static.

@jyn514
Copy link
Member

jyn514 commented Dec 26, 2020

Relevant code:

// Check the qualifs of the value of `const` items.
if let ty::ConstKind::Unevaluated(def, _, promoted) = constant.literal.val {
assert!(promoted.is_none());

@kennethuil
Copy link
Author

Adding #[derive(Copy, Clone)] to Header makes it successfully compile

@jyn514 jyn514 added the A-borrow-checker Area: The borrow checker label Dec 26, 2020
fanninpm added a commit to fanninpm/glacier that referenced this issue Dec 29, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 31, 2020
@bors bors closed this as completed in 99f2f5a Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants