Skip to content

nightly rustc panicked when no dyn before trait in type T = #138369

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

Closed
wychlw opened this issue Mar 11, 2025 · 2 comments
Closed

nightly rustc panicked when no dyn before trait in type T = #138369

wychlw opened this issue Mar 11, 2025 · 2 comments
Labels
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.

Comments

@wychlw
Copy link

wychlw commented Mar 11, 2025

Code

trait T1{
    type T;
}
trait T2{
}
struct S {}
impl T1 for S{
    type T = T2;
}

fn main() {}

Compile with:

RUST_BACKTRACE=1 rustc --edition 2024 src/main.rs

Meta

rustc --version --verbose:

rustc 1.87.0-nightly (9fb94b32d 2025-03-10)
binary: rustc
commit-hash: 9fb94b32df38073bf63d009df77ed10cb1c989d0
commit-date: 2025-03-10
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Note: This panic won't happen if using a stable version rust.

Error output

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs:210:61:
$ident: found ImplItem(ImplItem { ident: T#0, owner_id: DefId(0:9 ~ nfuzz[80de]::{impl#0}::T), generics: Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: src/main.rs:9:16: 9:16 (#0), span: src/main.rs:9:11: 9:11 (#0) }, kind: Type(Ty { hir_id: HirId(DefId(0:9 ~ nfuzz[80de]::{impl#0}::T).4), span: src/main.rs:9:14: 9:16 (#0), kind: TraitObject([PolyTraitRef { bound_generic_params: [], modifiers: TraitBoundModifiers { constness: Never, polarity: Positive }, trait_ref: TraitRef { path: Path { span: src/main.rs:9:14: 9:16 (#0), res: Def(Trait, DefId(0:5 ~ nfuzz[80de]::T2)), segments: [PathSegment { ident: T2#0, hir_id: HirId(DefId(0:9 ~ nfuzz[80de]::{impl#0}::T).1), res: Def(Trait, DefId(0:5 ~ nfuzz[80de]::T2)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:9 ~ nfuzz[80de]::{impl#0}::T).2) }, span: src/main.rs:9:14: 9:16 (#0) }], TaggedRef { pointer: Lifetime { hir_id: HirId(DefId(0:9 ~ nfuzz[80de]::{impl#0}::T).3), ident: #0, res: ImplicitObjectLifetimeDefault }, tag: None }) }), defaultness: Final, span: src/main.rs:9:5: 9:17 (#0), vis_span: src/main.rs:9:5: 9:5 (#0) })
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs:210:61:
$ident: found ImplItem(ImplItem { ident: T#0, owner_id: DefId(0:9 ~ main[5c0d]::{impl#0}::T), generics: Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: src/main.rs:9:16: 9:16 (#0), span: src/main.rs:9:11: 9:11 (#0) }, kind: Type(Ty { hir_id: HirId(DefId(0:9 ~ main[5c0d]::{impl#0}::T).4), span: src/main.rs:9:14: 9:16 (#0), kind: TraitObject([PolyTraitRef { bound_generic_params: [], modifiers: TraitBoundModifiers { constness: Never, polarity: Positive }, trait_ref: TraitRef { path: Path { span: src/main.rs:9:14: 9:16 (#0), res: Def(Trait, DefId(0:5 ~ main[5c0d]::T2)), segments: [PathSegment { ident: T2#0, hir_id: HirId(DefId(0:9 ~ main[5c0d]::{impl#0}::T).1), res: Def(Trait, DefId(0:5 ~ main[5c0d]::T2)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:9 ~ main[5c0d]::{impl#0}::T).2) }, span: src/main.rs:9:14: 9:16 (#0) }], TaggedRef { pointer: Lifetime { hir_id: HirId(DefId(0:9 ~ main[5c0d]::{impl#0}::T).3), ident: #0, res: ImplicitObjectLifetimeDefault }, tag: None }) }), defaultness: Final, span: src/main.rs:9:5: 9:17 (#0), vis_span: src/main.rs:9:5: 9:5 (#0) })
stack backtrace:
   0:     0x7f83744bd7a5 - std::backtrace::Backtrace::create::h1c390fc3b8673de8
   1:     0x7f83727fe185 - std::backtrace::Backtrace::force_capture::h9092203d313dcaea
   2:     0x7f8371883dda - std[8d48930af2b37499]::panicking::update_hook::<alloc[917be3ddc91b1c2b]::boxed::Box<rustc_driver_impl[cb2ef720636d8c5e]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7f83728169a3 - std::panicking::rust_panic_with_hook::hdd2c1ee436bc47e1
   4:     0x7f837281669a - std::panicking::begin_panic_handler::{{closure}}::h2d122914997e8086
   5:     0x7f8372813e89 - std::sys::backtrace::__rust_end_short_backtrace::hd9079b2f352c9f4f
   6:     0x7f837281635d - rust_begin_unwind
   7:     0x7f836f26c570 - core::panicking::panic_fmt::h69773a3e9707cb82
   8:     0x7f8371951c31 - rustc_hir[b2623b24b2b871ce]::hir::expect_failed::<&rustc_hir[b2623b24b2b871ce]::hir::Node>
   9:     0x7f83742d2189 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::prohibit_or_lint_bare_trait_object_ty
  10:     0x7f8373589962 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_ty
  11:     0x7f8373578bb5 - rustc_hir_analysis[44b7779f9b34443e]::collect::type_of::type_of
  12:     0x7f8373027866 - rustc_query_impl[5838e3d4961b7ce3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5838e3d4961b7ce3]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 8usize]>>
  13:     0x7f83730266b2 - rustc_query_system[35a24321d428aa9e]::query::plumbing::try_execute_query::<rustc_query_impl[5838e3d4961b7ce3]::DynamicConfig<rustc_query_system[35a24321d428aa9e]::query::caches::DefIdCache<rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5838e3d4961b7ce3]::plumbing::QueryCtxt, false>
  14:     0x7f837302625f - rustc_query_impl[5838e3d4961b7ce3]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  15:     0x7f83735a5202 - rustc_hir_analysis[44b7779f9b34443e]::check::wfcheck::check_well_formed
  16:     0x7f83735a3011 - rustc_query_impl[5838e3d4961b7ce3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 1usize]>>
  17:     0x7f83735a2ac8 - rustc_query_system[35a24321d428aa9e]::query::plumbing::try_execute_query::<rustc_query_impl[5838e3d4961b7ce3]::DynamicConfig<rustc_data_structures[3750d9ccf695a742]::vec_cache::VecCache<rustc_span[6a00076ff7f7ecaa]::def_id::LocalDefId, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[35a24321d428aa9e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[5838e3d4961b7ce3]::plumbing::QueryCtxt, false>
  18:     0x7f83735a2583 - rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  19:     0x7f837359faa4 - rustc_hir_analysis[44b7779f9b34443e]::check::wfcheck::check_mod_type_wf
  20:     0x7f837359f89d - rustc_query_impl[5838e3d4961b7ce3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 1usize]>>
  21:     0x7f8373fd35d4 - rustc_query_system[35a24321d428aa9e]::query::plumbing::try_execute_query::<rustc_query_impl[5838e3d4961b7ce3]::DynamicConfig<rustc_query_system[35a24321d428aa9e]::query::caches::DefaultCache<rustc_span[6a00076ff7f7ecaa]::def_id::LocalModDefId, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5838e3d4961b7ce3]::plumbing::QueryCtxt, false>
  22:     0x7f8373fd337e - rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7f8373583497 - rustc_hir_analysis[44b7779f9b34443e]::check_crate
  24:     0x7f83734400dd - rustc_interface[90e31f5b4a029d3a]::passes::run_required_analyses
  25:     0x7f8373fe1fb8 - rustc_interface[90e31f5b4a029d3a]::passes::analysis
  26:     0x7f8373fe1f97 - rustc_query_impl[5838e3d4961b7ce3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5838e3d4961b7ce3]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7f837411ac01 - rustc_query_system[35a24321d428aa9e]::query::plumbing::try_execute_query::<rustc_query_impl[5838e3d4961b7ce3]::DynamicConfig<rustc_query_system[35a24321d428aa9e]::query::caches::SingleCache<rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[5838e3d4961b7ce3]::plumbing::QueryCtxt, false>
  28:     0x7f837411a8f4 - rustc_query_impl[5838e3d4961b7ce3]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f837435affc - rustc_interface[90e31f5b4a029d3a]::passes::create_and_enter_global_ctxt::<core[c99fea247d116993]::option::Option<rustc_interface[90e31f5b4a029d3a]::queries::Linker>, rustc_driver_impl[cb2ef720636d8c5e]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x7f8374163817 - rustc_interface[90e31f5b4a029d3a]::interface::run_compiler::<(), rustc_driver_impl[cb2ef720636d8c5e]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7f8373fc0fd2 - std[8d48930af2b37499]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[90e31f5b4a029d3a]::util::run_in_thread_with_globals<rustc_interface[90e31f5b4a029d3a]::util::run_in_thread_pool_with_globals<rustc_interface[90e31f5b4a029d3a]::interface::run_compiler<(), rustc_driver_impl[cb2ef720636d8c5e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7f8373fc18b4 - <<std[8d48930af2b37499]::thread::Builder>::spawn_unchecked_<rustc_interface[90e31f5b4a029d3a]::util::run_in_thread_with_globals<rustc_interface[90e31f5b4a029d3a]::util::run_in_thread_pool_with_globals<rustc_interface[90e31f5b4a029d3a]::interface::run_compiler<(), rustc_driver_impl[cb2ef720636d8c5e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c99fea247d116993]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f8373fc2cab - std::sys::pal::unix::thread::Thread::new::thread_start::h7dc228a213406109
  34:     0x7f836de6470a - <unknown>
  35:     0x7f836dee8aac - <unknown>
  36:                0x0 - <unknown>


rustc version: 1.87.0-nightly (9fb94b32d 2025-03-10)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [type_of] computing type of `<impl at src/main.rs:8:1: 8:14>::T`
#1 [check_well_formed] checking that `<impl at src/main.rs:8:1: 8:14>` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack


@wychlw wychlw 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 Mar 11, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 11, 2025
@compiler-errors
Copy link
Member

compiler-errors commented Mar 11, 2025

Should be fixed by #138238, which should be in today's nightly but will definitely be in tomorrow's.

@wychlw
Copy link
Author

wychlw commented Mar 13, 2025

Confirm has been fixed :)
Thanks a lot!

@wychlw wychlw closed this as completed Mar 13, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

4 participants