Skip to content

iffy diagnostics for struct defined in a const generic default that uses generics from outer struct #86651

Closed
@BoxyUwU

Description

@BoxyUwU

Given the following code: link

#![feature(const_generics, const_generics_defaults)]
#![allow(incomplete_features)]

struct Foo<const N: usize, const M: usize = { struct Bar<const L: usize = N>; N }>;

The current output is:

error[E0401]: can't use generic parameters from outer function
 --> src/lib.rs:4:75
  |
4 | struct Foo<const N: usize, const M: usize = { struct Bar<const L: usize = N>; N }>;
  |                  - const parameter from outer function                    ^ use of generic parameter from outer function

Ideally the output should shouldn't talk about functions but struct definitions instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsF-const_generics_defaults`#![feature(const_generics_defaults)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`T-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