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

Lint control attributes (allow/deny/etc) have no effect on lifetime and const parameters #61552

Open
petrochenkov opened this issue Jun 5, 2019 · 3 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

fn f<#[allow(warnings)] foo>() {} // warning: type parameter `foo` should have an upper camel case name

Expected behavior - no warning, actual behavior - warning.

cc #61238, which is a similar issue

@jonas-schievink jonas-schievink added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 5, 2019
@Centril Centril added the C-bug Category: This is a bug. label Jun 5, 2019
@istankovic
Copy link
Contributor

Seems to be fixed. Tested with 1.73.

@fmease
Copy link
Member

fmease commented Nov 5, 2024

Seems to be fixed. Tested with 1.73.

Only for type parameters. The issue is still present for lifetime and const parameters, it seems.

Type parameters (works):

//@ check-pass
#![deny(non_camel_case_types)]
struct S<#[allow(non_camel_case_types)] t>(t);

Lifetime parameters (doesn't work):

#![deny(non_snake_case)]
struct Z<#[allow(non_snake_case)] 'A>(&'A ()); //~ ERROR

Const parameters (doesn't work):

#![deny(non_upper_case_globals)]
struct S<#[allow(non_upper_case_globals)] const n: usize>; //~ ERROR

@fmease
Copy link
Member

fmease commented Nov 5, 2024

I did a cursory reading through various parts like <LateContext<'_> as LintContext>::opt_span_lint (...), LateContextAndPass, various visitors, etc. but nothing stood out. It's especially weird that it now works for type params but not for the other two kinds of generic params given the fact that they are unified under {ast,hir}::GenericParam.

@fmease fmease changed the title Lint control attributes (allow/deny/etc) have no effect on generic parameters Lint control attributes (allow/deny/etc) have no effect on lifetime and const parameters Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. 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

5 participants