Skip to content

E0053: const parameters under generic_const_parameter_types rejected when identical #162897

Description

@HaineSensei

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 (&param_impl.kind, &param_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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-adt_const_params`#![feature(adt_const_params)]`F-generic_const_parameter_types`#![feature(generic_const_parameter_types)]`needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions