Skip to content

adt_const_params feature gate error leaks {type error} (TyKind::Error) #118179

Closed
@fmease

Description

@fmease

The following code

struct G<T, const N: Vec<T>>(T);
fn main() {}

currently yields

error[E0770]: the type of const parameters must not depend on other generic parameters
 --> src/lib.rs:1:26
  |
1 | struct G<T, const N: Vec<T>>(T);
  |                          ^ the type must not depend on the parameter `T`
  |
  = note: type parameters may not be used in the type of const parameters

error: `Vec<{type error}, {type error}>` is forbidden as the type of a const generic parameter
 --> src/lib.rs:1:22
  |
1 | struct G<T, const N: Vec<T>>(T);
  |                      ^^^^^^
  |
  = note: the only supported types are integers, `bool` and `char`
  = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types

Ideally, we would replace the {type error} with _ or prevent the second error from being be emitted (this can be achieved by bailing out early if the relevant type .references_errors()).

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.D-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions