Skip to content

ICE: lower-impl-trait-in-trait-to-assoc-ty item_name: no name for DefPath #113438

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

rustc -Zlower-impl-trait-in-trait-to-assoc-ty file.rs

#![feature(min_specialization)]

struct MyStruct;

trait MyTrait<T> {
    async fn foo(_: T) -> &'static str;
}

impl<T> MyTrait<T> for MyStruct {}

impl MyTrait<i32> for MyStruct {
    async fn foo(_: i32) -> &'static str {}
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (921f66974 2023-07-07)
binary: rustc
commit-hash: 921f669749a57ab5936721fdd93b2da57b581381
commit-date: 2023-07-07
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> treereduce.out:6:5
  |
6 |     async fn foo(_: T) -> &'static str;
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0670]: `async fn` is not permitted in Rust 2015
  --> treereduce.out:12:5
   |
12 |     async fn foo(_: i32) -> &'static str {}
   |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
   |
   = help: pass `--edition 2021` to `rustc`
   = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0706]: functions in traits cannot be declared `async`
 --> treereduce.out:6:5
  |
6 |     async fn foo(_: T) -> &'static str;
  |     -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |     |
  |     `async` because of this
  |
  = note: `async` trait functions are not currently supported
  = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable

error[E0706]: functions in traits cannot be declared `async`
  --> treereduce.out:12:5
   |
12 |     async fn foo(_: i32) -> &'static str {}
   |     -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     `async` because of this
   |
   = note: `async` trait functions are not currently supported
   = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `treereduce`
  --> treereduce.out:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `treereduce.out`

error[E0046]: not all trait items implemented, missing: `foo`
 --> treereduce.out:9:1
  |
6 |     async fn foo(_: T) -> &'static str;
  |     ----------------------------------- `foo` from trait
...
9 | impl<T> MyTrait<T> for MyStruct {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation

error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default`
  --> treereduce.out:12:5
   |
9  | impl<T> MyTrait<T> for MyStruct {}
   | ------------------------------- parent `impl` is here
...
12 |     async fn foo(_: i32) -> &'static str {}
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `foo`
   |
   = note: to specialize, `foo` in the parent `impl` must be marked `default`
Backtrace


error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:2319:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: Impl, disambiguator: 1 }, DisambiguatedDefPathData { data: ImplTraitAssocTy, disambiguator: 0 }], krate: crate0 }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/921f669749a57ab5936721fdd93b2da57b581381/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0:     0x7f297f163a71 - std::backtrace_rs::backtrace::libunwind::trace::hb05aa6cc8cc12798
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f297f163a71 - std::backtrace_rs::backtrace::trace_unsynchronized::h4eb176a26cc1ba04
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f297f163a71 - std::sys_common::backtrace::_print_fmt::h1f61568d68579c4a
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f297f163a71 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h57dacdd98f67e152
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f297f1c9d7f - core::fmt::rt::Argument::fmt::hc9125659956a317d
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/core/src/fmt/rt.rs:138:9
   5:     0x7f297f1c9d7f - core::fmt::write::hacfaa5fb24457741
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f297f1564b7 - std::io::Write::write_fmt::hbd177ac610ea9ddb
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/io/mod.rs:1714:15
   7:     0x7f297f163885 - std::sys_common::backtrace::_print::h794d92bec131f33b
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f297f163885 - std::sys_common::backtrace::print::h00747b9c9d53fb7c
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f297f166663 - std::panicking::default_hook::{{closure}}::h974e1e40cc31ef37
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/panicking.rs:269:22
  10:     0x7f297f1663f4 - std::panicking::default_hook::h83eab9cf6bc2c1d4
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/panicking.rs:288:9
  11:     0x7f2982451f3b - rustc_driver_impl[7b385e897129221a]::install_ice_hook::{closure#0}
  12:     0x7f297f166e8e - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h27c942e87a09f23b
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/alloc/src/boxed.rs:2007:9
  13:     0x7f297f166e8e - std::panicking::rust_panic_with_hook::hd06db9c2c751c186
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/panicking.rs:709:13
  14:     0x7f2982a040a1 - std[158e0661572bfb70]::panicking::begin_panic::<rustc_errors[aa05a5e1436cb11f]::ExplicitBug>::{closure#0}
  15:     0x7f2982a02db6 - std[158e0661572bfb70]::sys_common::backtrace::__rust_end_short_backtrace::<std[158e0661572bfb70]::panicking::begin_panic<rustc_errors[aa05a5e1436cb11f]::ExplicitBug>::{closure#0}, !>
  16:     0x7f2982a024a6 - std[158e0661572bfb70]::panicking::begin_panic::<rustc_errors[aa05a5e1436cb11f]::ExplicitBug>
  17:     0x7f2982a0dc34 - <rustc_errors[aa05a5e1436cb11f]::HandlerInner>::bug::<alloc[b8d7d276236dc4dc]::string::String>
  18:     0x7f2982a0dab6 - <rustc_errors[aa05a5e1436cb11f]::Handler>::bug::<alloc[b8d7d276236dc4dc]::string::String>
  19:     0x7f298294d27c - rustc_middle[c8a9aab83046b80]::util::bug::opt_span_bug_fmt::<rustc_span[8207084c985c29b2]::span_encoding::Span>::{closure#0}
  20:     0x7f298294c98a - rustc_middle[c8a9aab83046b80]::ty::context::tls::with_opt::<rustc_middle[c8a9aab83046b80]::util::bug::opt_span_bug_fmt<rustc_span[8207084c985c29b2]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f298294c95a - rustc_middle[c8a9aab83046b80]::ty::context::tls::with_context_opt::<rustc_middle[c8a9aab83046b80]::ty::context::tls::with_opt<rustc_middle[c8a9aab83046b80]::util::bug::opt_span_bug_fmt<rustc_span[8207084c985c29b2]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f2980bf9c4d - rustc_middle[c8a9aab83046b80]::util::bug::bug_fmt
  23:     0x7f298091a0c6 - <rustc_middle[c8a9aab83046b80]::ty::context::TyCtxt>::item_name
  24:     0x7f29825bef38 - rustc_hir_analysis[2ce2f0004243268f]::check::report_forbidden_specialization
  25:     0x7f2981321c69 - rustc_hir_analysis[2ce2f0004243268f]::check::check::check_mod_item_types
  26:     0x7f298113425c - rustc_query_impl[1b840d390aceead0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1b840d390aceead0]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c8a9aab83046b80]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7f298113423e - <rustc_query_impl[1b840d390aceead0]::query_impl::check_mod_item_types::dynamic_query::{closure#2} as core[61f378b86da375b9]::ops::function::FnOnce<(rustc_middle[c8a9aab83046b80]::ty::context::TyCtxt, rustc_span[8207084c985c29b2]::def_id::LocalDefId)>>::call_once
  28:     0x7f2980b669af - rustc_query_system[6dbbf163f57784cb]::query::plumbing::try_execute_query::<rustc_query_impl[1b840d390aceead0]::DynamicConfig<rustc_query_system[6dbbf163f57784cb]::query::caches::VecCache<rustc_span[8207084c985c29b2]::def_id::LocalDefId, rustc_middle[c8a9aab83046b80]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1b840d390aceead0]::plumbing::QueryCtxt, false>
  29:     0x7f2981db08b4 - rustc_query_impl[1b840d390aceead0]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f29818ad2c7 - <rustc_middle[c8a9aab83046b80]::hir::map::Map>::for_each_module::<rustc_hir_analysis[2ce2f0004243268f]::check_crate::{closure#6}::{closure#0}>
  31:     0x7f29818ac6fd - <rustc_session[6a2016e5065eb503]::session::Session>::time::<(), rustc_hir_analysis[2ce2f0004243268f]::check_crate::{closure#6}>
  32:     0x7f29818ab387 - rustc_hir_analysis[2ce2f0004243268f]::check_crate
  33:     0x7f29818a23fa - rustc_interface[685a07e484656f4a]::passes::analysis
  34:     0x7f298192beba - rustc_query_impl[1b840d390aceead0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1b840d390aceead0]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c8a9aab83046b80]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7f298192bea9 - <rustc_query_impl[1b840d390aceead0]::query_impl::analysis::dynamic_query::{closure#2} as core[61f378b86da375b9]::ops::function::FnOnce<(rustc_middle[c8a9aab83046b80]::ty::context::TyCtxt, ())>>::call_once
  36:     0x7f2981aa2f58 - rustc_query_system[6dbbf163f57784cb]::query::plumbing::try_execute_query::<rustc_query_impl[1b840d390aceead0]::DynamicConfig<rustc_query_system[6dbbf163f57784cb]::query::caches::SingleCache<rustc_middle[c8a9aab83046b80]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1b840d390aceead0]::plumbing::QueryCtxt, false>
  37:     0x7f2981aa2d29 - rustc_query_impl[1b840d390aceead0]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f2981676d35 - <rustc_middle[c8a9aab83046b80]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>
  39:     0x7f2981676362 - <rustc_interface[685a07e484656f4a]::interface::Compiler>::enter::<rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}::{closure#2}, core[61f378b86da375b9]::result::Result<core[61f378b86da375b9]::option::Option<rustc_interface[685a07e484656f4a]::queries::Linker>, rustc_span[8207084c985c29b2]::ErrorGuaranteed>>
  40:     0x7f298166d075 - rustc_span[8207084c985c29b2]::set_source_map::<core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>, rustc_interface[685a07e484656f4a]::interface::run_compiler<core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>, rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  41:     0x7f298166cae6 - <scoped_tls[bbce240ef0a64b5f]::ScopedKey<rustc_span[8207084c985c29b2]::SessionGlobals>>::set::<rustc_interface[685a07e484656f4a]::interface::run_compiler<core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>, rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}>::{closure#0}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>
  42:     0x7f298166c0ac - std[158e0661572bfb70]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[685a07e484656f4a]::util::run_in_thread_pool_with_globals<rustc_interface[685a07e484656f4a]::interface::run_compiler<core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>, rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}>::{closure#0}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>
  43:     0x7f298166be75 - <<std[158e0661572bfb70]::thread::Builder>::spawn_unchecked_<rustc_interface[685a07e484656f4a]::util::run_in_thread_pool_with_globals<rustc_interface[685a07e484656f4a]::interface::run_compiler<core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>, rustc_driver_impl[7b385e897129221a]::run_compiler::{closure#1}>::{closure#0}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[61f378b86da375b9]::result::Result<(), rustc_span[8207084c985c29b2]::ErrorGuaranteed>>::{closure#1} as core[61f378b86da375b9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f297f171305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfa7c9203707b95b4
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/alloc/src/boxed.rs:1993:9
  45:     0x7f297f171305 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfff12c5df8b973a7
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/alloc/src/boxed.rs:1993:9
  46:     0x7f297f171305 - std::sys::unix::thread::Thread::new::thread_start::hb792ef8e1c27dbc6
                               at /rustc/921f669749a57ab5936721fdd93b2da57b581381/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7f297ef0444b - <unknown>
  48:     0x7f297ef87e40 - <unknown>
  49:                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: rustc 1.72.0-nightly (921f66974 2023-07-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z lower-impl-trait-in-trait-to-assoc-ty

query stack during panic:
#0 [check_mod_item_types] checking item types in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 8 previous errors

Some errors have detailed explanations: E0046, E0520, E0601, E0670, E0706.
For more information about an error, try `rustc --explain E0046`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions