lint: Improve camel case suggestion when empty.
This commit is contained in:
parent
673c555443
commit
9eb9fcd719
@ -768,9 +768,13 @@ impl LintPass for NonCamelCaseTypes {
|
|||||||
let s = token::get_ident(ident);
|
let s = token::get_ident(ident);
|
||||||
|
|
||||||
if !is_camel_case(ident) {
|
if !is_camel_case(ident) {
|
||||||
cx.span_lint(NON_CAMEL_CASE_TYPES, span,
|
let c = to_camel_case(s.get());
|
||||||
format!("{} `{}` should have a camel case name such as `{}`",
|
let m = if c.is_empty() {
|
||||||
sort, s, to_camel_case(s.get())).as_slice());
|
format!("{} `{}` should have a camel case name such as `CamelCase`", sort, s)
|
||||||
|
} else {
|
||||||
|
format!("{} `{}` should have a camel case name such as `{}`", sort, s, c)
|
||||||
|
};
|
||||||
|
cx.span_lint(NON_CAMEL_CASE_TYPES, span, m.as_slice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,6 @@ struct foo7 {
|
|||||||
bar: int,
|
bar: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
type __ = int; //~ ERROR type `__` should have a camel case name such as ``
|
type __ = int; //~ ERROR type `__` should have a camel case name such as `CamelCase`
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
Loading…
Reference in New Issue
Block a user