Skip to content

attributes on const params do not cause an error #78957

Closed
@lcnr

Description

@lcnr
#![feature(min_const_generics)]

pub struct Foo<#[inline] const N: usize>;
pub struct Bar<#[cold] const N: usize>;
pub struct Baz<#[repr(C)] const N: usize>;

results in

warning: unused attribute
 --> src/lib.rs:5:16
  |
5 | pub struct Baz<#[repr(C)] const N: usize>;
  |                ^^^^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default

So inline and cold are silently accepted and repr(C) only results in a lint.
All of these cases should error. Fixing this after stabilization would be an - although small - backcompat issue.

Blocking stabilization on this for now.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions