Skip to content

ICE: expected type differs from actual type u16 / u32 #118778

Open
@matthiaskrgr

Description

@matthiaskrgr

Code

// check-pass

#![feature(generic_const_items, associated_const_equality)]
#![allow(incomplete_features, dead_code)]

trait Owner {
    const K<const N: u16>: u32;
}

impl Owner for () {
    const K<const N: u32>: u32 = N + 1;
}

fn take1(_: impl Owner<K<99> = 100>) {}

fn main() {
    take1(());
}

Meta

rustc --version --verbose:

f967532a47eb728ada44473a5c4c2eca1a45fe30

Error output

error[E0053]: const `K` has an incompatible generic parameter for trait `Owner`
  --> E3C8E80B9F16D249D1078B5DF2852F8E37EB546C642CE235A1E955910CCB2F71.rs:11:13
   |
6  | trait Owner {
   |       -----
7  |     const K<const N: u16>: u32;
   |             ------------ expected const parameter of type `u16`
...
10 | impl Owner for () {
   | -----------------
11 |     const K<const N: u32>: u32 = N + 1;
   |             ^^^^^^^^^^^^ found const parameter of type `u32`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-associated_const_equality`#![feature(associated_const_equality)]`F-generic_const_items`#![feature(generic_const_items)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    Status

    Can Do

    Status

    Can Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions