Rollup merge of #110513 - Ezrashaw:fix-trait-const-name-lint, r=compiler-errors
make `non_upper_case_globals` lint not report trait impls We should not lint on trait `impl`s for `non_upper_case_globals`; the user doesn't have control over the name. This brings `non_upper_case_globals` into consistency with other `nonstandard_style` lints.
This commit is contained in:
commit
78490ada7c
3 changed files with 38 additions and 6 deletions
|
@ -494,6 +494,15 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
|
|||
hir::ItemKind::Const(..) => {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "constant", &it.ident);
|
||||
}
|
||||
// we only want to check inherent associated consts, trait consts
|
||||
// are linted at def-site.
|
||||
hir::ItemKind::Impl(hir::Impl { of_trait: None, items, .. }) => {
|
||||
for it in *items {
|
||||
if let hir::AssocItemKind::Const = it.kind {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &it.ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -504,12 +513,6 @@ impl<'tcx> LateLintPass<'tcx> for NonUpperCaseGlobals {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'_>, ii: &hir::ImplItem<'_>) {
|
||||
if let hir::ImplItemKind::Const(..) = ii.kind {
|
||||
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
|
||||
}
|
||||
}
|
||||
|
||||
fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) {
|
||||
// Lint for constants that look like binding identifiers (#7526)
|
||||
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.kind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue