rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.33k stars 12.72k forks source link

ICE: `missing value for assoc item in impl` #120343

Closed matthiaskrgr closed 9 months ago

matthiaskrgr commented 9 months ago

auto-reduced (treereduce-rust):

trait ToUnit<'a> {
    type Unit;
}

impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T {}

trait Overlap<T> {}

type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;

impl<T> Overlap<T> for T {}

impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T {}

original:

trait ToUnit<'a> {
    type Unit;
}

struct LocalTy;
impl<'a> ToUnit<'a> for *const LocalTy {}

impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T {}

trait Overlap<T> {}

type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;

impl<T> Overlap<T> for T {}

impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T where for<'a> *const T: Overlap<T> {}

Version information

rustc 1.77.0-nightly (5bd5d214e 2024-01-25)
binary: rustc
commit-hash: 5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c
commit-date: 2024-01-25
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command: /home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib -Znext-solver=coherence

Program output

``` WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: Alias(Projection, AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:18 ~ mvce[dd88]::{impl#2}::'a), 'a) })], def_id: DefId(0:5 ~ mvce[dd88]::ToUnit::Unit) }) note: no errors encountered even though `span_delayed_bug` issued note: those delayed bugs will now be shown as internal compiler errors error: internal compiler error: missing value for assoc item in impl --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ | note: delayed at compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs:198:38 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::consider_impl_candidate::{closure#0}::{closure#2} 4: ::consider_impl_candidate 5: ::assemble_candidates_via_self_ty:: 6: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3} 7: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}> 8: ::evaluate_goal 9: ::try_evaluate_added_goals 10: ::try_normalize_ty_recur 11: ::try_normalize_term 12: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3} 13: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}> 14: ::evaluate_goal 15: ::evaluate_root_goal 16: ::select_where_possible 17: ::evaluate_obligation 18: rustc_trait_selection::traits::coherence::overlap 19: ::insert 20: ::insert 21: rustc_trait_selection::traits::specialize::specialization_graph_provider 22: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 23: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 24: rustc_query_impl::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace 25: rustc_hir_analysis::coherence::coherent_trait 26: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 27: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 28: rustc_query_impl::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace 29: rustc_hir_analysis::check_crate 30: rustc_interface::passes::analysis 31: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 32: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 33: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 34: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0} 35: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 36: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 37: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 38: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 39: std::sys::pal::unix::thread::Thread::new::thread_start at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/std/src/sys/pal/unix/thread.rs:108:17 40: 41: --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ error: internal compiler error: missing value for assoc item in impl --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ | note: delayed at compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs:198:38 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::consider_impl_candidate::{closure#0}::{closure#2} 4: ::consider_impl_candidate 5: ::assemble_candidates_via_self_ty:: 6: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3} 7: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}> 8: ::evaluate_goal 9: ::try_evaluate_added_goals 10: ::try_normalize_ty_recur 11: ::try_normalize_term 12: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3} 13: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}> 14: ::evaluate_goal 15: ::evaluate_root_goal 16: rustc_trait_selection::traits::coherence::overlap 17: ::insert 18: ::insert 19: rustc_trait_selection::traits::specialize::specialization_graph_provider 20: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 21: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 22: rustc_query_impl::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace 23: rustc_hir_analysis::coherence::coherent_trait 24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 25: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 26: rustc_query_impl::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace 27: rustc_hir_analysis::check_crate 28: rustc_interface::passes::analysis 29: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 30: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 31: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 32: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0} 33: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 34: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 35: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 36: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 37: std::sys::pal::unix::thread::Thread::new::thread_start at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/std/src/sys/pal/unix/thread.rs:108:17 38: 39: --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ error: internal compiler error: missing value for assoc item in impl --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ | note: delayed at compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs:198:38 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: ::consider_impl_candidate::{closure#0}::{closure#2} 4: ::consider_impl_candidate 5: ::assemble_candidates_via_self_ty:: 6: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#3} 7: ::with_new_goal::<::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}> 8: ::evaluate_goal 9: ::evaluate_root_goal 10: ::visit_goal 11: rustc_trait_selection::traits::coherence::overlap 12: ::insert 13: ::insert 14: rustc_trait_selection::traits::specialize::specialization_graph_provider 15: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 16: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 17: rustc_query_impl::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace 18: rustc_hir_analysis::coherence::coherent_trait 19: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 20: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 21: rustc_query_impl::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace 22: rustc_hir_analysis::check_crate 23: rustc_interface::passes::analysis 24: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 25: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 26: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 27: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0} 28: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 29: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 30: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 31: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 32: std::sys::pal::unix::thread::Thread::new::thread_start at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/std/src/sys/pal/unix/thread.rs:108:17 33: 34: --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:2:5 | 2 | type Unit; | ^^^^^^^^^ error: internal compiler error[E0119]: conflicting implementations of trait `Overlap fn(&'a (), {type error})>` for type `for<'a> fn(&'a (), {type error})` --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:13:1 | 11 | impl Overlap for T {} | ------------------------ first implementation here 12 | 13 | impl Overlap fn(&'a (), Assoc<'a, T>)> for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a> fn(&'a (), {type error})` | = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details note: delayed at compiler/rustc_trait_selection/src/traits/specialize/mod.rs:451:41 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: rustc_trait_selection::traits::specialize::report_overlap_conflict 4: rustc_trait_selection::traits::specialize::specialization_graph_provider 5: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 6: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 7: rustc_query_impl::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace 8: rustc_hir_analysis::coherence::coherent_trait 9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 10: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 11: rustc_query_impl::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace 12: rustc_hir_analysis::check_crate 13: rustc_interface::passes::analysis 14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 15: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 16: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 17: rustc_interface::interface::run_compiler::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0} 18: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>> 19: <::spawn_unchecked_, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 20: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 21: as core::ops::function::FnOnce>::call_once at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/alloc/src/boxed.rs:2016:9 22: std::sys::pal::unix::thread::Thread::new::thread_start at /rustc/5bd5d214effd494f4bafb29b3a7a2f6c2070ca5c/library/std/src/sys/pal/unix/thread.rs:108:17 23: 24: --> /tmp/icemaker_global_tempdir.M7BqUXYU3OH4/rustc_testrunner_tmpdir_reporting.XOmc9iO39P3N/mvce.rs:13:1 | 13 | impl Overlap fn(&'a (), Assoc<'a, T>)> for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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.0-nightly (5bd5d214e 2024-01-25) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -Z next-solver=coherence -Z dump-mir-dir=dir query stack during panic: end of query stack ```

matthiaskrgr commented 9 months ago

https://github.com/rust-lang/rust/pull/119895 cc @oli-obk