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

Internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17 #79628

Closed
someguynamedjosh opened this issue Dec 2, 2020 · 3 comments
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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.

Comments

@someguynamedjosh
Copy link

Code

trait Output<'a> {
    type Type;
    fn convert() -> Self::Type;
}

impl<'a> Output<'a> for i32 {
    type Type = i32;
    
    fn convert() -> i32 {
        0
    }
}

struct Wrapper;

impl Wrapper {
    fn do_something_wrapper<O, F>(&mut self, use_output: F)
    where
        O: for<'a> Output<'a>,
        F: for<'a> FnOnce(<O as Output<'a>>::Type)
    {
        let output = <O as Output>::convert();
        use_output(output)
    }
}

fn main() {
    let mut wrapper = Wrapper;
    wrapper.do_something_wrapper::<i32, _>(|value| ());
}

Meta

Using Rust Playground's nightly build:

Nightly channel
Build using the Nightly version: 1.50.0-nightly
(2020-11-30 b7ebc6b0c1ba3c27ebb1)

Error output

   Compiling playground v0.0.1 (/playground)
warning: unused variable: `value`
  --> src/main.rs:29:45
   |
29 |     wrapper.do_something_wrapper::<i32, _>(|value| ());
   |                                             ^^^^^ help: if this is intentional, prefix it with an underscore: `_value`
   |
   = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(<i32 as Output<'_>>::Type,)>>), Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>), Sorts(ExpectedFound { expected: i32, found: <i32 as Output<'_>>::Type }))` selecting `Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>)` during codegen

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.50.0-nightly (b7ebc6b0c 2020-11-30) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::ops::FnOnce` fulfills its obligations
#1 [resolve_instance] resolving instance `<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>::call_once`
end of query stack
error: aborting due to previous error; 1 warning emitted

error: could not compile `playground`

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

(On my own computer with the stable build)

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
   Compiling bug v0.1.0 (/tmp/bug)
warning: unused variable: `value`
  --> src/main.rs:29:45
   |
29 |     wrapper.do_something_wrapper::<i32, _>(|value| ());
   |                                             ^^^^^ help: if this is intentional, prefix it with an underscore: `_value`
   |
   = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler/rustc_trait_selection/src/traits/codegen/mod.rs:75:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(<i32 as Output<'_>>::Type,)>>), Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>), Sorts(ExpectedFound { expected: i32, found: <i32 as Output<'_>>::Type }))` selecting `Binder(<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>)` during codegen

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_infer::infer::InferCtxtBuilder::enter
   9: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
  10: 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
  11: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  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_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::get_query_impl
  22: rustc_middle::ty::instance::Instance::resolve_opt_const_arg
  23: rustc_middle::ty::instance::Instance::resolve
  24: <rustc_mir::monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
  25: rustc_mir::monomorphize::collector::collect_neighbours
  26: rustc_mir::monomorphize::collector::collect_items_rec
  27: rustc_mir::monomorphize::collector::collect_items_rec
  28: rustc_session::utils::<impl rustc_session::session::Session>::time
  29: rustc_mir::monomorphize::collector::collect_crate_mono_items
  30: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  31: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_and_partition_mono_items>::compute
  32: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  33: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  34: rustc_data_structures::stack::ensure_sufficient_stack
  35: rustc_query_system::query::plumbing::get_query_impl
  36: rustc_codegen_ssa::base::codegen_crate
  37: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  38: rustc_session::utils::<impl rustc_session::session::Session>::time
  39: rustc_interface::passes::QueryContext::enter
  40: rustc_interface::queries::Queries::ongoing_codegen
  41: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  42: rustc_span::with_source_map
  43: 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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::ops::FnOnce` fulfills its obligations
#1 [resolve_instance] resolving instance `<[closure@src/main.rs:29:44: 29:54] as std::ops::FnOnce<(i32,)>>::call_once`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error; 1 warning emitted

error: could not compile `bug`

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

@someguynamedjosh someguynamedjosh 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 Dec 2, 2020
@connorskees
Copy link
Contributor

a bit smaller,

trait Output<'a> {
    type Type;
    fn convert() -> Self::Type;
}

impl<'a> Output<'a> for i32 {
    type Type = ();

    fn convert() {}
}

fn do_something<O, F>(use_output: F)
where
    O: for<'a> Output<'a>,
    F: for<'a> FnOnce(<O as Output<'a>>::Type),
{
    use_output(O::convert())
}

fn main() {
    do_something::<i32, _>(|value| ());
}

@jonas-schievink
Copy link
Contributor

(also happens on stable, not a regression)

@someguynamedjosh someguynamedjosh changed the title Internal compiler error on latest nightly Internal compiler error Dec 2, 2020
@camelid camelid changed the title Internal compiler error Internal compiler error: compiler/rustc_trait_selection/src/traits/codegen.rs:78:17 Dec 9, 2020
@camelid camelid added the A-trait-system Area: Trait system label Dec 9, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 12, 2020
@jackh726
Copy link
Member

Closing as duplicate of #62529

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. glacier ICE tracked in rust-lang/glacier. 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.
Projects
None yet
Development

No branches or pull requests

6 participants