Closed
Description
Code
I have not yet successfully reproduced the bug but I have a direction. it seems the compile has some struggles with how to deal with generic that are phantomdata. in this case Exact is phantomdata
pub fn get_exact_storage( storage: Self) -> Result<Storage< 2, Float, Exact>, Self>{
if storage.seeds.len() == 4{
return Ok(Self{ seeds: storage.seeds, state: PhantomData });
}
Err(storage)
}
when I changed it to this it has compiled successfully
(Self is Storage< 2, Float, UnExact>)
pub fn get_exact_storage( storage: Self) -> Result<Storage< 2, Float, UnExact>, Self>{
if storage.seeds.len() == 4{
return Ok(Self{ seeds: storage.seeds, state: PhantomData });
}
Err(storage)
}
I have also tried to reproduce the bug with this simple code but I have to compile
use std::marker::PhantomData;
struct A;
struct B;
struct Foo<T>{
_marker: PhantomData<T>
}
impl Foo<A>{
pub fn some_func(value: Self, number:i32) -> Result<Foo<A>, Foo<B>>{
if number == 0{
return Ok(value );
}
Err(Foo { _marker: PhantomData })
}
}
Meta
rustc 1.77.2 (25ef9e3 2024-04-09)
binary: rustc
commit-hash: 25ef9e3
commit-date: 2024-04-09
host: x86_64-pc-windows-msvc
release: 1.77.2
LLVM version: 17.0.6
Error output
compiler\rustc_middle\src\ty\generic_args.rs:907:9: expected type for `Float/#0` (Float/#0/0) but found Const(2_usize) when substituting, args=[2_usize, Float/#0, storage::Exact]
thread 'rustc' panicked at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_errors\src\lib.rs:932:30:
Box<dyn Any>
stack backtrace:
0: 0x7ffef5c72902 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h708c0e6d07ee75bc
1: 0x7ffef5ca5a5d - core::fmt::write::ha562f117fc8493e6
2: 0x7ffef5c68f91 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h73b3c4d73d82ca2e
3: 0x7ffef5c7272a - std::sys_common::backtrace::lock::h300ba94956ddd24a
4: 0x7ffef5c75ac9 - std::panicking::default_hook::hc9d04f0d76a9742b
5: 0x7ffef5c75785 - std::panicking::default_hook::hc9d04f0d76a9742b
6: 0x7ffed51db863 - <tracing_subscriber[c0eceff03426eead]::fmt::format::Writer>::write_fmt
7: 0x7ffef5c760d3 - std::panicking::rust_panic_with_hook::h05ca8ac23cc77c65
8: 0x7ffed65f20d8 - rustc_errors[10ae28232b989578]::add_elided_lifetime_in_path_suggestion
9: 0x7ffed65f2019 - rustc_errors[10ae28232b989578]::add_elided_lifetime_in_path_suggestion
10: 0x7ffed65ff069 - <rustc_errors[10ae28232b989578]::registry::Registry>::try_find_description
11: 0x7ffed66033d5 - <rustc_errors[10ae28232b989578]::diagnostic_builder::BugAbort as rustc_errors[10ae28232b989578]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
12: 0x7ffed649563c - <core[d4e1671815e8b4a5]::option::Option<rustc_middle[3a1ce97b5b0524ba]::mir::terminator::Terminator> as rustc_middle[3a1ce97b5b0524ba]::mir::visit::MirVisitable>::apply
13: 0x7ffed64d008b - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
14: 0x7ffed64cf6fd - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
15: 0x7ffed64cf6ca - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
16: 0x7ffed64cff82 - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
17: 0x7ffed6518797 - <rustc_middle[3a1ce97b5b0524ba]::ty::generic_args::GenericArg as rustc_middle[3a1ce97b5b0524ba]::ty::context::Lift>::lift_to_tcx
18: 0x7ffed5047713 - <rustc_middle[3a1ce97b5b0524ba]::ty::Ty>::walk
19: 0x7ffed40f6e1f - <rustc_middle[3a1ce97b5b0524ba]::ty::print::pretty::FmtPrinter as rustc_middle[3a1ce97b5b0524ba]::ty::print::Printer>::print_def_path
20: 0x7ffed64a31ab - <rustc_middle[3a1ce97b5b0524ba]::ty::print::pretty::FmtPrinter as rustc_middle[3a1ce97b5b0524ba]::ty::print::pretty::PrettyPrinter>::print_value_path
21: 0x7ffed54e66cb - <rustc_hir_typeck[d09ebf2a634d1509]::coercion::CollectRetsVisitor as rustc_hir[b6886131bf44f6e3]::intravisit::Visitor>::visit_expr
22: 0x7ffed54aa944 - <rustc_hir[b6886131bf44f6e3]::hir_id::HirId as rustc_hir_typeck[d09ebf2a634d1509]::writeback::Locatable>::to_span
23: 0x7ffed5446dd6 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
24: 0x7ffed544d639 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
25: 0x7ffed545a0c0 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::blame_specific_expr_if_possible
26: 0x7ffed430032d - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::check_call
27: 0x7ffed4310d32 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
28: 0x7ffed432d529 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
29: 0x7ffed4312071 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
30: 0x7ffed434a74f - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::check_struct_path
31: 0x7ffed431106a - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
32: 0x7ffed431223e - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
33: 0x7ffed434a896 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::check_struct_path
34: 0x7ffed431106a - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
35: 0x7ffed432d529 - <rustc_hir_typeck[d09ebf2a634d1509]::fn_ctxt::FnCtxt>::demand_eqtype
36: 0x7ffed42f1980 - rustc_hir_typeck[d09ebf2a634d1509]::typeck
37: 0x7ffed42ece2e - rustc_hir_typeck[d09ebf2a634d1509]::typeck
38: 0x7ffed4ad089f - <rustc_query_impl[910689ae0041c04b]::plumbing::QueryCtxt as rustc_query_system[9a9d032e0d04d659]::query::QueryContext>::load_side_effects
39: 0x7ffed4ac943f - rustc_query_impl[910689ae0041c04b]::query_callbacks
40: 0x7ffed4ba49a1 - <rustc_query_impl[910689ae0041c04b]::plumbing::QueryCtxt as rustc_query_system[9a9d032e0d04d659]::query::QueryContext>::load_side_effects
41: 0x7ffed4b45e32 - <rustc_query_impl[910689ae0041c04b]::plumbing::QueryCtxt as rustc_query_system[9a9d032e0d04d659]::query::QueryContext>::load_side_effects
42: 0x7ffed447bc6f - rustc_hir_analysis[dc08ae6b29e9a3a]::check::check::check_abi
43: 0x7ffed3b572ea - rustc_hir_analysis[dc08ae6b29e9a3a]::check_crate
44: 0x7ffed138e807 - rustc_interface[6562ac5350621f0c]::passes::analysis
45: 0x7ffed3dd8c4d - rustc_query_impl[910689ae0041c04b]::profiling_support::alloc_self_profile_query_strings
46: 0x7ffed3e0e239 - rustc_query_impl[910689ae0041c04b]::profiling_support::alloc_self_profile_query_strings
47: 0x7ffed3e398d8 - rustc_query_impl[910689ae0041c04b]::profiling_support::alloc_self_profile_query_strings
48: 0x7ffed3e10f72 - rustc_query_impl[910689ae0041c04b]::profiling_support::alloc_self_profile_query_strings
49: 0x7ffed13406fb - rustc_driver_impl[5927ec3c421e5c5e]::args::arg_expand_all
50: 0x7ffed133f469 - rustc_driver_impl[5927ec3c421e5c5e]::args::arg_expand_all
51: 0x7ffed13584b1 - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
52: 0x7ffed136385f - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
53: 0x7ffed1360bf8 - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
54: 0x7ffef5c8803c - std::sys::pal::windows::thread::Thread::new::h51a32cdc9f29bad5
55: 0x7fff52be7344 - BaseThreadInitThunk
56: 0x7fff53c426b1 - 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
note: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck] type-checking `storage::<impl at src\storage.rs:49:1: 51:25>::get_exact_storage`
#1 [analysis] running analysis passes on this crate
end of query stack