-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
I tried this code:
struct Thing;
trait Trait {
type Assoc;
}
impl Trait for Thing {
type Assoc = i32;
}
type Alias1 = i32;
type Alias2 = <Thing as Trait>::Assoc;
fn works<const N: Alias1>() {}
fn fails<const N: Alias2>() {}I expected works and fails to either both compile or both error. Instead, only works compiles:
error: `<Thing as Trait>::Assoc` is forbidden as the type of a const generic parameter
--> src/lib.rs:14:19
|
14 | fn fails<const N: Alias2>() {}
| ^^^^^^
|
= note: the only supported types are integers, `bool`, and `char`
See also #149203
Meta
Reproducible on the playground with version 1.93.0-nightly (2025-11-21 27b076af7e3e7a363975)
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team