Skip to content

ICE with contract attr on struct #137129

Open
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#![core::contracts::ensures]
struct A {
    b: dyn A + 'static,
}
fn c() {}

Version information

rustc 1.87.0-nightly (4229b80f5 2025-02-16)
binary: rustc
commit-hash: 4229b80f506d5c1e6267f27e69f10fa3bd3c8f9e
commit-date: 2025-02-16
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

.collect();
let start_span = first_bound.span();
// `end_span` is the end of the poly trait ref (Foo + 'baz + Bar><)
let end_span = last_bound.span();
// `last_bound_span` is the last bound of the poly trait ref (Foo + >'baz< + Bar)
let last_bound_span = spans.last().cloned().unwrap();
let mut multi_span: MultiSpan = spans.clone().into();
for sp in spans {
let msg = if sp == last_bound_span {
format!(
"...because of {these} bound{s}",
these = pluralize!("this", bounds.len() - 1),

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

Program output

error[E0658]: use of unstable library feature `contracts`
 --> /tmp/icemaker_global_tempdir.HzHcBZ80mdGy/rustc_testrunner_tmpdir_reporting.BzR9c8BMmkyf/mvce.rs:1:4
  |
1 | #![core::contracts::ensures]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
  = help: add `#![feature(contracts)]` to the crate attributes to enable
  = note: this compiler was built on 2025-02-16; consider upgrading it if it is out of date

error[E0658]: inner macro attributes are unstable
 --> /tmp/icemaker_global_tempdir.HzHcBZ80mdGy/rustc_testrunner_tmpdir_reporting.BzR9c8BMmkyf/mvce.rs:1:4
  |
1 | #![core::contracts::ensures]
  |    ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
  = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
  = note: this compiler was built on 2025-02-16; consider upgrading it if it is out of date


thread 'rustc' panicked at compiler/rustc_resolve/src/late/diagnostics.rs:842:61:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x74059afdd620 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h57233a0da0a60088
   1:     0x74059b828a3c - core::fmt::write::h277933db078ea1bf
   2:     0x74059caf7251 - std::io::Write::write_fmt::h8430d504d6ff56fb
   3:     0x74059afdd482 - std::sys::backtrace::BacktraceLock::print::hecfd09ab0b155c84
   4:     0x74059afdf902 - std::panicking::default_hook::{{closure}}::h1f0ee2e7d1c1b508
   5:     0x74059afdf78a - std::panicking::default_hook::hd2d7676a9cd69c99
   6:     0x74059a13d699 - std[583eece78dd3d63f]::panicking::update_hook::<alloc[37f1d100dd86de67]::boxed::Box<rustc_driver_impl[1b4a71c91db98a50]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x74059afe0483 - std::panicking::rust_panic_with_hook::hc9095558f55c65d6
   8:     0x74059afe0146 - std::panicking::begin_panic_handler::{{closure}}::h85a86a0cd4afc144
   9:     0x74059afddaf9 - std::sys::backtrace::__rust_end_short_backtrace::ha253a85376825872
  10:     0x74059afdfe3d - rust_begin_unwind
  11:     0x740597c3e0e0 - core::panicking::panic_fmt::hb4f1c18d835e1f88
  12:     0x7405985c132c - core::panicking::panic::hd7b03e3332072d32
  13:     0x740598d04af9 - core::option::unwrap_failed::ha4f95c1c4a35468b
  14:     0x74059abe728f - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor>::smart_resolve_report_errors
  15:     0x7405986f4e44 - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor>::smart_resolve_path_fragment::{closure#0}
  16:     0x74059c4daf7c - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor>::smart_resolve_path_fragment
  17:     0x74059c4c341d - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor as rustc_ast[369685b33cae84d3]::visit::Visitor>::visit_poly_trait_ref
  18:     0x74059c4c2f77 - rustc_ast[369685b33cae84d3]::visit::walk_ty::<rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor>
  19:     0x74059c4d38e7 - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor as rustc_ast[369685b33cae84d3]::visit::Visitor>::visit_ty
  20:     0x74059c4e68d9 - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor as rustc_ast[369685b33cae84d3]::visit::Visitor>::visit_field_def
  21:     0x74059c4e98ab - rustc_ast[369685b33cae84d3]::visit::walk_item_ctxt::<rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor, rustc_ast[369685b33cae84d3]::ast::ItemKind>
  22:     0x74059c4f2c4c - <rustc_resolve[e71c47757d1f7101]::late::LateResolutionVisitor as rustc_ast[369685b33cae84d3]::visit::Visitor>::visit_item
  23:     0x74059c93d997 - <rustc_resolve[e71c47757d1f7101]::Resolver>::resolve_crate::{closure#0}
  24:     0x74059c9398ff - <rustc_resolve[e71c47757d1f7101]::Resolver>::resolve_crate
  25:     0x74059bd19c24 - rustc_interface[b605b7ae5b4b0e4]::passes::resolver_for_lowering_raw
  26:     0x74059bd18c67 - rustc_query_impl[176071ab12e9c6f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[176071ab12e9c6f]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d9ca97673980df99]::query::erase::Erased<[u8; 16usize]>>
  27:     0x74059bd18c55 - <rustc_query_impl[176071ab12e9c6f]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[b3e2a60bccbad4e1]::ops::function::FnOnce<(rustc_middle[d9ca97673980df99]::ty::context::TyCtxt, ())>>::call_once
  28:     0x74059c7904f6 - rustc_query_system[dea6796d91266fe8]::query::plumbing::try_execute_query::<rustc_query_impl[176071ab12e9c6f]::DynamicConfig<rustc_query_system[dea6796d91266fe8]::query::caches::SingleCache<rustc_middle[d9ca97673980df99]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[176071ab12e9c6f]::plumbing::QueryCtxt, false>
  29:     0x74059c7901a0 - rustc_query_impl[176071ab12e9c6f]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x74059c75b330 - rustc_interface[b605b7ae5b4b0e4]::passes::create_and_enter_global_ctxt::<core[b3e2a60bccbad4e1]::option::Option<rustc_interface[b605b7ae5b4b0e4]::queries::Linker>, rustc_driver_impl[1b4a71c91db98a50]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  31:     0x74059c739f29 - rustc_interface[b605b7ae5b4b0e4]::interface::run_compiler::<(), rustc_driver_impl[1b4a71c91db98a50]::run_compiler::{closure#0}>::{closure#1}
  32:     0x74059c68b944 - std[583eece78dd3d63f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b605b7ae5b4b0e4]::util::run_in_thread_with_globals<rustc_interface[b605b7ae5b4b0e4]::util::run_in_thread_pool_with_globals<rustc_interface[b605b7ae5b4b0e4]::interface::run_compiler<(), rustc_driver_impl[1b4a71c91db98a50]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x74059c68b619 - <<std[583eece78dd3d63f]::thread::Builder>::spawn_unchecked_<rustc_interface[b605b7ae5b4b0e4]::util::run_in_thread_with_globals<rustc_interface[b605b7ae5b4b0e4]::util::run_in_thread_pool_with_globals<rustc_interface[b605b7ae5b4b0e4]::interface::run_compiler<(), rustc_driver_impl[1b4a71c91db98a50]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b3e2a60bccbad4e1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x74059c68adaf - std::sys::pal::unix::thread::Thread::new::thread_start::hac4cd682f8f95252
  35:     0x7405968a339d - <unknown>
  36:     0x74059692849c - <unknown>
  37:                0x0 - <unknown>

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.87.0-nightly (4229b80f5 2025-02-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 2 previous errors

For more information about this error, try `rustc --explain E0658`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-contracts`#![feature(contracts)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions