While working on a const generic shaped grid, I tried code that minimised to this:
#![feature(min_adt_const_params)]
#![feature(generic_const_parameter_types)]
#![allow(incomplete_features)]
trait Trait {
fn method<const A: usize, const B: [usize; A]>();
}
struct Foo;
impl Trait for Foo {
fn method<const A: usize, const B: [usize; A]>() {}
}
I expected this to effectively implement the trait for Foo, but instead, it complained that the impl's const parameter of type [usize; A] did not match the trait's const parameter [usize; A]:
error[E0053]: associated function `method` has an incompatible generic parameter for trait `Trait`
--> minimal.rs:12:31
|
5 | trait Trait {
| -----
6 | fn method<const A: usize, const B: [usize; A]>();
| ------------------- expected const parameter of type `[usize; A]`
...
11 | impl Trait for Foo {
| ------------------
12 | fn method<const A: usize, const B: [usize; A]>() {}
| ^^^^^^^^^^^^^^^^^^^ found const parameter of type `[usize; A]`
I initially asked in Zulip about this in this topic where it was confirmed the issue probably lies at this line where the != is not the appropriate comparison under min_adt_const_params:
|
if match (¶m_impl.kind, ¶m_trait.kind) { |
|
(Const { .. }, Const { .. }) |
|
if tcx.type_of(param_impl.def_id) != tcx.type_of(param_trait.def_id) => |
Meta
rustc --version --verbose:
rustc 1.100.0-nightly (4b6d04e70 2026-09-13)
binary: rustc
commit-hash: 4b6d04e706108ccfeafe2547fbe857dfe8972bad
commit-date: 2026-09-13
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
@rustbot label +F-min_adt_const_params +F-generic_const_parameter_types
While working on a const generic shaped grid, I tried code that minimised to this:
I expected this to effectively implement the trait for
Foo, but instead, it complained that the impl's const parameter of type[usize; A]did not match the trait's const parameter[usize; A]:I initially asked in Zulip about this in this topic where it was confirmed the issue probably lies at this line where the
!=is not the appropriate comparison undermin_adt_const_params:rust/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Lines 2084 to 2086 in 4b6d04e
Meta
rustc --version --verbose:@rustbot label +F-min_adt_const_params +F-generic_const_parameter_types