1
Fork 0

Auto merge of #57387 - euclio:nonstandard-style-suggestions, r=oli-obk

Use structured suggestions for nonstandard style lints

This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the `crate_name` attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered.

Fixes #48103.
Fixes #52414.
This commit is contained in:
bors 2019-01-14 06:35:51 +00:00
commit 1d029c67e2
45 changed files with 372 additions and 373 deletions

View file

@ -42,13 +42,13 @@ use std::cmp;
#[derive(Copy, Clone)]
pub enum FnKind<'a> {
/// #[xxx] pub async/const/extern "Abi" fn foo()
ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]),
/// fn foo(&self)
/// `fn foo(&self)`
Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]),
/// |x, y| {}
/// `|x, y| {}`
Closure(&'a [Attribute]),
}
@ -472,7 +472,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor.visit_nested_body(body);
}
ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
visitor.visit_fn(FnKind::ItemFn(item.ident.name,
visitor.visit_fn(FnKind::ItemFn(item.ident,
generics,
header,
&item.vis,

View file

@ -15,7 +15,7 @@ use hir as ast;
use hir::map;
use hir::{Expr, FnDecl, Node};
use hir::intravisit::FnKind;
use syntax::ast::{Attribute, Ident, Name, NodeId};
use syntax::ast::{Attribute, Ident, NodeId};
use syntax_pos::Span;
/// An FnLikeNode is a Node that is like a fn, in that it has a decl
@ -98,7 +98,7 @@ impl<'a> Code<'a> {
/// These are all the components one can extract from a fn item for
/// use when implementing FnLikeNode operations.
struct ItemFnParts<'a> {
name: Name,
ident: Ident,
decl: &'a ast::FnDecl,
header: ast::FnHeader,
vis: &'a ast::Visibility,
@ -200,7 +200,7 @@ impl<'a> FnLikeNode<'a> {
pub fn kind(self) -> FnKind<'a> {
let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
FnKind::ItemFn(p.name, p.generics, p.header, p.vis, p.attrs)
FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
};
let closure = |c: ClosureParts<'a>| {
FnKind::Closure(c.attrs)
@ -228,7 +228,7 @@ impl<'a> FnLikeNode<'a> {
ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
item_fn(ItemFnParts {
id: i.id,
name: i.ident.name,
ident: i.ident,
decl: &decl,
body: block,
vis: &i.vis,

View file

@ -7,7 +7,8 @@ use lint::{EarlyContext, LateContext, LintContext, LintArray};
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 {
@ -40,13 +41,12 @@ declare_lint! {
pub struct NonCamelCaseTypes;
impl NonCamelCaseTypes {
fn check_case(&self, cx: &EarlyContext, sort: &str, name: ast::Name, span: Span) {
fn check_case(&self, cx: &EarlyContext, sort: &str, ident: &Ident) {
fn char_has_case(c: char) -> bool {
c.is_lowercase() || c.is_uppercase()
}
fn is_camel_case(name: ast::Name) -> bool {
let name = name.as_str();
fn is_camel_case(name: &str) -> bool {
let name = name.trim_matches('_');
if name.is_empty() {
return true;
@ -86,14 +86,20 @@ impl NonCamelCaseTypes {
}).0
}
let name = &ident.name.as_str();
if !is_camel_case(name) {
let c = to_camel_case(&name.as_str());
let m = if c.is_empty() {
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, name)
} else {
format!("{} `{}` should have a camel case name such as `{}`", sort, name, c)
};
cx.span_lint(NON_CAMEL_CASE_TYPES, span, &m);
let c = to_camel_case(name);
let msg = format!("{} `{}` should have a camel case name", sort, name);
cx.struct_span_lint(NON_CAMEL_CASE_TYPES, ident.span, &msg)
.span_suggestion_with_applicability(
ident.span,
"convert the identifier to camel case",
c,
Applicability::MaybeIncorrect,
)
.emit();
}
}
}
@ -122,19 +128,19 @@ impl EarlyLintPass for NonCamelCaseTypes {
ast::ItemKind::Ty(..) |
ast::ItemKind::Enum(..) |
ast::ItemKind::Struct(..) |
ast::ItemKind::Union(..) => self.check_case(cx, "type", it.ident.name, it.span),
ast::ItemKind::Trait(..) => self.check_case(cx, "trait", it.ident.name, it.span),
ast::ItemKind::Union(..) => self.check_case(cx, "type", &it.ident),
ast::ItemKind::Trait(..) => self.check_case(cx, "trait", &it.ident),
_ => (),
}
}
fn check_variant(&mut self, cx: &EarlyContext, v: &ast::Variant, _: &ast::Generics) {
self.check_case(cx, "variant", v.node.ident.name, v.span);
self.check_case(cx, "variant", &v.node.ident);
}
fn check_generic_param(&mut self, cx: &EarlyContext, param: &ast::GenericParam) {
if let ast::GenericParamKind::Type { .. } = param.kind {
self.check_case(cx, "type parameter", param.ident.name, param.ident.span);
self.check_case(cx, "type parameter", &param.ident);
}
}
}
@ -179,7 +185,8 @@ impl NonSnakeCase {
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 +208,28 @@ impl NonSnakeCase {
})
}
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 +242,75 @@ impl LintPass for NonSnakeCase {
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 +318,35 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
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);
}
}
}
@ -322,21 +361,21 @@ declare_lint! {
pub struct NonUpperCaseGlobals;
impl NonUpperCaseGlobals {
fn check_upper_case(cx: &LateContext, sort: &str, name: ast::Name, span: Span) {
if name.as_str().chars().any(|c| c.is_lowercase()) {
let uc = NonSnakeCase::to_snake_case(&name.as_str()).to_uppercase();
if name != &*uc {
cx.span_lint(NON_UPPER_CASE_GLOBALS,
span,
&format!("{} `{}` should have an upper case name such as `{}`",
sort,
name,
uc));
} else {
cx.span_lint(NON_UPPER_CASE_GLOBALS,
span,
&format!("{} `{}` should have an upper case name", sort, name));
}
fn check_upper_case(cx: &LateContext, sort: &str, ident: &Ident) {
let name = &ident.name.as_str();
if name.chars().any(|c| c.is_lowercase()) {
let uc = NonSnakeCase::to_snake_case(&name).to_uppercase();
let msg = format!("{} `{}` should have an upper case name", sort, name);
cx.struct_span_lint(NON_UPPER_CASE_GLOBALS, ident.span, &msg)
.span_suggestion_with_applicability(
ident.span,
"convert the identifier to upper case",
uc,
Applicability::MaybeIncorrect,
)
.emit();
}
}
}
@ -350,38 +389,25 @@ impl LintPass for NonUpperCaseGlobals {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
match it.node {
hir::ItemKind::Static(..) => {
if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
return;
}
NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.ident.name,
it.span);
hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, "no_mangle") => {
NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
}
hir::ItemKind::Const(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "constant", it.ident.name,
it.span);
NonUpperCaseGlobals::check_upper_case(cx, "constant", &it.ident);
}
_ => {}
}
}
fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) {
match ti.node {
hir::TraitItemKind::Const(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
ti.ident.name, ti.span);
}
_ => {}
if let hir::TraitItemKind::Const(..) = ti.node {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident);
}
}
fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
match ii.node {
hir::ImplItemKind::Const(..) => {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
ii.ident.name, ii.span);
}
_ => {}
if let hir::ImplItemKind::Const(..) = ii.node {
NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
}
}
@ -390,10 +416,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
if let Def::Const(..) = path.def {
if path.segments.len() == 1 {
NonUpperCaseGlobals::check_upper_case(cx,
"constant in pattern",
path.segments[0].ident.name,
path.span);
NonUpperCaseGlobals::check_upper_case(
cx,
"constant in pattern",
&path.segments[0].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

@ -124,14 +124,14 @@ pub fn expand_test_or_bench(
])
};
let mut test_const = cx.item(sp, item.ident.gensym(),
let mut test_const = cx.item(sp, ast::Ident::new(item.ident.name.gensymed(), sp),
vec![
// #[cfg(test)]
cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![
cx.meta_list_item_word(attr_sp, Symbol::intern("test"))
])),
// #[rustc_test_marker]
cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker")))
cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker"))),
],
// const $ident: test::TestDescAndFn =
ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),

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 @@
#![warn(unused)]
#[deny(warnings)]
#![deny(warnings)]
const foo: isize = 3;
//~^ ERROR: should have an upper case name such as
//~^ ERROR: should have an upper case name
//~^^ ERROR: constant item is never used
fn main() {}

View file

@ -5,23 +5,23 @@ LL | const foo: isize = 3;
| ^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/issue-17718-const-naming.rs:2:8
--> $DIR/issue-17718-const-naming.rs:2:9
|
LL | #[deny(warnings)]
| ^^^^^^^^
LL | #![deny(warnings)]
| ^^^^^^^^
= note: #[deny(dead_code)] implied by #[deny(warnings)]
error: constant `foo` should have an upper case name such as `FOO`
--> $DIR/issue-17718-const-naming.rs:4:1
error: constant `foo` should have an upper case name
--> $DIR/issue-17718-const-naming.rs:4:7
|
LL | const foo: isize = 3;
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^ help: convert the identifier to upper case: `FOO`
|
note: lint level defined here
--> $DIR/issue-17718-const-naming.rs:2:8
--> $DIR/issue-17718-const-naming.rs:2:9
|
LL | #[deny(warnings)]
| ^^^^^^^^
LL | #![deny(warnings)]
| ^^^^^^^^
= note: #[deny(non_upper_case_globals)] implied by #[deny(warnings)]
error: aborting due to 2 previous errors

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

@ -1,8 +1,8 @@
warning: type `snake_case` should have a camel case name such as `SnakeCase`
--> $DIR/lint-group-nonstandard-style.rs:22:9
warning: type `snake_case` should have a camel case name
--> $DIR/lint-group-nonstandard-style.rs:22:16
|
LL | struct snake_case; //~ WARN should have a camel
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^ help: convert the identifier to camel case: `SnakeCase`
|
note: lint level defined here
--> $DIR/lint-group-nonstandard-style.rs:18:17
@ -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
@ -37,11 +37,11 @@ LL | #[forbid(nonstandard_style)]
| ^^^^^^^^^^^^^^^^^
= note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)]
error: static variable `bad` should have an upper case name such as `BAD`
--> $DIR/lint-group-nonstandard-style.rs:14:9
error: static variable `bad` should have an upper case name
--> $DIR/lint-group-nonstandard-style.rs:14:16
|
LL | static bad: isize = 1; //~ ERROR should have an upper
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^ help: convert the identifier to upper case: `BAD`
|
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,13 +1,12 @@
// run-pass
// compile-pass
// Issue #7526: lowercase static constants in patterns look like bindings
// This is similar to compile-fail/match-static-const-lc, except it
// This is similar to lint-lowercase-static-const-pattern.rs, except it
// shows the expected usual workaround (choosing a different name for
// the static definition) and also demonstrates that one can work
// around this problem locally by renaming the constant in the `use`
// form to an uppercase identifier that placates the lint.
#![deny(non_upper_case_globals)]
pub const A : isize = 97;

View file

@ -9,7 +9,7 @@ pub const a : isize = 97;
fn f() {
let r = match (0,0) {
(0, a) => 0,
//~^ ERROR constant in pattern `a` should have an upper case name such as `A`
//~^ ERROR constant in pattern `a` should have an upper case name
(x, y) => 1 + x + y,
};
assert_eq!(r, 1);
@ -24,7 +24,7 @@ fn g() {
use self::m::aha;
let r = match (0,0) {
(0, aha) => 0,
//~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA`
//~^ ERROR constant in pattern `aha` should have an upper case name
(x, y) => 1 + x + y,
};
assert_eq!(r, 1);
@ -38,7 +38,7 @@ fn h() {
use self::n::OKAY as not_okay;
let r = match (0,0) {
(0, not_okay) => 0,
//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
//~^ ERROR constant in pattern `not_okay` should have an upper case name
(x, y) => 1 + x + y,
};
assert_eq!(r, 1);

View file

@ -0,0 +1,26 @@
error: constant in pattern `a` should have an upper case name
--> $DIR/lint-lowercase-static-const-pattern.rs:11:13
|
LL | (0, a) => 0,
| ^ help: convert the identifier to upper case: `A`
|
note: lint level defined here
--> $DIR/lint-lowercase-static-const-pattern.rs:4:9
|
LL | #![deny(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: constant in pattern `aha` should have an upper case name
--> $DIR/lint-lowercase-static-const-pattern.rs:26:13
|
LL | (0, aha) => 0,
| ^^^ help: convert the identifier to upper case: `AHA`
error: constant in pattern `not_okay` should have an upper case name
--> $DIR/lint-lowercase-static-const-pattern.rs:40:13
|
LL | (0, not_okay) => 0,
| ^^^^^^^^ help: convert the identifier to upper case: `NOT_OKAY`
error: aborting due to 3 previous errors

View file

@ -2,31 +2,31 @@
#![allow(dead_code)]
struct ONE_TWO_THREE;
//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
//~^ ERROR type `ONE_TWO_THREE` should have a camel case name
struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
struct foo { //~ ERROR type `foo` should have a camel case name
bar: isize,
}
enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
enum foo2 { //~ ERROR type `foo2` should have a camel case name
Bar
}
struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
struct foo3 { //~ ERROR type `foo3` should have a camel case name
bar: isize
}
type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
type foo4 = isize; //~ ERROR type `foo4` should have a camel case name
enum Foo5 {
bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
bar //~ ERROR variant `bar` should have a camel case name
}
trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
trait foo6 { //~ ERROR trait `foo6` should have a camel case name
fn dummy(&self) { }
}
fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name
#[repr(C)]
struct foo7 {
@ -35,10 +35,10 @@ struct foo7 {
struct X86_64;
struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
struct X86__64; //~ ERROR type `X86__64` should have a camel case name
struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name
struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name
fn main() { }

View file

@ -1,8 +1,8 @@
error: type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree`
--> $DIR/lint-non-camel-case-types.rs:4:1
error: type `ONE_TWO_THREE` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:4:8
|
LL | struct ONE_TWO_THREE;
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^ help: convert the identifier to camel case: `OneTwoThree`
|
note: lint level defined here
--> $DIR/lint-non-camel-case-types.rs:1:11
@ -10,73 +10,65 @@ note: lint level defined here
LL | #![forbid(non_camel_case_types)]
| ^^^^^^^^^^^^^^^^^^^^
error: type `foo` should have a camel case name such as `Foo`
--> $DIR/lint-non-camel-case-types.rs:7:1
error: type `foo` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:7:8
|
LL | / struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo`
LL | | bar: isize,
LL | | }
| |_^
LL | struct foo { //~ ERROR type `foo` should have a camel case name
| ^^^ help: convert the identifier to camel case: `Foo`
error: type `foo2` should have a camel case name such as `Foo2`
--> $DIR/lint-non-camel-case-types.rs:11:1
error: type `foo2` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:11:6
|
LL | / enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2`
LL | | Bar
LL | | }
| |_^
LL | enum foo2 { //~ ERROR type `foo2` should have a camel case name
| ^^^^ help: convert the identifier to camel case: `Foo2`
error: type `foo3` should have a camel case name such as `Foo3`
--> $DIR/lint-non-camel-case-types.rs:15:1
error: type `foo3` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:15:8
|
LL | / struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3`
LL | | bar: isize
LL | | }
| |_^
LL | struct foo3 { //~ ERROR type `foo3` should have a camel case name
| ^^^^ help: convert the identifier to camel case: `Foo3`
error: type `foo4` should have a camel case name such as `Foo4`
--> $DIR/lint-non-camel-case-types.rs:19:1
error: type `foo4` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:19:6
|
LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4`
| ^^^^^^^^^^^^^^^^^^
LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name
| ^^^^ help: convert the identifier to camel case: `Foo4`
error: variant `bar` should have a camel case name such as `Bar`
error: variant `bar` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:22:5
|
LL | bar //~ ERROR variant `bar` should have a camel case name such as `Bar`
| ^^^
LL | bar //~ ERROR variant `bar` should have a camel case name
| ^^^ help: convert the identifier to camel case: `Bar`
error: trait `foo6` should have a camel case name such as `Foo6`
--> $DIR/lint-non-camel-case-types.rs:25:1
error: trait `foo6` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:25:7
|
LL | / trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6`
LL | | fn dummy(&self) { }
LL | | }
| |_^
LL | trait foo6 { //~ ERROR trait `foo6` should have a camel case name
| ^^^^ help: convert the identifier to camel case: `Foo6`
error: type parameter `ty` should have a camel case name such as `Ty`
error: type parameter `ty` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:29:6
|
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty`
| ^^
LL | fn f<ty>(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name
| ^^ help: convert the identifier to camel case: `Ty`
error: type `X86__64` should have a camel case name such as `X86_64`
--> $DIR/lint-non-camel-case-types.rs:38:1
error: type `X86__64` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:38:8
|
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64`
| ^^^^^^^^^^^^^^^
LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name
| ^^^^^^^ help: convert the identifier to camel case: `X86_64`
error: type `Abc_123` should have a camel case name such as `Abc123`
--> $DIR/lint-non-camel-case-types.rs:40:1
error: type `Abc_123` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:40:8
|
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123`
| ^^^^^^^^^^^^^^^
LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name
| ^^^^^^^ help: convert the identifier to camel case: `Abc123`
error: type `A1_b2_c3` should have a camel case name such as `A1B2C3`
--> $DIR/lint-non-camel-case-types.rs:42:1
error: type `A1_b2_c3` should have a camel case name
--> $DIR/lint-non-camel-case-types.rs:42:8
|
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3`
| ^^^^^^^^^^^^^^^^
LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name
| ^^^^^^^^ help: convert the identifier to camel case: `A1B2C3`
error: aborting due to 11 previous errors

View file

@ -1,3 +1,5 @@
// compile-pass
#![deny(non_camel_case_types)]
pub enum Foo {

View file

@ -1,3 +1,5 @@
// compile-pass
#![allow(dead_code)]
// This is ok because we often use the trailing underscore to mean 'prime'

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 @@ struct Foo;
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 @@ impl X for Foo {
}
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

@ -6,6 +6,6 @@ struct Foo;
impl Foo {
const not_upper: bool = true;
}
//~^^ ERROR associated constant `not_upper` should have an upper case name such as `NOT_UPPER`
//~^^ ERROR associated constant `not_upper` should have an upper case name
fn main() {}

View file

@ -1,11 +1,11 @@
error: associated constant `not_upper` should have an upper case name such as `NOT_UPPER`
--> $DIR/associated-const-upper-case-lint.rs:7:5
error: associated constant `not_upper` should have an upper case name
--> $DIR/lint-non-uppercase-associated-const.rs:7:11
|
LL | const not_upper: bool = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^ help: convert the identifier to upper case: `NOT_UPPER`
|
note: lint level defined here
--> $DIR/associated-const-upper-case-lint.rs:1:9
--> $DIR/lint-non-uppercase-associated-const.rs:1:9
|
LL | #![deny(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,10 +1,9 @@
#![forbid(non_upper_case_globals)]
#![allow(dead_code)]
static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO`
static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name
static mut bar: isize = 1;
//~^ ERROR static variable `bar` should have an upper case name such as `BAR`
static mut bar: isize = 1; //~ ERROR static variable `bar` should have an upper case name
#[no_mangle]
pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning

View file

@ -1,8 +1,8 @@
error: static variable `foo` should have an upper case name such as `FOO`
--> $DIR/lint-non-uppercase-statics.rs:4:1
error: static variable `foo` should have an upper case name
--> $DIR/lint-non-uppercase-statics.rs:4:8
|
LL | static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO`
| ^^^^^^^^^^^^^^^^^^^^^^
LL | static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name
| ^^^ help: convert the identifier to upper case: `FOO`
|
note: lint level defined here
--> $DIR/lint-non-uppercase-statics.rs:1:11
@ -10,11 +10,11 @@ note: lint level defined here
LL | #![forbid(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: static variable `bar` should have an upper case name such as `BAR`
--> $DIR/lint-non-uppercase-statics.rs:6:1
error: static variable `bar` should have an upper case name
--> $DIR/lint-non-uppercase-statics.rs:6:12
|
LL | static mut bar: isize = 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | static mut bar: isize = 1; //~ ERROR static variable `bar` should have an upper case name
| ^^^ help: convert the identifier to upper case: `BAR`
error: aborting due to 2 previous errors

View file

@ -1,6 +1,6 @@
//
#![allow(dead_code)]
// compile-pass
#![allow(dead_code)]
#![forbid(non_camel_case_types)]
#![forbid(non_upper_case_globals)]

View file

@ -7,20 +7,20 @@ mod 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

@ -1,26 +0,0 @@
error: constant in pattern `a` should have an upper case name such as `A`
--> $DIR/match-static-const-lc.rs:11:13
|
LL | (0, a) => 0,
| ^
|
note: lint level defined here
--> $DIR/match-static-const-lc.rs:4:9
|
LL | #![deny(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: constant in pattern `aha` should have an upper case name such as `AHA`
--> $DIR/match-static-const-lc.rs:26:13
|
LL | (0, aha) => 0,
| ^^^
error: constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY`
--> $DIR/match-static-const-lc.rs:40:13
|
LL | (0, not_okay) => 0,
| ^^^^^^^^
error: aborting due to 3 previous errors

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`

View file

@ -3,7 +3,7 @@
fn foo<
'β, //~ ERROR non-ascii idents are not fully supported
γ //~ ERROR non-ascii idents are not fully supported
//~^ WARN type parameter `γ` should have a camel case name such as `Γ`
//~^ WARN type parameter `γ` should have a camel case name
>() {}
struct X {

View file

@ -30,11 +30,11 @@ LL | let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported
|
= help: add #![feature(non_ascii_idents)] to the crate attributes to enable
warning: type parameter `γ` should have a camel case name such as `Γ`
warning: type parameter `γ` should have a camel case name
--> $DIR/utf8_idents.rs:5:5
|
LL | γ //~ ERROR non-ascii idents are not fully supported
| ^
| ^ help: convert the identifier to camel case: `Γ`
|
= note: #[warn(non_camel_case_types)] on by default