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

attributes on const params do not cause an error #78957

Closed
lcnr opened this issue Nov 11, 2020 · 0 comments · Fixed by #79073
Closed

attributes on const params do not cause an error #78957

lcnr opened this issue Nov 11, 2020 · 0 comments · Fixed by #79073
Assignees
Labels
C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]`

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 11, 2020

#![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.

@lcnr lcnr added C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` F-min_const_generics labels Nov 11, 2020
@davidtwco davidtwco self-assigned this Nov 11, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Dec 19, 2020
…ttrs, r=lcnr

passes: prohibit invalid attrs on generic params

Fixes rust-lang#78957.

This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity.

r? `@lcnr`
@bors bors closed this as completed in 3d9ada6 Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants