Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BoxyUwU opened this issue Jun 26, 2021 · 2 comments
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints F-const_generics_defaults `#![feature(const_generics_defaults)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 26, 2021

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

@BoxyUwU BoxyUwU added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` F-const_generics_defaults `#![feature(const_generics_defaults)]` labels Jun 26, 2021
@lcnr lcnr removed the F-const_generics `#![feature(const_generics)]` label Jun 28, 2022
@BoxyUwU BoxyUwU added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Jun 28, 2022
@fmease
Copy link
Member

fmease commented Jan 25, 2024

Current output:

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

for

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

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

@fmease
Copy link
Member

fmease commented Jan 25, 2024

I've fixed that a while ago namely in #115744. Closing as fixed.

@fmease fmease closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-diagnostics Area: Messages for errors, warnings, and lints F-const_generics_defaults `#![feature(const_generics_defaults)]` F-generic_const_exprs `#![feature(generic_const_exprs)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants