Skip to content

Trait's types could not be determined #114057

Closed
@Jenya705

Description

@Jenya705

Code

pub trait A {
    type B;

    fn m(b: Self::B);
}

pub trait C<'a> {
    type D: 'a; 
}

struct S;

impl<'a> C<'a> for S {
    type D = ();
}

struct T<CG: C<'static>> {
    d: &'static CG::D,
}

impl A for S
where 
    for<'a> S: C<'a> {
    type B = T<S>;

    fn m(b: Self::B) {
        f(b.d)    
    }
}

fn f(d: &<S as C>::D) {}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (31395ec38 2023-07-24)
binary: rustc
commit-hash: 31395ec38250b60b380fd3c27e94756aba3557de
commit-date: 2023-07-24
host: x86_64-pc-windows-msvc
release: 1.73.0-nightly
LLVM version: 16.0.5

Error output

error: internal compiler error: /rustc/31395ec38250b60b380fd3c27e94756aba3557de\compiler\rustc_const_eval\src\interpret\place.rs:653:13: type mismatch when copying!
                                src: &(),
                                dest: &<S as C<'_>>::D
  --> src\main.rs:27:11
   |
27 |         f(b.d)
   |           ^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/31395ec38250b60b380fd3c27e94756aba3557de\compiler\rustc_errors\src\lib.rs:1007:33
stack backtrace:
   0:     0x7ffafe358b6c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd03a95172b6fcf57
   1:     0x7ffafe392a5b - core::fmt::write::he3165d1d7dc3f002
   2:     0x7ffafe34dd91 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h6069b8ca54bb4015
   3:     0x7ffafe35891b - std::sys::common::alloc::realloc_fallback::h49007f5c332b820a
   4:     0x7ffafe35c2d3 - std::panicking::panic_hook_with_disk_dump::he95d68a9852fd168
   5:     0x7ffafe35be7a - std::panicking::panic_hook_with_disk_dump::he95d68a9852fd168
   6:     0x7ffaebeab2f0 - rustc_driver_impl[55ec51074fcbdf41]::ice_path
   7:     0x7ffafe35cc9a - std::panicking::rust_panic_with_hook::h7ab7a381000f0959
   8:     0x7ffaec30a0b3 - <rustc_mir_transform[f49da265e3e79212]::errors::MustNotSupend as rustc_errors[223d10168b8ae2b1]::diagnostic::DecorateLint<()>>::msg
   9:     0x7ffaec306549 - <rustc_mir_transform[f49da265e3e79212]::errors::MustNotSupend as rustc_errors[223d10168b8ae2b1]::diagnostic::DecorateLint<()>>::msg
  10:     0x7ffaec3609a9 - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  11:     0x7ffaec35e391 - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  12:     0x7ffaec35e1ad - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  13:     0x7ffaec39d3df - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  14:     0x7ffaec39d41d - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  15:     0x7ffaec39cacf - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  16:     0x7ffaec39ca76 - <rustc_mir_transform[f49da265e3e79212]::coverage::spans::CoverageSpan as core[5892f5adc6345ffc]::fmt::Debug>::fmt
  17:     0x7ffaeb2fb1a8 - <rustc_mir_transform[f49da265e3e79212]::remove_storage_markers::RemoveStorageMarkers as rustc_middle[f9049dd98e39c010]::mir::MirPass>::run_pass
  18:     0x7ffaeb240dfc - <rustc_mir_transform[f49da265e3e79212]::const_prop_lint::ConstPropagator as rustc_middle[f9049dd98e39c010]::mir::visit::Visitor>::visit_basic_block_data
  19:     0x7ffaeb23f791 - <rustc_mir_transform[f49da265e3e79212]::const_prop_lint::ConstProp as rustc_mir_transform[f49da265e3e79212]::pass_manager::MirLint>::run_lint
  20:     0x7ffaeb22bc8f - <rustc_mir_transform[f49da265e3e79212]::simplify_comparison_integral::SimplifyComparisonIntegral as rustc_middle[f9049dd98e39c010]::mir::MirPass>::run_pass
  21:     0x7ffaeb7efdbf - <rustc_query_impl[194cf41dd8cf861e]::plumbing::QueryCtxt as rustc_query_system[71f5d4e748ef2a3f]::query::QueryContext>::load_side_effects
  22:     0x7ffaeb847eff - <rustc_query_impl[194cf41dd8cf861e]::plumbing::QueryCtxt as rustc_query_system[71f5d4e748ef2a3f]::query::QueryContext>::load_side_effects
  23:     0x7ffaeb8b1249 - <rustc_query_impl[194cf41dd8cf861e]::plumbing::QueryCtxt as rustc_query_system[71f5d4e748ef2a3f]::query::QueryContext>::load_side_effects
  24:     0x7ffaeab9daf2 - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  25:     0x7ffaeaf231ef - rustc_driver_impl[55ec51074fcbdf41]::args::arg_expand_all
  26:     0x7ffae823d750 - rustc_interface[7385ddcaaf499a65]::passes::analysis
  27:     0x7ffaeaafeded - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  28:     0x7ffaeab19ba9 - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  29:     0x7ffaeab3c1e5 - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  30:     0x7ffaeab509aa - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  31:     0x7ffaeab9afdc - rustc_query_impl[194cf41dd8cf861e]::profiling_support::alloc_self_profile_query_strings
  32:     0x7ffae81ecb91 - rustc_driver_impl[55ec51074fcbdf41]::main
  33:     0x7ffae81f7463 - rustc_driver_impl[55ec51074fcbdf41]::main
  34:     0x7ffae820d412 - <rustc_middle[f9049dd98e39c010]::ty::SymbolName as core[5892f5adc6345ffc]::fmt::Display>::fmt
  35:     0x7ffae820ea6f - <rustc_middle[f9049dd98e39c010]::ty::SymbolName as core[5892f5adc6345ffc]::fmt::Display>::fmt
  36:     0x7ffafe37036c - std::sys::windows::thread::Thread::new::he11eb30ab359cca1
  37:     0x7ffb59bf26ad - BaseThreadInitThunk
  38:     0x7ffb5a4aaa68 - RtlUserThreadStart

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

warning: the ICE couldn't be written to `\rusttest\rustc-ice-2023-07-25T13:29:05.2566834Z-44140.txt`: (os error 123)

note: rustc 1.73.0-nightly (31395ec38 2023-07-24) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `<impl at src\main.rs:21:1: 21:13>::m`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: `rusttest` (bin "rusttest") generated 1 warning (run `cargo fix --bin "rusttest"` to apply 1 suggestion)
error: could not compile `rusttest` (bin "rusttest"); 1 warning emitted
Backtrace

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions