rust-lang / rust

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

ICE when using `trivial_bounds` and an associated type #125394

Closed CraftSpider closed 5 months ago

CraftSpider commented 5 months ago

This appears to be an issue in the MissingCopyImplementations lint, possibly it assuming struct S(<Foo as Bar>::Assoc); can be normalized, when due to the bound and the lack of implementation Bar for Foo, the type is effectively struct S(<Error>);

Code

playground

Meta

rustc --version --verbose: locally

rustc 1.80.0-nightly (791adf759 2024-05-21)
binary: rustc
commit-hash: 791adf759cc065316f054961875052d5bc03e16c
commit-date: 2024-05-21
host: x86_64-pc-windows-msvc
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: couldn't normalize struct field `<Bar as Foo>::Assoc` when checking Copy implementation
  --> src/lib.rs:11:17
   |
11 | pub struct Baz2(<Bar as Foo>::Assoc)
   |                 ^^^^^^^^^^^^^^^^^^^
   |
note: delayed at compiler/rustc_trait_selection/src/traits/misc.rs:177:27 - disabled backtrace
  --> src/lib.rs:11:17
   |
11 | pub struct Baz2(<Bar as Foo>::Assoc)
   |                 ^^^^^^^^^^^^^^^^^^^

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 `/playground/rustc-ice-2024-05-22T05_01_12-24.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack
warning: `playground` (lib) generated 3 warnings
error: could not compile `playground` (lib); 3 warnings emitted
Backtrace

``` note: delayed at compiler/rustc_trait_selection/src/traits/misc.rs:177:27 0: ::emit_diagnostic 1: ::emit_diagnostic 2: ::emit_producing_guarantee 3: rustc_trait_selection::traits::misc::all_fields_implement_trait 4: ::check_item 5: ::check_item 6: as rustc_hir::intravisit::Visitor>::visit_nested_item 7: rustc_lint::lint_mod 8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::> 9: rustc_query_system::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false> 10: rustc_query_impl::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace 11: rustc_lint::late::check_crate::{closure#1} 12: rustc_lint::late::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#1} 18: std::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, 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#1}, 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#2} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 20: as core::ops::function::FnOnce>::call_once at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/alloc/src/boxed.rs:2063:9 21: as core::ops::function::FnOnce>::call_once at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/alloc/src/boxed.rs:2063:9 22: std::sys::pal::unix::thread::Thread::new::thread_start at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/std/src/sys/pal/unix/thread.rs:108:17 23: start_thread 24: clone ```

matthiaskrgr commented 5 months ago

Still crashes with -Clink-dead-code, although the Ice is a bit different.

compiler-errors commented 5 months ago

@matthiaskrgr I would appreciate if you opened a new issue for that, and shared the backtrace, etc there instead.