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 ambiguity selecting Binder(<[type error] as Bar>) during trans, presuming due to overflow #48027

Closed
Badel2 opened this issue Feb 6, 2018 · 3 comments · Fixed by #65395
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Badel2
Copy link
Contributor

Badel2 commented Feb 6, 2018

This code ICEs, both on stable and nightly:

trait Bar {
    const X: usize;
    fn return_n(&self) -> [u8; Bar::X];
}

impl Bar {}

The first error is expected, the second one is a ICE:

error[E0038]: the trait `Bar` cannot be made into an object
 --> ice.rs:6:6
  |
6 | impl Bar {}
  |      ^^^ the trait `Bar` cannot be made into an object
  |
  = note: the trait cannot contain associated consts like `X`

error: internal compiler error: librustc/traits/trans/mod.rs:62: Encountered ambiguity selecting `Binder(<[type error] as Bar>)` during trans, presuming due to overflow

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:535:9
Backtrace

rustc version:

rustc 1.25.0-nightly (6c04c4103 2018-02-05)
binary: rustc
commit-hash: 6c04c41034c46730fba97bfe9cfa2dd0687c2a5f
commit-date: 2018-02-05
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 4.0

Backtrace:

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:535:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:380
   3: std::panicking::default_hook
             at libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:576
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::bug
   7: rustc::session::opt_span_bug_fmt::{{closure}}
   8: rustc::session::opt_span_bug_fmt
   9: rustc::session::bug_fmt
  10: rustc::traits::trans::trans_fulfill_obligation
  11: rustc::dep_graph::graph::DepGraph::with_task_impl
  12: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::force
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::try_get
  14: rustc::ty::maps::TyCtxtAt::trans_fulfill_obligation
  15: rustc::ty::instance::Instance::resolve
  16: rustc_const_eval::eval::lookup_const_by_id
  17: rustc_mir::interpret::const_eval::const_eval_provider
  18: rustc::dep_graph::graph::DepGraph::with_task_impl
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::force
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  21: rustc::ty::maps::TyCtxtAt::const_eval
  22: rustc_const_eval::eval::eval_const_expr_partial
  23: rustc_const_eval::eval::ConstContext::eval
  24: rustc_mir::interpret::const_eval::const_eval_provider
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::force
  27: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  28: rustc::ty::maps::TyCtxtAt::const_eval
  29: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  30: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  31: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  32: rustc::ty::fold::TypeFoldable::fold_with
  33: rustc::infer::InferCtxt::partially_normalize_associated_types_in
  34: rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor::check_associated_item
  35: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_trait_item
  36: rustc_typeck::check_crate::{{closure}}
  37: rustc_typeck::check_crate
  38: rustc::ty::context::TyCtxt::create_and_enter
  39: rustc_driver::driver::compile_input
  40: rustc_driver::run_compiler

@TimNN TimNN added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. labels Feb 6, 2018
@Badel2
Copy link
Contributor Author

Badel2 commented Feb 7, 2018

I thought the impl Bar {} was necessary for the ICE, but other errors like a missing main function also produce it:

trait Bar {
    const X: usize;
    fn return_n(&self) -> [u8; Bar::X];
}

//fn main() {}

Playground link. Uncommenting the main function produces an error, not sure if correct, but doesn't ICE:

error[E0283]: type annotations required: cannot resolve `_: Bar`
 --> src/main.rs:3:32
  |
3 |     fn return_n(&self) -> [u8; Bar::X];
  |                                ^^^^^^
  |
  = note: required by `Bar::X`

@VictorKoenders
Copy link

VictorKoenders commented May 15, 2018

I'm running into a similar issue: playground

For some reason it compiles fine if you remove the Network and Layer struct, even though those are seemingly not related to the error at all.

   Compiling playground v0.0.1 (file:///playground)
error[E0401]: can't use type parameters from outer function
  --> src/main.rs:24:36
   |
22 | impl<TConfig: NodeConfig> NeuralNetwork<TConfig> {
   |      ------- type variable from outer function
23 |     pub fn new(id: u32) -> Self {
   |            --- try adding a local type parameter in this method instead
24 |         const LAYER_COUNT: usize = TConfig::LAYER_DEPTH + 2;
   |                                    ^^^^^^^^^^^^^^^^^^^^ use of type variable from outer function

error: internal compiler error: librustc/traits/trans/mod.rs:63: Encountered ambiguity selecting `Binder(<[type error] as NodeConfig>)` during trans, presuming due to overflow

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0401`.

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.27.0-nightly (ac5c0848d 2018-05-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@JohnTitor
Copy link
Member

Cannot reproduce ICEs with both examples on latest nightly. marked as E-needstest

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 14, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 14, 2019
Add some tests for fixed ICEs

Fixes rust-lang#44153 (from 1.23.0)
Fixes rust-lang#47486 (from 1.36.0)
Fixes rust-lang#48010 (from 1.38.0)
Fixes rust-lang#48027 (from nightly)
Fixes rust-lang#48638 (from nightly)
@bors bors closed this as completed in a73e073 Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants