Closed
Description
auto-reduced (treereduce-rust):
use Bar::foo;
trait Bar {
fn foo(&self) {}
}
fn main() {
let foo: Arc<dyn Foo> = propagate2(&j);
}
original code
original:
// Check that more complex receivers work:
// terminator of the MIR, which has had the PostAnalysisNormalize pass performed on it.
//@ error-pattern: Uninitialized value was created by an allocation
//@ revisions: cfi kcfi
//@ only-linux
//@ [cfi] needs-sanitizer-cfi
//@ [kcfi] needs-sanitizer-kcfi
//@ compile-flags: -C target-feature=-crt-static
//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi
//@ [cfi] compile-flags: -Z sanitizer=cfi
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
//@ run-pass
use Bar::foo;
trait Foo {
fn foo(self: Arc<Self>)(&self)
}
struct FooImpl;
impl Foo for C {
fn rpit_fn(self: Iter<Self>) {}
}
trait Bar {
fn foo(&self) {}
}
struct BarImpl;
impl Bar for BarImpl {
type T = i32;
fn bar(&self) -> Self::T { 7 }
}
fn main() {
let foo: Arc<dyn Foo> = propagate2(&j);
foo.as_ptr();
let bar: &dyn Yprintln!("p1")T=i32> = &BarImpl
assert_eq!(use_closure_once.bar(), 3);
}
Version information
rustc 1.86.0-nightly (bb3fa4b48 2025-01-17)
binary: rustc
commit-hash: bb3fa4b48eef8dc0815b0464e56f1fb82fe2cdfc
commit-date: 2025-01-17
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Possibly related line of code:
rust/compiler/rustc_resolve/src/late.rs
Lines 4015 to 4027 in bb3fa4b
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0658]: `use` associated items of traits is unstable
--> /tmp/icemaker_global_tempdir.Z7Hkc1ETV8nn/rustc_testrunner_tmpdir_reporting.2yoSVIHoUPEC/mvce.rs:1:5
|
1 | use Bar::foo;
| ^^^^^^^^
|
= note: see issue #134691 <https://github.com/rust-lang/rust/issues/134691> for more information
= help: add `#![feature(import_trait_associated_functions)]` to the crate attributes to enable
= note: this compiler was built on 2025-01-17; consider upgrading it if it is out of date
error: internal compiler error: compiler/rustc_resolve/src/late.rs:4021:18: unexpected resolution for an identifier in pattern: Def(AssocFn, DefId(0:5 ~ mvce[144b]::Bar::foo))
--> /tmp/icemaker_global_tempdir.Z7Hkc1ETV8nn/rustc_testrunner_tmpdir_reporting.2yoSVIHoUPEC/mvce.rs:8:9
|
8 | let foo: Arc<dyn Foo> = propagate2(&j);
| ^^^
thread 'rustc' panicked at compiler/rustc_resolve/src/late.rs:4021:18:
Box<dyn Any>
stack backtrace:
0: 0x7edbcc0f683a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h23c1af5b93b45c4e
1: 0x7edbcc812d66 - core::fmt::write::he6ce13e554e79ce6
2: 0x7edbcd795b91 - std::io::Write::write_fmt::hec6f02e202dc5849
3: 0x7edbcc0f6692 - std::sys::backtrace::BacktraceLock::print::hc275ab55e4e7012b
4: 0x7edbcc0f8b12 - std::panicking::default_hook::{{closure}}::ha505ca355cb30c7e
5: 0x7edbcc0f899a - std::panicking::default_hook::h19ac97dfcd221a6d
6: 0x7edbcb25a9fb - std[31774604a6320310]::panicking::update_hook::<alloc[371b401ffbdd17ea]::boxed::Box<rustc_driver_impl[6ffd8ce43d36b65a]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7edbcc0f9693 - std::panicking::rust_panic_with_hook::h5c0132368c99678a
8: 0x7edbcb296341 - std[31774604a6320310]::panicking::begin_panic::<rustc_errors[98a8ad297a61928c]::ExplicitBug>::{closure#0}
9: 0x7edbcb28b246 - std[31774604a6320310]::sys::backtrace::__rust_end_short_backtrace::<std[31774604a6320310]::panicking::begin_panic<rustc_errors[98a8ad297a61928c]::ExplicitBug>::{closure#0}, !>
10: 0x7edbcb287f7d - std[31774604a6320310]::panicking::begin_panic::<rustc_errors[98a8ad297a61928c]::ExplicitBug>
11: 0x7edbcb2a0271 - <rustc_errors[98a8ad297a61928c]::diagnostic::BugAbort as rustc_errors[98a8ad297a61928c]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7edbcb7f7c9c - <rustc_errors[98a8ad297a61928c]::DiagCtxtHandle>::span_bug::<rustc_span[2051e39db7245042]::span_encoding::Span, alloc[371b401ffbdd17ea]::string::String>
13: 0x7edbcb87d537 - rustc_middle[d6b3b4678fa8d253]::util::bug::opt_span_bug_fmt::<rustc_span[2051e39db7245042]::span_encoding::Span>::{closure#0}
14: 0x7edbcb862d5a - rustc_middle[d6b3b4678fa8d253]::ty::context::tls::with_opt::<rustc_middle[d6b3b4678fa8d253]::util::bug::opt_span_bug_fmt<rustc_span[2051e39db7245042]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x7edbcb862beb - rustc_middle[d6b3b4678fa8d253]::ty::context::tls::with_context_opt::<rustc_middle[d6b3b4678fa8d253]::ty::context::tls::with_opt<rustc_middle[d6b3b4678fa8d253]::util::bug::opt_span_bug_fmt<rustc_span[2051e39db7245042]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7edbca225da7 - rustc_middle[d6b3b4678fa8d253]::util::bug::span_bug_fmt::<rustc_span[2051e39db7245042]::span_encoding::Span>
17: 0x7edbcd49a91e - <rustc_ast[a21bb4063d307b10]::ast::Pat>::walk::<<rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor>::resolve_pattern_inner::{closure#0}>
18: 0x7edbcd49aceb - <rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor>::resolve_pattern_top
19: 0x7edbcd493282 - <rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor>::resolve_block
20: 0x7edbcd49c9ea - <rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor as rustc_ast[a21bb4063d307b10]::visit::Visitor>::visit_fn
21: 0x7edbcd4b42fd - rustc_ast[a21bb4063d307b10]::visit::walk_item_ctxt::<rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor, rustc_ast[a21bb4063d307b10]::ast::ItemKind>
22: 0x7edbcd4bd17b - <rustc_resolve[ef634132eb20349a]::late::LateResolutionVisitor as rustc_ast[a21bb4063d307b10]::visit::Visitor>::visit_item
23: 0x7edbcda2778a - <rustc_resolve[ef634132eb20349a]::Resolver>::resolve_crate::{closure#0}
24: 0x7edbcda2377f - <rustc_resolve[ef634132eb20349a]::Resolver>::resolve_crate
25: 0x7edbccdcd1d7 - rustc_interface[d0fa5b755e7f54c8]::passes::resolver_for_lowering_raw
26: 0x7edbccdcc227 - rustc_query_impl[61d446cd41769aac]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[61d446cd41769aac]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d6b3b4678fa8d253]::query::erase::Erased<[u8; 16usize]>>
27: 0x7edbccdcc215 - <rustc_query_impl[61d446cd41769aac]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[a9419c698344facd]::ops::function::FnOnce<(rustc_middle[d6b3b4678fa8d253]::ty::context::TyCtxt, ())>>::call_once
28: 0x7edbcd764cb6 - rustc_query_system[2ef7fec5ec5d5e8e]::query::plumbing::try_execute_query::<rustc_query_impl[61d446cd41769aac]::DynamicConfig<rustc_query_system[2ef7fec5ec5d5e8e]::query::caches::SingleCache<rustc_middle[d6b3b4678fa8d253]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[61d446cd41769aac]::plumbing::QueryCtxt, false>
29: 0x7edbcd764960 - rustc_query_impl[61d446cd41769aac]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
30: 0x7edbcd7c03b0 - rustc_interface[d0fa5b755e7f54c8]::passes::create_and_enter_global_ctxt::<core[a9419c698344facd]::option::Option<rustc_interface[d0fa5b755e7f54c8]::queries::Linker>, rustc_driver_impl[6ffd8ce43d36b65a]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
31: 0x7edbcd801456 - rustc_interface[d0fa5b755e7f54c8]::interface::run_compiler::<(), rustc_driver_impl[6ffd8ce43d36b65a]::run_compiler::{closure#0}>::{closure#1}
32: 0x7edbcd7325c7 - std[31774604a6320310]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d0fa5b755e7f54c8]::util::run_in_thread_with_globals<rustc_interface[d0fa5b755e7f54c8]::util::run_in_thread_pool_with_globals<rustc_interface[d0fa5b755e7f54c8]::interface::run_compiler<(), rustc_driver_impl[6ffd8ce43d36b65a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: 0x7edbcd732299 - <<std[31774604a6320310]::thread::Builder>::spawn_unchecked_<rustc_interface[d0fa5b755e7f54c8]::util::run_in_thread_with_globals<rustc_interface[d0fa5b755e7f54c8]::util::run_in_thread_pool_with_globals<rustc_interface[d0fa5b755e7f54c8]::interface::run_compiler<(), rustc_driver_impl[6ffd8ce43d36b65a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a9419c698344facd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: 0x7edbcd731a2f - std::sys::pal::unix::thread::Thread::new::thread_start::h1ff917b0bfabc673
35: 0x7edbc7aa339d - <unknown>
36: 0x7edbc7b2849c - <unknown>
37: 0x0 - <unknown>
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.86.0-nightly (bb3fa4b48 2025-01-17) 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`.