Closed
Description
I have encountered an ICE in stable rust, please see the code and error below. The issue seems to be present also on nightly and also older rust compiler versions like 1.45.
Code
trait ColumnOutput<'a, T> {
type Output: Sized;
}
struct C;
impl<'a, T> ColumnOutput<'a, T> for C {
type Output = T;
}
fn calc<'a, T1: Default, T2, O1, O2, F1>(f: F1)
where
O1: ColumnOutput<'a, T1>,
O2: ColumnOutput<'a, T2>,
F1: Fn(&<O2 as ColumnOutput<T2>>::Output) -> T1,
{
let c2_data: Vec<<O2 as ColumnOutput<T2>>::Output> = Vec::new();
let mut dummy: Vec<T1> = Vec::new();
dummy.extend(c2_data.iter().map(|c2_value| f(c2_value)));
}
pub fn run_calc() {
calc::<u64, u64, C, C, _>(|c2_data| *c2_data)
}
fn main() {
run_calc();
}
Meta
The ICE happens also on nightly
rustc --version --verbose
:
<version>
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-pc-windows-msvc
release: 1.48.0
LLVM version: 11.0
Error output
<output>
error: internal compiler error: compiler\rustc_trait_selection\src\traits\codegen\mod.rs:75:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&<operations::generic_functions_3::C as operations::generic_functions_3::ColumnOutput<'_, u64>>::Output,)>>), Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&u64,)>>), Sorts(ExpectedFound { expected: u64, found:
<operations::generic_functions_3::C as operations::generic_functions_3::ColumnOutput<'_, u64>>::Output }))` selecting `Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&u64,)>>)` during codegen
Backtrace
error: internal compiler error: compiler\rustc_trait_selection\src\traits\codegen\mod.rs:75:17: Encountered error `OutputTypeParameterMismatch(Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&<operations::generic_functions_3::C as operations::generic_functions_3::ColumnOutput<'_, u64>>::Output,)>>), Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&u64,)>>), Sorts(ExpectedFound { expected: u64, found:
<operations::generic_functions_3::C as operations::generic_functions_3::ColumnOutput<'_, u64>>::Output }))` selecting `Binder(<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&u64,)>>)` during codegen
thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:945:9
stack backtrace:
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-pc-windows-msvc
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::ops::Fn` fulfills its obligations
#1 [resolve_instance] resolving instance `<[closure@src\operations\generic_functions_3.rs:23:31: 23:49] as std::ops::Fn<(&u64,)>>::call`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
#3 [exported_symbols] exported_symbols
end of query stack
<backtrace>
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Lifetimes / regionsArea: Trait systemCategory: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.