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: Encountered errors [FulfillmentError(Obligation(predicate=TraitPredicate(<Five as TypeVal<[type error]>>), depth=1),Ambiguity)] resolving bounds after type-checking #77919

Closed
chengniansun opened this issue Oct 13, 2020 · 3 comments · Fixed by #77930
Assignees
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

fn main() {
    [1; <Multiply<Five, Five>>::VAL];
}
trait TypeVal<T> {
    const VAL: T;
}
struct Five;
struct Multiply<N, M> {
    _n: PhantomData,
}
impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (8dae8cdcc 2020-10-12)

binary: rustc

commit-hash: 8dae8cdcc8fa879cea6a4bbbfa5b32e97be4c306

commit-date: 2020-10-12

host: x86_64-unknown-linux-gnu

release: 1.49.0-nightly

LLVM version: 11.0

Error output

error[E0412]: cannot find type `PhantomData` in this scope
 --> reduced_mutant.rs:9:9
  |
9 |     _n: PhantomData,
  |         ^^^^^^^^^^^ not found in this scope
  |
help: consider importing this struct
  |
1 | use std::marker::PhantomData;
  |

error[E0412]: cannot find type `VAL` in this scope
  --> reduced_mutant.rs:11:63
   |
11 | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
   |          -                                                    ^^^ not found in this scope
   |          |
   |          help: you might be missing a type parameter: `, VAL`

error[E0046]: not all trait items implemented, missing: `VAL`
  --> reduced_mutant.rs:11:1
   |
5  |     const VAL: T;
   |     ------------- `VAL` from trait
...
11 | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen/mod.rs:121:9: Encountered errors `[FulfillmentError(Obligation(predicate=TraitPredicate(<Five as TypeVal<[type error]>>), depth=1),Ambiguity)]` resolving bounds after type-checking

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945: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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.49.0-nightly (8dae8cdcc 2020-10-12) running on x86_64-unknown-linux-gnu

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.
Backtrace

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::bug
   2: rustc_errors::Handler::bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::bug_fmt
   8: rustc_trait_selection::traits::codegen::drain_fulfillment_cx_or_panic
   9: rustc_infer::infer::InferCtxtBuilder::enter
  10: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
  11: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::codegen_fulfill_obligation>::compute
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::get_query_impl
  15: rustc_ty::instance::inner_resolve_instance
  16: rustc_ty::instance::resolve_instance
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::resolve_instance>::compute
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_middle::ty::instance::Instance::resolve_opt_const_arg
  22: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  23: rustc_middle::ty::consts::Const::eval
  24: <rustc_infer::infer::at::At as rustc_trait_selection::traits::query::normalize::AtExt>::normalize
  25: rustc_infer::infer::InferCtxtBuilder::enter
  26: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  28: rustc_data_structures::stack::ensure_sufficient_stack
  29: rustc_query_system::query::plumbing::get_query_impl
  30: <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_const
  31: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
  32: rustc_mir::interpret::eval_context::InterpCx<M>::push_stack_frame
  33: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  34: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_allocation_raw>::compute
  35: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_query_system::query::plumbing::get_query_impl
  38: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  39: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  40: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  41: rustc_data_structures::stack::ensure_sufficient_stack
  42: rustc_query_system::query::plumbing::get_query_impl
  43: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  44: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  45: rustc_infer::infer::InferCtxt::const_eval_resolve
  46: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
  47: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations
  48: rustc_data_structures::obligation_forest::ObligationForest<O>::process_obligations
  49: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_where_possible
  50: rustc_typeck::check::fn_ctxt::FnCtxt::select_obligations_where_possible
  51: rustc_infer::infer::InferCtxtBuilder::enter
  52: rustc_typeck::check::typeck
  53: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  54: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  55: rustc_data_structures::stack::ensure_sufficient_stack
  56: rustc_query_system::query::plumbing::get_query_impl
  57: rustc_query_system::query::plumbing::ensure_query_impl
  58: rustc_typeck::check::typeck_item_bodies
  59: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  60: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  61: rustc_data_structures::stack::ensure_sufficient_stack
  62: rustc_query_system::query::plumbing::get_query_impl
  63: rustc_typeck::check_crate
  64: rustc_interface::passes::analysis
  65: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  66: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  67: rustc_data_structures::stack::ensure_sufficient_stack
  68: rustc_query_system::query::plumbing::get_query_impl
  69: rustc_interface::passes::QueryContext::enter
  70: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  71: rustc_span::with_source_map
  72: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

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.49.0-nightly (8dae8cdcc 2020-10-12) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `TypeVal` fulfills its obligations
#1 [resolve_instance] resolving instance `<Multiply<Five, Five> as TypeVal<usize>>::VAL`
#2 [normalize_generic_arg_after_erasing_regions] normalizing `<Multiply<Five, Five> as TypeVal<usize>>::VAL`
#3 [eval_to_allocation_raw] const-evaluating + checking `main::{constant#0}`
#4 [eval_to_const_value_raw] simplifying constant for the type system `main::{constant#0}`
#5 [typeck] type-checking `main`
#6 [typeck_item_bodies] type-checking all item bodies
#7 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0046, E0412.
For more information about an error, try `rustc --explain E0046`.

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

@chengniansun chengniansun 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 Oct 13, 2020
@jyn514 jyn514 added the A-trait-system Area: Trait system label Oct 13, 2020
@camelid camelid added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Oct 13, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 13, 2020
@camelid
Copy link
Member

camelid commented Oct 13, 2020

Regression occurred in Rust 1.36.0 per testing in Godbolt.

@camelid camelid added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Oct 13, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 14, 2020
@tesuji
Copy link
Contributor

tesuji commented Oct 14, 2020

bisection

Regression in nightly-2019-04-24
Range: 6d59933...e938c2b
found 9 bors merge commits in the specified range
commit[0] 2019-04-22UTC: Auto merge of #60168 - varkor:tidy-leading-newline, r=alexcrichton
commit[1] 2019-04-22UTC: Auto merge of #60126 - estebank:continue-eval, r=oli-obk
commit[2] 2019-04-23UTC: Auto merge of #60140 - euclio:pulldown-cmark, r=GuillaumeGomez
commit[3] 2019-04-23UTC: Auto merge of #60121 - davazp:fix-sync-all-macos, r=KodrAus
commit[4] 2019-04-23UTC: Auto merge of #60172 - varkor:tidy-double-trailing-newline, r=kennytm
commit[5] 2019-04-23UTC: Auto merge of #60125 - estebank:continue-evaluating, r=oli-obk
commit[6] 2019-04-23UTC: Auto merge of #60152 - stepnivlk:visit_subpats-removal, r=varkor
commit[7] 2019-04-23UTC: Auto merge of #60155 - davidtwco:issue-59819, r=oli-obk
commit[8] 2019-04-23UTC: Auto merge of #60211 - Centril:rollup-akw4r85, r=Centril


#60126, #60125, #60152 are likely the culprit.

@JohnTitor
Copy link
Member

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@JohnTitor JohnTitor added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Oct 14, 2020
@bors bors closed this as completed in b334eef Oct 25, 2020
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this issue Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

8 participants