Skip to content

Could not fully normalize <T as Trait>::Assoc #6539

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

Closed
ivan770 opened this issue Jan 3, 2021 · 3 comments · Fixed by #6582
Closed

Could not fully normalize <T as Trait>::Assoc #6539

ivan770 opened this issue Jan 3, 2021 · 3 comments · Fixed by #6582
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ivan770
Copy link

ivan770 commented Jan 3, 2021

Code

I'm not sure about the exact part of code, that leads to ICE.
To reproduce issue, run clippy with unstable-options
https://github.com/ivan770/spartan/tree/fade05f7896c2ecd8413bf20273c4236a7faeb78

Meta

  • cargo clippy -V: clippy 0.0.212 (fde6927 2021-01-02)
  • rustc -Vv:
    rustc 1.51.0-nightly (fde692739 2021-01-02)
    binary: rustc
    commit-hash: fde692739576089729885b7f79aa2232cb9778c5
    commit-date: 2021-01-02
    host: x86_64-unknown-linux-gnu
    release: 1.51.0-nightly
    

Error output

error: internal compiler error: compiler/rustc_traits/src/normalize_erasing_regions.rs:43:32: could not fully normalize `<M as core::payload::identifiable::Identifiable>::Id`

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new

note: Clippy version: clippy 0.0.212 (fde6927 2021-01-02)

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `<M as core::payload::identifiable::Identifiable>::Id`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
Backtrace

stack backtrace:
 0: std::panicking::begin_panic
 1: rustc_errors::HandlerInner::bug
 2: rustc_errors::Handler::bug
 3: rustc_middle::ty::context::tls::with_opt
 4: rustc_middle::util::bug::opt_span_bug_fmt
 5: rustc_middle::util::bug::bug_fmt
 6: rustc_infer::infer::InferCtxtBuilder::enter
 7: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions
 8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
 9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
10: rustc_data_structures::stack::ensure_sufficient_stack
11: rustc_query_system::query::plumbing::get_query_impl
12: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions
13: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
14: <rustc_lint::context::LateContext as rustc_target::abi::LayoutOf>::layout_of
15: <clippy_lints::zero_sized_map_values::ZeroSizedMapValues as rustc_lint::passes::LateLintPass>::check_ty
16: <rustc_lint::late::LateLintPassObjects as rustc_lint::passes::LateLintPass>::check_ty
17: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_ty
18: rustc_hir::intravisit::walk_item
19: rustc_hir::intravisit::Visitor::visit_nested_item
20: rustc_hir::intravisit::walk_mod
21: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
22: rustc_hir::intravisit::walk_item
23: rustc_hir::intravisit::Visitor::visit_nested_item
24: rustc_hir::intravisit::walk_mod
25: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
26: rustc_hir::intravisit::walk_item
27: rustc_hir::intravisit::Visitor::visit_nested_item
28: rustc_hir::intravisit::walk_mod
29: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
30: rustc_hir::intravisit::walk_item
31: rustc_hir::intravisit::Visitor::visit_nested_item
32: rustc_hir::intravisit::walk_mod
33: <rustc_lint::late::LateContextAndPass<T> as rustc_hir::intravisit::Visitor>::visit_mod
34: rustc_hir::intravisit::walk_crate
35: rustc_lint::late::late_lint_pass_crate
36: rustc_session::utils::<impl rustc_session::session::Session>::time
37: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
38: rustc_session::utils::<impl rustc_session::session::Session>::time
39: rustc_interface::passes::analysis
40: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
41: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
43: rustc_data_structures::stack::ensure_sufficient_stack
44: rustc_query_system::query::plumbing::get_query_impl
45: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
46: rustc_span::with_source_map
47: rustc_interface::interface::create_compiler_and_run
48: rustc_span::with_session_globals

@ivan770 ivan770 added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 3, 2021
@giraffate
Copy link
Contributor

Thanks for your report!

I guess it might be related with rust-lang/rust#80045.

@rail-rain
Copy link
Contributor

I have extracted a minimal repro from the original crate:

use std::collections::BTreeMap;
pub trait Identifiable {
    type Id;
}

type _Tree<M> = BTreeMap<(), <M as Identifiable>::Id>;

Playground

This means the underlying cause is that, in zero_sized_map_values, Clippy indirectly calls normalize_erasing_regions; which triggers the panic because that cannot normalize <M as Identifiable>::Id there. This is an expected behaviour since its document states "This is appropriate to use only after type-check: it assumes that normalization will succeed, for example.".

@tdyas
Copy link

tdyas commented Mar 7, 2021

Just wanted to flag that #6840 is an ICE in v1.50.0 related to normalize_generic_arg_after_erasing_regions that is not fixed by the PR linked to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants