improve non_snake_case diagnostics

Use a structured suggestion and tighten the span to just the identifier.
This commit is contained in:
Andy Russell 2019-01-04 10:19:52 -05:00
parent 3dfe36d094
commit 7c0d145ec1
No known key found for this signature in database
GPG key ID: BE2221033EDBC374
25 changed files with 191 additions and 179 deletions

View file

@ -7,7 +7,8 @@
use lint::{EarlyLintPass, LintPass, LateLintPass};
use syntax::ast;
use syntax::attr;
use syntax_pos::Span;
use syntax::errors::Applicability;
use syntax_pos::{BytePos, symbol::Ident, Span};
#[derive(PartialEq)]
pub enum MethodLateContext {
@ -179,7 +180,8 @@ fn to_snake_case(mut str: &str) -> String {
words.join("_")
}
fn check_snake_case(&self, cx: &LateContext, sort: &str, name: &str, span: Option<Span>) {
/// Checks if a given identifier is snake case, and reports a diagnostic if not.
fn check_snake_case(&self, cx: &LateContext, sort: &str, ident: &Ident) {
fn is_snake_case(ident: &str) -> bool {
if ident.is_empty() {
return true;
@ -201,20 +203,28 @@ fn is_snake_case(ident: &str) -> bool {
})
}
let name = &ident.name.as_str();
if !is_snake_case(name) {
let sc = NonSnakeCase::to_snake_case(name);
let msg = if sc != name {
format!("{} `{}` should have a snake case name such as `{}`",
sort,
name,
sc)
let msg = format!("{} `{}` should have a snake case name", sort, name);
let mut err = cx.struct_span_lint(NON_SNAKE_CASE, ident.span, &msg);
// We have a valid span in almost all cases, but we don't have one when linting a crate
// name provided via the command line.
if !ident.span.is_dummy() {
err.span_suggestion_with_applicability(
ident.span,
"convert the identifier to snake case",
sc,
Applicability::MaybeIncorrect,
);
} else {
format!("{} `{}` should have a snake case name", sort, name)
};
match span {
Some(span) => cx.span_lint(NON_SNAKE_CASE, span, &msg),
None => cx.lint(NON_SNAKE_CASE, &msg),
err.help(&format!("convert the identifier to snake case: `{}`", sc));
}
err.emit();
}
}
}
@ -227,50 +237,75 @@ fn get_lints(&self) -> LintArray {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) {
let attr_crate_name = attr::find_by_name(&cr.attrs, "crate_name")
.and_then(|at| at.value_str().map(|s| (at, s)));
if let Some(ref name) = cx.tcx.sess.opts.crate_name {
self.check_snake_case(cx, "crate", name, None);
} else if let Some((attr, name)) = attr_crate_name {
self.check_snake_case(cx, "crate", &name.as_str(), Some(attr.span));
let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
Some(Ident::from_str(name))
} else {
attr::find_by_name(&cr.attrs, "crate_name")
.and_then(|attr| attr.meta())
.and_then(|meta| {
meta.name_value_literal().and_then(|lit| {
if let ast::LitKind::Str(name, ..) = lit.node {
// Discard the double quotes surrounding the literal.
let sp = cx.sess().source_map().span_to_snippet(lit.span)
.ok()
.and_then(|snippet| {
let left = snippet.find('"')?;
let right = snippet.rfind('"').map(|pos| snippet.len() - pos)?;
Some(
lit.span
.with_lo(lit.span.lo() + BytePos(left as u32 + 1))
.with_hi(lit.span.hi() - BytePos(right as u32)),
)
})
.unwrap_or_else(|| lit.span);
Some(Ident::new(name, sp))
} else {
None
}
})
})
};
if let Some(ident) = &crate_ident {
self.check_snake_case(cx, "crate", ident);
}
}
fn check_generic_param(&mut self, cx: &LateContext, param: &hir::GenericParam) {
match param.kind {
GenericParamKind::Lifetime { .. } => {
let name = param.name.ident().as_str();
self.check_snake_case(cx, "lifetime", &name, Some(param.span));
}
GenericParamKind::Type { .. } => {}
if let GenericParamKind::Lifetime { .. } = param.kind {
self.check_snake_case(cx, "lifetime", &param.name.ident());
}
}
fn check_fn(&mut self,
cx: &LateContext,
fk: FnKind,
_: &hir::FnDecl,
_: &hir::Body,
span: Span,
id: ast::NodeId) {
match fk {
FnKind::Method(name, ..) => {
fn check_fn(
&mut self,
cx: &LateContext,
fk: FnKind,
_: &hir::FnDecl,
_: &hir::Body,
_: Span,
id: ast::NodeId,
) {
match &fk {
FnKind::Method(ident, ..) => {
match method_context(cx, id) {
MethodLateContext::PlainImpl => {
self.check_snake_case(cx, "method", &name.as_str(), Some(span))
self.check_snake_case(cx, "method", ident);
}
MethodLateContext::TraitAutoImpl => {
self.check_snake_case(cx, "trait method", &name.as_str(), Some(span))
self.check_snake_case(cx, "trait method", ident);
}
_ => (),
}
}
FnKind::ItemFn(name, _, header, _, attrs) => {
FnKind::ItemFn(ident, _, header, _, attrs) => {
// Skip foreign-ABI #[no_mangle] functions (Issue #31924)
if header.abi != Abi::Rust && attr::find_by_name(attrs, "no_mangle").is_some() {
if header.abi != Abi::Rust && attr::contains_name(attrs, "no_mangle") {
return;
}
self.check_snake_case(cx, "function", &name.as_str(), Some(span))
self.check_snake_case(cx, "function", ident);
}
FnKind::Closure(_) => (),
}
@ -278,36 +313,35 @@ fn check_fn(&mut self,
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
if let hir::ItemKind::Mod(_) = it.node {
self.check_snake_case(cx, "module", &it.ident.as_str(), Some(it.span));
self.check_snake_case(cx, "module", &it.ident);
}
}
fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(ref pnames)) = item.node {
self.check_snake_case(cx,
"trait method",
&item.ident.as_str(),
Some(item.span));
if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node {
self.check_snake_case(cx, "trait method", &item.ident);
for param_name in pnames {
self.check_snake_case(cx, "variable", &param_name.as_str(), Some(param_name.span));
self.check_snake_case(cx, "variable", param_name);
}
}
}
fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
if let &PatKind::Binding(_, _, ref ident, _) = &p.node {
self.check_snake_case(cx, "variable", &ident.as_str(), Some(p.span));
if let &PatKind::Binding(_, _, ident, _) = &p.node {
self.check_snake_case(cx, "variable", &ident);
}
}
fn check_struct_def(&mut self,
cx: &LateContext,
s: &hir::VariantData,
_: ast::Name,
_: &hir::Generics,
_: ast::NodeId) {
fn check_struct_def(
&mut self,
cx: &LateContext,
s: &hir::VariantData,
_: ast::Name,
_: &hir::Generics,
_: ast::NodeId,
) {
for sf in s.fields() {
self.check_snake_case(cx, "structure field", &sf.ident.as_str(), Some(sf.span));
self.check_snake_case(cx, "structure field", &sf.ident);
}
}
}

View file

@ -117,16 +117,18 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
));
}
});
let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!(
"__register_diagnostic_{}", code
)));
let span = span.apply_mark(ecx.current_expansion.mark);
let sym = Ident::new(Symbol::gensym(&format!("__register_diagnostic_{}", code)), span);
MacEager::items(smallvec![
ecx.item_mod(
span,
span,
sym,
Vec::new(),
Vec::new()
vec![],
vec![],
)
])
}

View file

@ -1,8 +1,8 @@
error: function `BOGUS` should have a snake case name such as `bogus`
--> $DIR/enable-unstable-lib-feature.rs:12:1
error: function `BOGUS` should have a snake case name
--> $DIR/enable-unstable-lib-feature.rs:12:8
|
LL | pub fn BOGUS() { } //~ ERROR
| ^^^^^^^^^^^^^^^^^^
| ^^^^^ help: convert the identifier to snake case: `bogus`
|
note: lint level defined here
--> $DIR/enable-unstable-lib-feature.rs:6:9

View file

@ -1,8 +1,8 @@
error: variable `X` should have a snake case name such as `x`
error: variable `X` should have a snake case name
--> $DIR/expr_attr_paren_order.rs:19:17
|
LL | let X = 0; //~ ERROR snake case name
| ^
| ^ help: convert the identifier to snake case: `x`
|
note: lint level defined here
--> $DIR/expr_attr_paren_order.rs:17:17

View file

@ -1,8 +1,8 @@
error: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
error: variable `_InappropriateCamelCasing` should have a snake case name
--> $DIR/command-line-lint-group-deny.rs:4:9
|
LL | let _InappropriateCamelCasing = true; //~ ERROR should have a snake
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-D non-snake-case` implied by `-D bad-style`

View file

@ -1,8 +1,8 @@
error: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
error: variable `_InappropriateCamelCasing` should have a snake case name
--> $DIR/command-line-lint-group-forbid.rs:4:9
|
LL | let _InappropriateCamelCasing = true; //~ ERROR should have a snake
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-F non-snake-case` implied by `-F bad-style`

View file

@ -1,8 +1,8 @@
warning: variable `_InappropriateCamelCasing` should have a snake case name such as `_inappropriate_camel_casing`
warning: variable `_InappropriateCamelCasing` should have a snake case name
--> $DIR/command-line-lint-group-warn.rs:5:9
|
LL | let _InappropriateCamelCasing = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-W non-snake-case` implied by `-W bad-style`

View file

@ -11,11 +11,11 @@ LL | #![warn(nonstandard_style)]
| ^^^^^^^^^^^^^^^^^
= note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)]
error: function `CamelCase` should have a snake case name such as `camel_case`
--> $DIR/lint-group-nonstandard-style.rs:4:1
error: function `CamelCase` should have a snake case name
--> $DIR/lint-group-nonstandard-style.rs:4:4
|
LL | fn CamelCase() {} //~ ERROR should have a snake
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
|
note: lint level defined here
--> $DIR/lint-group-nonstandard-style.rs:1:9
@ -24,11 +24,11 @@ LL | #![deny(nonstandard_style)]
| ^^^^^^^^^^^^^^^^^
= note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)]
error: function `CamelCase` should have a snake case name such as `camel_case`
--> $DIR/lint-group-nonstandard-style.rs:12:9
error: function `CamelCase` should have a snake case name
--> $DIR/lint-group-nonstandard-style.rs:12:12
|
LL | fn CamelCase() {} //~ ERROR should have a snake
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
|
note: lint level defined here
--> $DIR/lint-group-nonstandard-style.rs:10:14
@ -50,11 +50,11 @@ LL | #[forbid(nonstandard_style)]
| ^^^^^^^^^^^^^^^^^
= note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)]
warning: function `CamelCase` should have a snake case name such as `camel_case`
--> $DIR/lint-group-nonstandard-style.rs:20:9
warning: function `CamelCase` should have a snake case name
--> $DIR/lint-group-nonstandard-style.rs:20:12
|
LL | fn CamelCase() {} //~ WARN should have a snake
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ help: convert the identifier to snake case: `camel_case`
|
note: lint level defined here
--> $DIR/lint-group-nonstandard-style.rs:18:17

View file

@ -1,5 +1,5 @@
// compile-flags: --crate-name NonSnakeCase
// error-pattern: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
// error-pattern: crate `NonSnakeCase` should have a snake case name
#![deny(non_snake_case)]

View file

@ -1,10 +1,11 @@
error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
error: crate `NonSnakeCase` should have a snake case name
|
note: lint level defined here
--> $DIR/lint-non-snake-case-crate-2.rs:4:9
|
LL | #![deny(non_snake_case)]
| ^^^^^^^^^^^^^^
= help: convert the identifier to snake case: `non_snake_case`
error: aborting due to previous error

View file

@ -1,5 +1,5 @@
#![crate_name = "NonSnakeCase"]
//~^ ERROR crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
//~^ ERROR crate `NonSnakeCase` should have a snake case name
#![deny(non_snake_case)]
fn main() {}

View file

@ -1,8 +1,8 @@
error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case`
--> $DIR/lint-non-snake-case-crate.rs:1:1
error: crate `NonSnakeCase` should have a snake case name
--> $DIR/lint-non-snake-case-crate.rs:1:18
|
LL | #![crate_name = "NonSnakeCase"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^ help: convert the identifier to snake case: `non_snake_case`
|
note: lint level defined here
--> $DIR/lint-non-snake-case-crate.rs:3:9

View file

@ -5,28 +5,28 @@
impl Foo {
fn Foo_Method() {}
//~^ ERROR method `Foo_Method` should have a snake case name such as `foo_method`
//~^ ERROR method `Foo_Method` should have a snake case name
// Don't allow two underscores in a row
fn foo__method(&self) {}
//~^ ERROR method `foo__method` should have a snake case name such as `foo_method`
//~^ ERROR method `foo__method` should have a snake case name
pub fn xyZ(&mut self) {}
//~^ ERROR method `xyZ` should have a snake case name such as `xy_z`
//~^ ERROR method `xyZ` should have a snake case name
fn render_HTML() {}
//~^ ERROR method `render_HTML` should have a snake case name such as `render_html`
//~^ ERROR method `render_HTML` should have a snake case name
}
trait X {
fn ABC();
//~^ ERROR trait method `ABC` should have a snake case name such as `abc`
//~^ ERROR trait method `ABC` should have a snake case name
fn a_b_C(&self) {}
//~^ ERROR trait method `a_b_C` should have a snake case name such as `a_b_c`
//~^ ERROR trait method `a_b_C` should have a snake case name
fn something__else(&mut self);
//~^ ERROR trait method `something__else` should have a snake case name such as `something_else`
//~^ ERROR trait method `something__else` should have a snake case name
}
impl X for Foo {
@ -36,9 +36,9 @@ fn something__else(&mut self) {}
}
fn Cookie() {}
//~^ ERROR function `Cookie` should have a snake case name such as `cookie`
//~^ ERROR function `Cookie` should have a snake case name
pub fn bi_S_Cuit() {}
//~^ ERROR function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit`
//~^ ERROR function `bi_S_Cuit` should have a snake case name
fn main() { }

View file

@ -1,8 +1,8 @@
error: method `Foo_Method` should have a snake case name such as `foo_method`
--> $DIR/lint-non-snake-case-functions.rs:7:5
error: method `Foo_Method` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:7:8
|
LL | fn Foo_Method() {}
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
|
note: lint level defined here
--> $DIR/lint-non-snake-case-functions.rs:1:9
@ -10,53 +10,53 @@ note: lint level defined here
LL | #![deny(non_snake_case)]
| ^^^^^^^^^^^^^^
error: method `foo__method` should have a snake case name such as `foo_method`
--> $DIR/lint-non-snake-case-functions.rs:11:5
error: method `foo__method` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:11:8
|
LL | fn foo__method(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^ help: convert the identifier to snake case: `foo_method`
error: method `xyZ` should have a snake case name such as `xy_z`
--> $DIR/lint-non-snake-case-functions.rs:14:5
error: method `xyZ` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:14:12
|
LL | pub fn xyZ(&mut self) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^ help: convert the identifier to snake case: `xy_z`
error: method `render_HTML` should have a snake case name such as `render_html`
--> $DIR/lint-non-snake-case-functions.rs:17:5
error: method `render_HTML` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:17:8
|
LL | fn render_HTML() {}
| ^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^ help: convert the identifier to snake case: `render_html`
error: trait method `ABC` should have a snake case name such as `abc`
--> $DIR/lint-non-snake-case-functions.rs:22:5
error: trait method `ABC` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:22:8
|
LL | fn ABC();
| ^^^^^^^^^
| ^^^ help: convert the identifier to snake case: `abc`
error: trait method `a_b_C` should have a snake case name such as `a_b_c`
--> $DIR/lint-non-snake-case-functions.rs:25:5
error: trait method `a_b_C` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:25:8
|
LL | fn a_b_C(&self) {}
| ^^^^^^^^^^^^^^^^^^
| ^^^^^ help: convert the identifier to snake case: `a_b_c`
error: trait method `something__else` should have a snake case name such as `something_else`
--> $DIR/lint-non-snake-case-functions.rs:28:5
error: trait method `something__else` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:28:8
|
LL | fn something__else(&mut self);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `something_else`
error: function `Cookie` should have a snake case name such as `cookie`
--> $DIR/lint-non-snake-case-functions.rs:38:1
error: function `Cookie` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:38:4
|
LL | fn Cookie() {}
| ^^^^^^^^^^^^^^
| ^^^^^^ help: convert the identifier to snake case: `cookie`
error: function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit`
--> $DIR/lint-non-snake-case-functions.rs:41:1
error: function `bi_S_Cuit` should have a snake case name
--> $DIR/lint-non-snake-case-functions.rs:41:8
|
LL | pub fn bi_S_Cuit() {}
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ help: convert the identifier to snake case: `bi_s_cuit`
error: aborting due to 9 previous errors

View file

@ -1,7 +1,7 @@
#![deny(non_snake_case)]
#![allow(dead_code)]
fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar`
fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name
_: &'FooBar ()
) {}

View file

@ -1,8 +1,8 @@
error: lifetime `'FooBar` should have a snake case name such as `'foo_bar`
error: lifetime `'FooBar` should have a snake case name
--> $DIR/lint-non-snake-case-lifetimes.rs:4:6
|
LL | fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar`
| ^^^^^^^
LL | fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name
| ^^^^^^^ help: convert the identifier to snake case: `'foo_bar`
|
note: lint level defined here
--> $DIR/lint-non-snake-case-lifetimes.rs:1:9

View file

@ -1,7 +1,7 @@
#![deny(non_snake_case)]
#![allow(dead_code)]
mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar`
mod FooBar { //~ ERROR module `FooBar` should have a snake case name
pub struct S;
}

View file

@ -1,10 +1,8 @@
error: module `FooBar` should have a snake case name such as `foo_bar`
--> $DIR/lint-non-snake-case-modules.rs:4:1
error: module `FooBar` should have a snake case name
--> $DIR/lint-non-snake-case-modules.rs:4:5
|
LL | / mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar`
LL | | pub struct S;
LL | | }
| |_^
LL | mod FooBar { //~ ERROR module `FooBar` should have a snake case name
| ^^^^^^ help: convert the identifier to snake case: `foo_bar`
|
note: lint level defined here
--> $DIR/lint-non-snake-case-modules.rs:1:9

View file

@ -1,3 +1,5 @@
// compile-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616

View file

@ -7,20 +7,20 @@ pub enum Foo { Foo }
}
struct Something {
X: usize //~ ERROR structure field `X` should have a snake case name such as `x`
X: usize //~ ERROR structure field `X` should have a snake case name
}
fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx`
fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name
println!("{}", Xx);
}
fn main() {
let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name
println!("{}", Test);
match foo::Foo::Foo {
Foo => {}
//~^ ERROR variable `Foo` should have a snake case name such as `foo`
//~^ ERROR variable `Foo` should have a snake case name
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
//~^^^ WARN unused variable: `Foo`
}

View file

@ -17,11 +17,11 @@ LL | #![warn(unused)]
| ^^^^^^
= note: #[warn(unused_variables)] implied by #[warn(unused)]
error: structure field `X` should have a snake case name such as `x`
error: structure field `X` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:10:5
|
LL | X: usize //~ ERROR structure field `X` should have a snake case name such as `x`
| ^^^^^^^^
LL | X: usize //~ ERROR structure field `X` should have a snake case name
| ^ help: convert the identifier to snake case: `x`
|
note: lint level defined here
--> $DIR/lint-uppercase-variables.rs:3:9
@ -29,23 +29,23 @@ note: lint level defined here
LL | #![deny(non_snake_case)]
| ^^^^^^^^^^^^^^
error: variable `Xx` should have a snake case name such as `xx`
error: variable `Xx` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:13:9
|
LL | fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx`
| ^^
LL | fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name
| ^^ help: convert the identifier to snake case: `xx`
error: variable `Test` should have a snake case name such as `test`
error: variable `Test` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:18:9
|
LL | let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test`
| ^^^^
LL | let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name
| ^^^^ help: convert the identifier to snake case: `test`
error: variable `Foo` should have a snake case name such as `foo`
error: variable `Foo` should have a snake case name
--> $DIR/lint-uppercase-variables.rs:22:9
|
LL | Foo => {}
| ^^^
| ^^^ help: convert the identifier to snake case: `foo`
error: aborting due to 4 previous errors

View file

@ -11,11 +11,11 @@ note: lint level defined here
LL | #![warn(elided_lifetimes_in_paths,
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: variable `Social_exchange_psychology` should have a snake case name such as `social_exchange_psychology`
warning: variable `Social_exchange_psychology` should have a snake case name
--> $DIR/reasons.rs:30:9
|
LL | let Social_exchange_psychology = CheaterDetectionMechanism {};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `social_exchange_psychology`
|
= note: people shouldn't have to change their usual style habits
to contribute to our project

View file

@ -10,6 +10,7 @@
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
struct S;

View file

@ -1,26 +0,0 @@
warning: function `want_F` should have a snake case name such as `want_f`
--> $DIR/regions-fn-subtyping-return-static.rs:18:1
|
LL | fn want_F(f: F) { }
| ^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(non_snake_case)] on by default
warning: function `want_G` should have a snake case name such as `want_g`
--> $DIR/regions-fn-subtyping-return-static.rs:22:1
|
LL | fn want_G(f: G) { }
| ^^^^^^^^^^^^^^^^^^^
warning: function `supply_F` should have a snake case name such as `supply_f`
--> $DIR/regions-fn-subtyping-return-static.rs:39:1
|
LL | / fn supply_F() {
LL | | want_F(foo);
LL | |
LL | | want_F(bar);
LL | |
LL | | want_F(baz);
LL | | }
| |_^

View file

@ -11,17 +11,17 @@ LL | #![warn(unused)]
| ^^^^^^
= note: #[warn(unused_variables)] implied by #[warn(unused)]
warning: variable `theTwo` should have a snake case name such as `the_two`
warning: variable `theTwo` should have a snake case name
--> $DIR/issue-24690.rs:12:9
|
LL | let theTwo = 2; //~ WARN should have a snake case name
| ^^^^^^
| ^^^^^^ help: convert the identifier to snake case: `the_two`
|
= note: #[warn(non_snake_case)] on by default
warning: variable `theOtherTwo` should have a snake case name such as `the_other_two`
warning: variable `theOtherTwo` should have a snake case name
--> $DIR/issue-24690.rs:13:9
|
LL | let theOtherTwo = 2; //~ WARN should have a snake case name
| ^^^^^^^^^^^
| ^^^^^^^^^^^ help: convert the identifier to snake case: `the_other_two`