Skip to content

Compiler bug while trying to use a Box<dyn T> #138888

@Big-Smarty

Description

@Big-Smarty

rustc-ice-2025-03-24T14_51_15-40318.txt

Code

use crate::intersection;
use crate::ray;

//give back the resulting intersection between the input ray and the object and also the scattered ray
pub trait Material: Sync + Send {
    fn scatter(&self, ray: ray::Ray) -> Option<(intersection::Intersection, ray::Ray)> {
        None
    }
}

Meta

rustc --version --verbose:

<version>
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

Error output

<output>
thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs:210:61:
$ident: found ImplItem(ImplItem { ident: material#0, owner_id: DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material), generics: Generics { params: [GenericParam { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).8), def_id: DefId(0:307 ~ rtrs[e135]::primitive::sphere::{impl#0}::material::'_), name: Fresh, span: src/primitive/sphere.rs:47:21: 47:22 (#0), pure_wrt_drop: false, kind: Lifetime { kind: Elided(Ampersand) }, colon_span: None, source: Generics }], predicates: [], has_where_clause_predicates: false, where_clause_span: src/primitive/sphere.rs:47:54: 47:54 (#0), span: src/primitive/sphere.rs:47:20: 47:20 (#0) }, kind: Fn(FnSig { header: FnHeader { safety: Normal(Safe), constness: NotConst, asyncness: NotAsync, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).12), span: src/primitive/sphere.rs:47:21: 47:26 (#0), kind: Ref(Lifetime { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).9), ident: '_#0, res: Param(DefId(0:307 ~ rtrs[e135]::primitive::sphere::{impl#0}::material::'_)) }, MutTy { ty: Ty {hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).11), span: src/primitive/sphere.rs:47:22: 47:26 (#0), kind: Path(Resolved(None, Path { span: src/primitive/sphere.rs:47:22: 47:26 (#0), res: SelfTyAlias { alias_to: DefId(0:126 ~ rtrs[e135]::primitive::sphere::{impl#0}), forbid_generic: false, is_trait_impl: false }, segments: [PathSegment { ident: Self#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).10), res: SelfTyAlias { alias_to: DefId(0:126 ~ rtrs[e135]::primitive::sphere::{impl#0}), forbid_generic: false, is_trait_impl: false }, args: None, infer_args: true }] })) }, mutbl: Not }) }], output: Return(Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).13), span: src/primitive/sphere.rs:47:31: 47:54 (#0), kind: Path(Resolved(None, Path { span: src/primitive/sphere.rs:47:31: 47:54 (#0), res: Def(Struct, DefId(3:670 ~ alloc[917b]::boxed::Box)), segments: [PathSegment { ident: Box#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).19), res: Def(Struct, DefId(3:670 ~ alloc[917b]::boxed::Box)), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).18), span: src/primitive/sphere.rs:47:35: 47:53 (#0), kind: TraitObject([PolyTraitRef { bound_generic_params: [], modifiers: TraitBoundModifiers { constness: Never, polarity: Positive }, trait_ref: TraitRef { path: Path { span: src/primitive/sphere.rs:47:35: 47:53 (#0), res: Def(Trait, DefId(0:114 ~ rtrs[e135]::material::Material)), segments: [PathSegment { ident: material#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).14), res: Def(Mod, DefId(0:111 ~ rtrs[e135]::material)), args: None, infer_args: false }, PathSegment { ident: Material#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).15), res: Def(Trait, DefId(0:114 ~ rtrs[e135]::material::Material)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).16) }, span: src/primitive/sphere.rs:47:35: 47:53 (#0) }], TaggedRef { pointer: Lifetime { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).17), ident: #0, res: ImplicitObjectLifetimeDefault }, tag: None }) })], constraints: [], parenthesized: No, span_ext: src/primitive/sphere.rs:47:34: 47:54 (#0) }), infer_args: false }] })) }), c_variadic: false, implicit_self: RefImm, lifetime_elision_allowed: true }, span: src/primitive/sphere.rs:47:5: 47:54 (#0) }, BodyId { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).7) }), defaultness: Final, span: src/primitive/sphere.rs:47:5: 49:6 (#0), vis_span: src/primitive/sphere.rs:47:5: 47:8 (#0) })
stack backtrace:
   0:     0x7ae7c90139b4 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0d1f2839602806ff
   1:     0x7ae7c9805a5a - core::fmt::write::h0c7e57e1fb2fde66
   2:     0x7ae7cab860d1 - std::io::Write::write_fmt::h7469fd7bdff7996d
   3:     0x7ae7c9013812 - std::sys::backtrace::BacktraceLock::print::hacdf24c938fbe4de
   4:     0x7ae7c9016138 - std::panicking::default_hook::{{closure}}::he52ba311cf62e2c1
   5:     0x7ae7c9015c57 - std::panicking::default_hook::h3849b4d96fafc882
   6:     0x7ae7c808368f - std[8d48930af2b37499]::panicking::update_hook::<alloc[917be3ddc91b1c2b]::boxed::Box<rustc_driver_impl[cb2ef720636d8c5e]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7ae7c90169a3 - std::panicking::rust_panic_with_hook::hdd2c1ee436bc47e1
   8:     0x7ae7c901669a - std::panicking::begin_panic_handler::{{closure}}::h2d122914997e8086
   9:     0x7ae7c9013e89 - std::sys::backtrace::__rust_end_short_backtrace::hd9079b2f352c9f4f
  10:     0x7ae7c901635d - rust_begin_unwind
  11:     0x7ae7c5a6c570 - core::panicking::panic_fmt::h69773a3e9707cb82
  12:     0x7ae7c8151c31 - rustc_hir[b2623b24b2b871ce]::hir::expect_failed::<&rustc_hir[b2623b24b2b871ce]::hir::Node>
  13:     0x7ae7caad2189 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::prohibit_or_lint_bare_trait_object_ty
  14:     0x7ae7c9d89962 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_ty
  15:     0x7ae7c9d86d66 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
  16:     0x7ae7c9d8a72b - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_path
  17:     0x7ae7c9d8929a - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_ty
  18:     0x7ae7c9d99fb6 - <dyn rustc_hir_analysis[44b7779f9b34443e]::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
  19:     0x7ae7c9d996de - rustc_hir_analysis[44b7779f9b34443e]::collect::lower_fn_sig_recovering_infer_ret_ty
  20:     0x7ae7c9d97d2e - rustc_hir_analysis[44b7779f9b34443e]::collect::fn_sig
  21:     0x7ae7c9cb11d7 - rustc_query_impl[5838e3d4961b7ce3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5838e3d4961b7ce3]::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle[602e8fb74d6cfd7]::query::erase::Erased<[u8; 24usize]>>
  22:     0x7ae7c9cb11ad - <rustc_query_impl[5838e3d4961b7ce3]::query_impl::fn_sig::dynamic_query::{closure#2} as core[c99fea247d116993]::ops::function::FnOnce<(rustc_middle[602e8fb74d6cfd7]::ty::context::TyCtxt, rustc_span[6a00076ff7f7ecaa]::def_id::DefId)>>::call_once
  23:     0x7ae7c9cb2f75 - 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; 24usize]>>, false, false, false>, rustc_query_impl[5838e3d4961b7ce3]::plumbing::QueryCtxt, false>
  24:     0x7ae7c9cb2674 - rustc_query_impl[5838e3d4961b7ce3]::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7ae7c9dac573 - <rustc_hir_analysis[44b7779f9b34443e]::collect::CollectItemTypesVisitor as rustc_hir[b2623b24b2b871ce]::intravisit::Visitor>::visit_impl_item
  26:     0x7ae7c9da4b45 - rustc_hir_analysis[44b7779f9b34443e]::check::wfcheck::check_well_formed
  27:     0x7ae7c9da3011 - 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]>>
  28:     0x7ae7c9da2ac8 - 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>
  29:     0x7ae7c9da2583 - rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ae7c9d9fba5 - rustc_hir_analysis[44b7779f9b34443e]::check::wfcheck::check_mod_type_wf
  31:     0x7ae7c9d9f89d - 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]>>
  32:     0x7ae7ca7d35d4 - 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>
  33:     0x7ae7ca7d337e - rustc_query_impl[5838e3d4961b7ce3]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7ae7c9d83497 - rustc_hir_analysis[44b7779f9b34443e]::check_crate
  35:     0x7ae7c9c400dd - rustc_interface[90e31f5b4a029d3a]::passes::run_required_analyses
  36:     0x7ae7ca7e1fb8 - rustc_interface[90e31f5b4a029d3a]::passes::analysis
  37:     0x7ae7ca7e1f97 - 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]>>
  38:     0x7ae7ca91ac01 - 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>
  39:     0x7ae7ca91a8f4 - rustc_query_impl[5838e3d4961b7ce3]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7ae7cab5affc - 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}
  41:     0x7ae7ca963817 - rustc_interface[90e31f5b4a029d3a]::interface::run_compiler::<(), rustc_driver_impl[cb2ef720636d8c5e]::run_compiler::{closure#0}>::{closure#1}
  42:     0x7ae7ca7c0fd2 - 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}, ()>
  43:     0x7ae7ca7c18b4 - <<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}
  44:     0x7ae7ca7c2cab - std::sys::pal::unix::thread::Thread::new::thread_start::h7dc228a213406109
  45:     0x7ae7c44972e3 - start_thread
  46:     0x7ae7c451b2fc - __GI___clone3
  47:                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: please attach the file at `/home/bigsmarty/projects/rtrs/rustc-ice-2025-03-24T14_51_15-40318.txt` to your bug report

note: compiler flags: --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C linker=clang -C strip=debuginfo -C link-arg=-fuse-ld=mold

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [fn_sig] computing function signature of `primitive::sphere::<impl at src/primitive/sphere.rs:20:1: 20:12>::material`
#1 [check_well_formed] checking that `primitive::sphere::<impl at src/primitive/sphere.rs:20:1: 20:12>::material` is well-formed
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
warning: `rtrs` (lib) generated 4 warnings (run `cargo fix --lib -p rtrs` to apply 4 suggestions)
error: could not compile `rtrs` (lib); 4 warnings emitted

Caused by:
  process didn't exit successfully: `/nix/store/cdirc57ifwi19zjbmsj5dshzd7m8r8ma-sccache-0.10.0/bin/sccache /home/bigsmarty/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rtrs --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=232 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=1d606345b6985bc0 -C extra-filename=-28c58b2808874cd0 --out-dir /home/bigsmarty/projects/rtrs/target/release/deps -C linker=clang -C strip=debuginfo -L dependency=/home/bigsmarty/projects/rtrs/target/release/deps --extern apecs=/home/bigsmarty/projects/rtrs/target/release/deps/libapecs-d434b8443e224e3e.rmeta --extern chrono=/home/bigsmarty/projects/rtrs/target/release/deps/libchrono-fa9ec590987264be.rmeta --extern crossterm=/home/bigsmarty/projects/rtrs/target/release/deps/libcrossterm-447d9ebd801fc6c6.rmeta --extern glam=/home/bigsmarty/projects/rtrs/target/release/deps/libglam-04081d43ae85bd69.rmeta --extern image=/home/bigsmarty/projects/rtrs/target/release/deps/libimage-56c00534f582d2dc.rmeta --extern log=/home/bigsmarty/projects/rtrs/target/release/deps/liblog-a09f23c8b152e23f.rmeta --extern rand=/home/bigsmarty/projects/rtrs/target/release/deps/librand-fb5c37a073bc0a92.rmeta --extern ratatui=/home/bigsmarty/projects/rtrs/target/release/deps/libratatui-4993cf7ba3bb402e.rmeta --extern ratatui_image=/home/bigsmarty/projects/rtrs/target/release/deps/libratatui_image-f2191a871c2bffe0.rmeta --extern rayon=/home/bigsmarty/projects/rtrs/target/release/deps/librayon-3ef9421143580e67.rmeta --extern simplelog=/home/bigsmarty/projects/rtrs/target/release/deps/libsimplelog-a18207bdbeb19aee.rmeta --extern tokio=/home/bigsmarty/projects/rtrs/target/release/deps/libtokio-780d35a130e81ef1.rmeta -C link-arg=-fuse-ld=mold` (exit status: 101)
Backtrace

<backtrace>
   Compiling rtrs v0.1.0 (/home/bigsmarty/projects/rtrs)
warning: unused import: `crate::intersectable::Intersectable`
 --> src/primitive.rs:3:5
  |
3 | use crate::intersectable::Intersectable;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `material`
  --> src/renderables.rs:10:25
   |
10 | use crate::{lambertian, material};
   |                         ^^^^^^^^

warning: unused import: `crate::material`
 --> src/scene.rs:5:5
  |
5 | use crate::material;
  |     ^^^^^^^^^^^^^^^

warning: unused import: `rand::prelude::*`
 --> src/util/rand.rs:2:5
  |
2 | use rand::prelude::*;
  |     ^^^^^^^^^^^^^^^^


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs:210:61:
$ident: found ImplItem(ImplItem { ident: material#0, owner_id: DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material), generics: Generics { params: [GenericParam { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).8), def_id: DefId(0:307 ~ rtrs[e135]::primitive::sphere::{impl#0}::material::'_), name: Fresh, span: src/primitive/sphere.rs:47:21: 47:22 (#0), pure_wrt_drop: false, kind: Lifetime { kind: Elided(Ampersand) }, colon_span: None, source: Generics }], predicates: [], has_where_clause_predicates: false, where_clause_span: src/primitive/sphere.rs:47:54: 47:54 (#0), span: src/primitive/sphere.rs:47:20: 47:20 (#0) }, kind: Fn(FnSig { header: FnHeader { safety: Normal(Safe), constness: NotConst, asyncness: NotAsync, abi: Rust }, decl: FnDecl { inputs: [Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).12), span: src/primitive/sphere.rs:47:21: 47:26 (#0), kind: Ref(Lifetime { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).9), ident: '_#0, res: Param(DefId(0:307 ~ rtrs[e135]::primitive::sphere::{impl#0}::material::'_)) }, MutTy { ty: Ty {hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).11), span: src/primitive/sphere.rs:47:22: 47:26 (#0), kind: Path(Resolved(None, Path { span: src/primitive/sphere.rs:47:22: 47:26 (#0), res: SelfTyAlias { alias_to: DefId(0:126 ~ rtrs[e135]::primitive::sphere::{impl#0}), forbid_generic: false, is_trait_impl: false }, segments: [PathSegment { ident: Self#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).10), res: SelfTyAlias { alias_to: DefId(0:126 ~ rtrs[e135]::primitive::sphere::{impl#0}), forbid_generic: false, is_trait_impl: false }, args: None, infer_args: true }] })) }, mutbl: Not }) }], output: Return(Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).13), span: src/primitive/sphere.rs:47:31: 47:54 (#0), kind: Path(Resolved(None, Path { span: src/primitive/sphere.rs:47:31: 47:54 (#0), res: Def(Struct, DefId(3:670 ~ alloc[917b]::boxed::Box)), segments: [PathSegment { ident: Box#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).19), res: Def(Struct, DefId(3:670 ~ alloc[917b]::boxed::Box)), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).18), span: src/primitive/sphere.rs:47:35: 47:53 (#0), kind: TraitObject([PolyTraitRef { bound_generic_params: [], modifiers: TraitBoundModifiers { constness: Never, polarity: Positive }, trait_ref: TraitRef { path: Path { span: src/primitive/sphere.rs:47:35: 47:53 (#0), res: Def(Trait, DefId(0:114 ~ rtrs[e135]::material::Material)), segments: [PathSegment { ident: material#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).14), res: Def(Mod, DefId(0:111 ~ rtrs[e135]::material)), args: None, infer_args: false }, PathSegment { ident: Material#0, hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).15), res: Def(Trait, DefId(0:114 ~ rtrs[e135]::material::Material)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).16) }, span: src/primitive/sphere.rs:47:35: 47:53 (#0) }], TaggedRef { pointer: Lifetime { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).17), ident: #0, res: ImplicitObjectLifetimeDefault }, tag: None }) })], constraints: [], parenthesized: No, span_ext: src/primitive/sphere.rs:47:34: 47:54 (#0) }), infer_args: false }] })) }), c_variadic: false, implicit_self: RefImm, lifetime_elision_allowed: true }, span: src/primitive/sphere.rs:47:5: 47:54 (#0) }, BodyId { hir_id: HirId(DefId(0:131 ~ rtrs[e135]::primitive::sphere::{impl#0}::material).7) }), defaultness: Final, span: src/primitive/sphere.rs:47:5: 49:6 (#0), vis_span: src/primitive/sphere.rs:47:5: 47:8 (#0) })
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_hir::hir::expect_failed::<&rustc_hir::hir::Node>
   3: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::prohibit_or_lint_bare_trait_object_ty
   4: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
   5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
   6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_path
   7: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
   8: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_fn_ty
   9: rustc_hir_analysis::collect::lower_fn_sig_recovering_infer_ret_ty
  10: rustc_hir_analysis::collect::fn_sig
      [... omitted 2 frames ...]
  11: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_impl_item
  12: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  13: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
      [... omitted 1 frame ...]
  14: rustc_hir_analysis::check_crate
  15: rustc_interface::passes::run_required_analyses
  16: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  17: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  18: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/home/bigsmarty/projects/rtrs/rustc-ice-2025-03-24T14_55_44-40977.txt` to your bug report

note: compiler flags: --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C linker=clang -C strip=debuginfo -C link-arg=-fuse-ld=mold

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [fn_sig] computing function signature of `primitive::sphere::<impl at src/primitive/sphere.rs:20:1: 20:12>::material`
#1 [check_well_formed] checking that `primitive::sphere::<impl at src/primitive/sphere.rs:20:1: 20:12>::material` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in module `primitive::sphere`
#3 [analysis] running analysis passes on this crate
end of query stack
warning: `rtrs` (lib) generated 4 warnings (run `cargo fix --lib -p rtrs` to apply 4 suggestions)
error: could not compile `rtrs` (lib); 4 warnings emitted

Caused by:
  process didn't exit successfully: `/nix/store/cdirc57ifwi19zjbmsj5dshzd7m8r8ma-sccache-0.10.0/bin/sccache /home/bigsmarty/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rtrs --edition=2024 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=232 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=1d606345b6985bc0 -C extra-filename=-28c58b2808874cd0 --out-dir /home/bigsmarty/projects/rtrs/target/release/deps -C linker=clang -C strip=debuginfo -L dependency=/home/bigsmarty/projects/rtrs/target/release/deps --extern apecs=/home/bigsmarty/projects/rtrs/target/release/deps/libapecs-d434b8443e224e3e.rmeta --extern chrono=/home/bigsmarty/projects/rtrs/target/release/deps/libchrono-fa9ec590987264be.rmeta --extern crossterm=/home/bigsmarty/projects/rtrs/target/release/deps/libcrossterm-447d9ebd801fc6c6.rmeta --extern glam=/home/bigsmarty/projects/rtrs/target/release/deps/libglam-04081d43ae85bd69.rmeta --extern image=/home/bigsmarty/projects/rtrs/target/release/deps/libimage-56c00534f582d2dc.rmeta --extern log=/home/bigsmarty/projects/rtrs/target/release/deps/liblog-a09f23c8b152e23f.rmeta --extern rand=/home/bigsmarty/projects/rtrs/target/release/deps/librand-fb5c37a073bc0a92.rmeta --extern ratatui=/home/bigsmarty/projects/rtrs/target/release/deps/libratatui-4993cf7ba3bb402e.rmeta --extern ratatui_image=/home/bigsmarty/projects/rtrs/target/release/deps/libratatui_image-f2191a871c2bffe0.rmeta --extern rayon=/home/bigsmarty/projects/rtrs/target/release/deps/librayon-3ef9421143580e67.rmeta --extern simplelog=/home/bigsmarty/projects/rtrs/target/release/deps/libsimplelog-a18207bdbeb19aee.rmeta --extern tokio=/home/bigsmarty/projects/rtrs/target/release/deps/libtokio-780d35a130e81ef1.rmeta -C link-arg=-fuse-ld=mold` (exit status: 101)

Activity

added
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.
on Mar 24, 2025
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 24, 2025
Big-Smarty

Big-Smarty commented on Mar 24, 2025

@Big-Smarty
Author

basically Im trying to do this:

pub trait Foo: Sync + Send {
}

pub struct FooStruct {}

impl Foo for FooStruct {
}

pub struct Bar {
    foo: Box<dyn Foo>
}
cyrgani

cyrgani commented on Mar 24, 2025

@cyrgani
Contributor

this is a duplicate of #138211, which is already fixed on the latest nightly

compiler-errors

compiler-errors commented on Mar 24, 2025

@compiler-errors
Member

Yep, please update your compiler :)

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @compiler-errors@fmease@rustbot@Big-Smarty@cyrgani

        Issue actions

          Compiler bug while trying to use a Box<dyn T> · Issue #138888 · rust-lang/rust