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

rustc::traits::trans OutputTypeParameterMismatch ICE with higher-rank trait bounds and associated type #50886

Closed
jturner314 opened this issue May 19, 2018 · 2 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jturner314
Copy link
Contributor

jturner314 commented May 19, 2018

Given this code:

pub struct Struct {}

pub trait Trait<'a> {
    type Assoc;

    fn method() -> Self::Assoc;
}

impl<'a> Trait<'a> for Struct {
    type Assoc = ();

    fn method() -> Self::Assoc {}
}

pub fn function<F, T>(f: F)
where
    F: for<'a> FnOnce(<T as Trait<'a>>::Assoc),
    T: for<'b> Trait<'b>,
{
    f(T::method());
}

fn main() {
    function::<_, Struct>(|_| {});
}

(Playground)

Trying to build results in an internal compiler error:

   Compiling playground v0.0.1 (file:///playground)
error: internal compiler error: librustc/traits/trans/mod.rs:68: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<(<Struct as Trait<'_>>::Assoc,)>>), Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<((),)>>), Sorts(ExpectedFound { expected: (), found: <Struct as Trait<'_>>::Assoc }))` selecting `Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<((),)>>)` during trans

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


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.26.0 (a77568041 2018-05-07) 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.

Note that cargo check finishes without errors; it's only when building that the ICE occurs.

Meta

On my machine, rustc --version --verbose:

rustc 1.26.0 (a77568041 2018-05-07)
binary: rustc
commit-hash: a7756804103447ea4e68a71ccf071e7ad8f7a03e
commit-date: 2018-05-07
host: x86_64-unknown-linux-gnu
release: 1.26.0
LLVM version: 6.0

On the playground, the ICE occurs on stable, beta, and nightly channels in both debug and release mode.

Backtrace generated by running RUST_BACKTRACE=1 cargo build on my machine:

error: internal compiler error: librustc/traits/trans/mod.rs:68: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<(<Struct as Trait<'_>>::Assoc,)>>), Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<((),)>>), Sorts(ExpectedFound { expected: (), found: <Struct as Trait<'_>>::Assoc }))` selecting `Binder(<[closure@src/main.rs:24:27: 24:33] as std::ops::FnOnce<((),)>>)` during trans

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543: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
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:207
   3: std::panicking::default_hook
             at libstd/panicking.rs:223
   4: core::ops::function::Fn::call
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:403
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: <std::thread::local::LocalKey<T>>::try_with
  11: <std::thread::local::LocalKey<T>>::with
  12: rustc::ty::context::tls::with
  13: rustc::ty::context::tls::with_opt
  14: rustc::session::opt_span_bug_fmt
  15: rustc::session::bug_fmt
  16: <std::thread::local::LocalKey<T>>::with
  17: rustc::ty::context::GlobalCtxt::enter_local
  18: rustc::traits::trans::trans_fulfill_obligation
  19: rustc::dep_graph::graph::DepGraph::with_task_impl
  20: rustc_errors::Handler::track_diagnostics
  21: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::force
  23: rustc::ty::maps::<impl rustc::ty::maps::queries::trans_fulfill_obligation<'tcx>>::try_get
  24: rustc::ty::maps::TyCtxtAt::trans_fulfill_obligation
  25: rustc::ty::instance::Instance::resolve
  26: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_mir::monomorphize::collector::collect_crate_mono_items
  30: rustc::util::common::time
  31: rustc_trans::base::collect_and_partition_translation_items
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
  33: rustc_errors::Handler::track_diagnostics
  34: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  35: rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::force
  36: rustc::ty::maps::<impl rustc::ty::maps::queries::collect_and_partition_translation_items<'tcx>>::try_get
  37: rustc::ty::maps::TyCtxtAt::collect_and_partition_translation_items
  38: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::collect_and_partition_translation_items
  39: rustc_trans::base::trans_crate
  40: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  41: rustc::util::common::time
  42: rustc_driver::driver::phase_4_translate_to_llvm
  43: rustc_driver::driver::compile_input::{{closure}}
  44: <std::thread::local::LocalKey<T>>::with
  45: <std::thread::local::LocalKey<T>>::with
  46: rustc::ty::context::TyCtxt::create_and_enter
  47: rustc_driver::driver::compile_input
  48: rustc_driver::run_compiler_impl
  49: syntax::with_globals
error: aborting due to previous error
@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 19, 2018
@jturner314
Copy link
Contributor Author

On further investigation, this looks closely related to #33364 and #34430, if not a duplicate.

@XAMPPRocky XAMPPRocky added A-trait-system Area: Trait system C-bug Category: This is a bug. labels Oct 2, 2018
@pnkfelix pnkfelix changed the title ICE with higher-rank trait bounds and associated type rustc::traits::trans ICE with higher-rank trait bounds and associated type Jul 9, 2019
@pnkfelix pnkfelix changed the title rustc::traits::trans ICE with higher-rank trait bounds and associated type rustc::traits::trans OutputTypeParameterMismatch ICE with higher-rank trait bounds and associated type Jul 9, 2019
@pnkfelix
Copy link
Member

closing as duplicate of #62529, which is where I will try to track future instances of this field of ICE.

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants