Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when using trivial_bounds and an associated type #125394

Closed
CraftSpider opened this issue May 22, 2024 · 2 comments · Fixed by #125416
Closed

ICE when using trivial_bounds and an associated type #125394

CraftSpider opened this issue May 22, 2024 · 2 comments · Fixed by #125416
Assignees
Labels
C-bug Category: This is a bug. F-trivial_bounds `#![feature(trivial_bounds)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-missing_copy_implementations Lint: missing_copy_implementations S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CraftSpider
Copy link
Contributor

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: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxt>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: rustc_trait_selection::traits::misc::all_fields_implement_trait
         4: <rustc_lint::builtin::MissingCopyImplementations as rustc_lint::passes::LateLintPass>::check_item
         5: <rustc_lint::BuiltinCombinedModuleLateLintPass as rustc_lint::passes::LateLintPass>::check_item
         6: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
         7: rustc_lint::lint_mod
         8: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
         9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, 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::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
        15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, 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::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        18: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, 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: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, 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: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                   at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/alloc/src/boxed.rs:2063:9
        21: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::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

@CraftSpider CraftSpider added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 22, 2024
@compiler-errors compiler-errors self-assigned this May 22, 2024
@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue F-trivial_bounds `#![feature(trivial_bounds)]` L-missing_copy_implementations Lint: missing_copy_implementations and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 22, 2024
fmease added a commit to fmease/rust that referenced this issue May 22, 2024
…copy, r=lcnr

Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes rust-lang#125394
fmease added a commit to fmease/rust that referenced this issue May 22, 2024
…copy, r=lcnr

Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes rust-lang#125394
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 23, 2024
…copy, r=lcnr

Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes rust-lang#125394
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 23, 2024
…copy, r=lcnr

Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes rust-lang#125394
@bors bors closed this as completed in e713b2a May 23, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 23, 2024
Rollup merge of rust-lang#125416 - compiler-errors:param-env-missing-copy, r=lcnr

Use correct param-env in `MissingCopyImplementations`

We shouldn't assume the param-env is empty for this lint, since although we check the struct has no parameters, there still may be trivial where-clauses.

fixes rust-lang#125394
@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr reopened this May 23, 2024
@compiler-errors
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-trivial_bounds `#![feature(trivial_bounds)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ L-missing_copy_implementations Lint: missing_copy_implementations S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants