all: make style of lint messages consistent
* start first sentence lowercased * use backticks to delimit code snippets * use "this is wrong. Consider doing X." consistently
This commit is contained in:
parent
2ec933377c
commit
bcd95aec1c
@ -53,7 +53,7 @@ fn check_known_consts(cx: &Context, span: Span, str: &str, module: &str) {
|
||||
for &(constant, name) in KNOWN_CONSTS {
|
||||
if within_epsilon(constant, value) {
|
||||
span_lint(cx, APPROX_CONSTANT, span, &format!(
|
||||
"Approximate value of {}::{} found, consider using it directly.", module, &name));
|
||||
"approximate value of `{}::{}` found. Consider using it directly.", module, &name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ fn check_attrs(cx: &Context, info: Option<&ExpnInfo>, ident: &Ident,
|
||||
if let MetaWord(ref always) = values[0].node {
|
||||
if always != &"always" { continue; }
|
||||
span_lint(cx, INLINE_ALWAYS, attr.span, &format!(
|
||||
"You have declared #[inline(always)] on {}. This \
|
||||
"you have declared `#[inline(always)]` on `{}`. This \
|
||||
is usually a bad idea. Are you sure?",
|
||||
ident.name.as_str()));
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
BiBitAnd => if mask_value & cmp_value != mask_value {
|
||||
if cmp_value != 0 {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ & {} can never be equal to {}",
|
||||
"incompatible bit mask: `_ & {}` can never be equal to `{}`",
|
||||
mask_value, cmp_value));
|
||||
}
|
||||
} else {
|
||||
@ -108,7 +108,7 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
},
|
||||
BiBitOr => if mask_value | cmp_value != cmp_value {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ | {} can never be equal to {}",
|
||||
"incompatible bit mask: `_ | {}` can never be equal to `{}`",
|
||||
mask_value, cmp_value));
|
||||
},
|
||||
_ => ()
|
||||
@ -116,7 +116,7 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
BiLt | BiGe => match bit_op {
|
||||
BiBitAnd => if mask_value < cmp_value {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ & {} will always be lower than {}",
|
||||
"incompatible bit mask: `_ & {}` will always be lower than `{}`",
|
||||
mask_value, cmp_value));
|
||||
} else {
|
||||
if mask_value == 0 {
|
||||
@ -126,12 +126,12 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
},
|
||||
BiBitOr => if mask_value >= cmp_value {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ | {} will never be lower than {}",
|
||||
"incompatible bit mask: `_ | {}` will never be lower than `{}`",
|
||||
mask_value, cmp_value));
|
||||
} else {
|
||||
if mask_value < cmp_value {
|
||||
span_lint(cx, INEFFECTIVE_BIT_MASK, *span, &format!(
|
||||
"ineffective bit mask: x | {} compared to {} is the same as x compared directly",
|
||||
"ineffective bit mask: `x | {}` compared to `{}` is the same as x compared directly",
|
||||
mask_value, cmp_value));
|
||||
}
|
||||
},
|
||||
@ -140,7 +140,7 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
BiLe | BiGt => match bit_op {
|
||||
BiBitAnd => if mask_value <= cmp_value {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ & {} will never be higher than {}",
|
||||
"incompatible bit mask: `_ & {}` will never be higher than `{}`",
|
||||
mask_value, cmp_value));
|
||||
} else {
|
||||
if mask_value == 0 {
|
||||
@ -150,12 +150,12 @@ fn check_bit_mask(cx: &Context, bit_op: BinOp_, cmp_op: BinOp_,
|
||||
},
|
||||
BiBitOr => if mask_value > cmp_value {
|
||||
span_lint(cx, BAD_BIT_MASK, *span, &format!(
|
||||
"incompatible bit mask: _ | {} will always be higher than {}",
|
||||
"incompatible bit mask: `_ | {}` will always be higher than `{}`",
|
||||
mask_value, cmp_value));
|
||||
} else {
|
||||
if mask_value < cmp_value {
|
||||
span_lint(cx, INEFFECTIVE_BIT_MASK, *span, &format!(
|
||||
"ineffective bit mask: x | {} compared to {} is the same as x compared directly",
|
||||
"ineffective bit mask: `x | {}` compared to `{}` is the same as x compared directly",
|
||||
mask_value, cmp_value));
|
||||
}
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ fn check_expr_expd(cx: &Context, e: &Expr, info: Option<&ExpnInfo>) {
|
||||
if let Some(&Expr{ node: ExprIf(ref check_inner, _, None), ..}) =
|
||||
single_stmt_of_block(then) {
|
||||
span_lint(cx, COLLAPSIBLE_IF, e.span, &format!(
|
||||
"This if statement can be collapsed. Try: if {} && {}\n{:?}",
|
||||
"this if statement can be collapsed. Try: `if {} && {}`\n{:?}",
|
||||
check_to_string(check), check_to_string(check_inner), e));
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
}
|
||||
}
|
||||
span_lint(cx, REDUNDANT_CLOSURE, expr.span,
|
||||
&format!("Redundant closure found, consider using `{}` in its place",
|
||||
&format!("redundant closure found. Consider using `{}` in its place.",
|
||||
expr_to_string(caller))[..])
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ fn check_expr(&mut self, cx: &Context, e: &Expr) {
|
||||
fn check(cx: &Context, e: &Expr, m: i8, span: Span, arg: Span) {
|
||||
if have_lit(cx, e, m) {
|
||||
span_lint(cx, IDENTITY_OP, span, &format!(
|
||||
"The operation is ineffective. Consider reducing it to '{}'",
|
||||
"the operation is ineffective. Consider reducing it to `{}`.",
|
||||
snippet(cx, arg, "..")));
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ fn is_named_self(item: &TraitItem, name: &str) -> bool {
|
||||
for i in trait_items {
|
||||
if is_named_self(i, "len") {
|
||||
span_lint(cx, LEN_WITHOUT_IS_EMPTY, i.span,
|
||||
&format!("Trait '{}' has a '.len(_: &Self)' method, but no \
|
||||
'.is_empty(_: &Self)' method. Consider adding one.",
|
||||
&format!("trait `{}` has a `.len(_: &Self)` method, but no \
|
||||
`.is_empty(_: &Self)` method. Consider adding one.",
|
||||
item.ident.name));
|
||||
}
|
||||
};
|
||||
@ -78,8 +78,8 @@ fn is_named_self(item: &ImplItem, name: &str) -> bool {
|
||||
let s = i.span;
|
||||
span_lint(cx, LEN_WITHOUT_IS_EMPTY,
|
||||
Span{ lo: s.lo, hi: s.lo, expn_id: s.expn_id },
|
||||
&format!("Item '{}' has a '.len(_: &Self)' method, but no \
|
||||
'.is_empty(_: &Self)' method. Consider adding one.",
|
||||
&format!("item `{}` has a `.len(_: &Self)` method, but no \
|
||||
`.is_empty(_: &Self)` method. Consider adding one.",
|
||||
item.ident.name));
|
||||
return;
|
||||
}
|
||||
@ -108,7 +108,7 @@ fn check_len_zero(cx: &Context, span: Span, method: &SpannedIdent,
|
||||
if method.node.name == "len" && args.len() == 1 &&
|
||||
has_is_empty(cx, &*args[0]) {
|
||||
span_lint(cx, LEN_ZERO, span, &format!(
|
||||
"Consider replacing the len comparison with '{}_.is_empty()'",
|
||||
"consider replacing the len comparison with `{}_.is_empty()`",
|
||||
empty))
|
||||
}
|
||||
}
|
||||
|
20
src/misc.rs
20
src/misc.rs
@ -43,10 +43,10 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
format!("{{ {} }}", body_code)
|
||||
};
|
||||
span_help_and_lint(cx, SINGLE_MATCH, expr.span,
|
||||
"You seem to be trying to use match for \
|
||||
"you seem to be trying to use match for \
|
||||
destructuring a single pattern. Did you mean to \
|
||||
use `if let`?",
|
||||
&*format!("Try\nif let {} = {} {}",
|
||||
&*format!("try\nif let {} = {} {}",
|
||||
snippet(cx, arms[0].pats[0].span, ".."),
|
||||
snippet(cx, ex.span, ".."),
|
||||
suggestion)
|
||||
@ -74,7 +74,7 @@ fn check_expr(&mut self, cx: &Context, expr: &ast::Expr) {
|
||||
ast::ExprMethodCall(ref method, _, ref args)
|
||||
if method.node.name == "to_string"
|
||||
&& is_str(cx, &*args[0]) => {
|
||||
span_lint(cx, STR_TO_STRING, expr.span, "str.to_owned() is faster");
|
||||
span_lint(cx, STR_TO_STRING, expr.span, "`str.to_owned()` is faster");
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
@ -105,7 +105,7 @@ fn check_fn(&mut self, cx: &Context, _: FnKind, decl: &FnDecl, _: &Block, _: Spa
|
||||
span_lint(cx,
|
||||
TOPLEVEL_REF_ARG,
|
||||
arg.pat.span,
|
||||
"`ref` directly on a function argument is ignored. Have you considered using a reference type instead?"
|
||||
"`ref` directly on a function argument is ignored. Consider using a reference type instead."
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
fn check_nan(cx: &Context, path: &Path, span: Span) {
|
||||
path.segments.last().map(|seg| if seg.identifier.name == "NAN" {
|
||||
span_lint(cx, CMP_NAN, span,
|
||||
"Doomed comparison with NAN, use std::{f32,f64}::is_nan instead");
|
||||
"doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead");
|
||||
});
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
let op = cmp.node;
|
||||
if (op == BiEq || op == BiNe) && (is_float(cx, left) || is_float(cx, right)) {
|
||||
span_lint(cx, FLOAT_CMP, expr.span, &format!(
|
||||
"{}-Comparison of f32 or f64 detected. You may want to change this to 'abs({} - {}) < epsilon' for some suitable value of epsilon",
|
||||
"{}-comparison of f32 or f64 detected. Consider changing this to `abs({} - {}) < epsilon` for some suitable value of epsilon.",
|
||||
binop_to_string(op), snippet(cx, left.span, ".."),
|
||||
snippet(cx, right.span, "..")));
|
||||
}
|
||||
@ -190,7 +190,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
if let ExprBinary(Spanned { node: op, ..}, ref left, ref right) = expr.node {
|
||||
if is_bit_op(op) && (is_arith_expr(left) || is_arith_expr(right)) {
|
||||
span_lint(cx, PRECEDENCE, expr.span,
|
||||
"Operator precedence can trip the unwary. Consider adding parenthesis to the subexpression.");
|
||||
"operator precedence can trip the unwary. Consider adding parenthesis to the subexpression.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,7 +246,7 @@ fn check_to_owned(cx: &Context, expr: &Expr, other_span: Span) {
|
||||
name == "to_owned" && is_str_arg(cx, args) {
|
||||
span_lint(cx, CMP_OWNED, expr.span, &format!(
|
||||
"this creates an owned instance just for comparison. \
|
||||
Consider using {}.as_slice() to compare without allocation",
|
||||
Consider using `{}.as_slice()` to compare without allocation.",
|
||||
snippet(cx, other_span, "..")))
|
||||
}
|
||||
},
|
||||
@ -256,7 +256,7 @@ fn check_to_owned(cx: &Context, expr: &Expr, other_span: Span) {
|
||||
match_path(path, &["String", "from"]) {
|
||||
span_lint(cx, CMP_OWNED, expr.span, &format!(
|
||||
"this creates an owned instance just for comparison. \
|
||||
Consider using {}.as_slice() to compare without allocation",
|
||||
Consider using `{}.as_slice()` to compare without allocation.",
|
||||
snippet(cx, other_span, "..")))
|
||||
}
|
||||
}
|
||||
@ -284,7 +284,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
if let ExprBinary(ref cmp, _, ref right) = expr.node {
|
||||
if let &Spanned {node: BinOp_::BiRem, ..} = cmp {
|
||||
if is_lit_one(right) {
|
||||
cx.span_lint(MODULO_ONE, expr.span, "Any number modulo 1 will be 0");
|
||||
cx.span_lint(MODULO_ONE, expr.span, "any number modulo 1 will be 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ fn check_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
|
||||
fn check_ty(&mut self, cx: &Context, ty: &Ty) {
|
||||
unwrap_mut(ty).and_then(unwrap_mut).map_or((), |_| span_lint(cx, MUT_MUT,
|
||||
ty.span, "Generally you want to avoid &mut &mut _ if possible."))
|
||||
ty.span, "generally you want to avoid `&mut &mut _` if possible"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,13 +40,13 @@ fn unwrap_addr(expr : &Expr) -> Option<&Expr> {
|
||||
unwrap_addr(expr).map_or((), |e| {
|
||||
unwrap_addr(e).map(|_| {
|
||||
span_lint(cx, MUT_MUT, expr.span,
|
||||
"Generally you want to avoid &mut &mut _ if possible.")
|
||||
"generally you want to avoid `&mut &mut _` if possible")
|
||||
}).unwrap_or_else(|| {
|
||||
if let TyRef(_, TypeAndMut{ty: _, mutbl: MutMutable}) =
|
||||
cx.tcx.expr_ty(e).sty {
|
||||
span_lint(cx, MUT_MUT, expr.span,
|
||||
"This expression mutably borrows a mutable reference. \
|
||||
Consider reborrowing")
|
||||
"this expression mutably borrows a mutable reference. \
|
||||
Consider reborrowing.")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -34,10 +34,10 @@ fn check_expr(&mut self, cx: &Context, e: &Expr) {
|
||||
"your if-then-else expression will always return true"); },
|
||||
(Option::Some(true), Option::Some(false)) => {
|
||||
span_lint(cx, NEEDLESS_BOOL, e.span,
|
||||
"you can reduce your if-statement to its predicate"); },
|
||||
"you can reduce your if statement to its predicate"); },
|
||||
(Option::Some(false), Option::Some(true)) => {
|
||||
span_lint(cx, NEEDLESS_BOOL, e.span,
|
||||
"you can reduce your if-statement to '!' + your predicate"); },
|
||||
"you can reduce your if statement to `!` + your predicate"); },
|
||||
(Option::Some(false), Option::Some(false)) => {
|
||||
span_lint(cx, NEEDLESS_BOOL, e.span,
|
||||
"your if-then-else expression will always return false"); },
|
||||
|
@ -60,10 +60,10 @@ fn check_ptr_subtype(cx: &Context, span: Span, ty: &Ty) {
|
||||
match_ty_unwrap(ty, &["Vec"]).map_or_else(|| match_ty_unwrap(ty,
|
||||
&["String"]).map_or((), |_| {
|
||||
span_lint(cx, PTR_ARG, span,
|
||||
"Writing '&String' instead of '&str' involves a new Object \
|
||||
where a slices will do. Consider changing the type to &str")
|
||||
"writing `&String` instead of `&str` involves a new object \
|
||||
where a slice will do. Consider changing the type to `&str`.")
|
||||
}), |_| span_lint(cx, PTR_ARG, span,
|
||||
"Writing '&Vec<_>' instead of \
|
||||
'&[_]' involves one more reference and cannot be used with \
|
||||
non-vec-based slices. Consider changing the type to &[...]"))
|
||||
"writing `&Vec<_>` instead of \
|
||||
`&[_]` involves one more reference and cannot be used with \
|
||||
non-Vec-based slices. Consider changing the type to `&[...]`."))
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ fn check_final_expr(&mut self, cx: &Context, expr: &Expr) {
|
||||
|
||||
fn emit_return_lint(&mut self, cx: &Context, spans: (Span, Span)) {
|
||||
span_lint(cx, NEEDLESS_RETURN, spans.0, &format!(
|
||||
"unneeded return statement. Consider using {} \
|
||||
"unneeded return statement. Consider using `{}` \
|
||||
without the trailing semicolon",
|
||||
snippet(cx, spans.1, "..")))
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ fn check_expr(&mut self, cx: &Context, e: &Expr) {
|
||||
if let &ExprAssign(ref target, ref src) = &e.node {
|
||||
if is_string(cx, target) && is_add(src, target) {
|
||||
span_lint(cx, STRING_ADD_ASSIGN, e.span,
|
||||
"You assign the result of adding something to this string. \
|
||||
Consider using `String::push_str(..) instead.")
|
||||
"you assign the result of adding something to this string. \
|
||||
Consider using `String::push_str()` instead.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
use syntax::ptr::P;
|
||||
use syntax::ast;
|
||||
use syntax::ast::*;
|
||||
@ -55,8 +53,8 @@ fn check_ty(&mut self, cx: &Context, ty: &ast::Ty) {
|
||||
.and_then(|t| match_ty_unwrap(&**t, &["std", "vec", "Vec"]))
|
||||
.map(|_| {
|
||||
span_help_and_lint(cx, BOX_VEC, ty.span,
|
||||
"You seem to be trying to use Box<Vec<T>>. Did you mean to use Vec<T>?",
|
||||
"Vec<T> is already on the heap, Box<Vec<T>> makes an extra allocation");
|
||||
"you seem to be trying to use `Box<Vec<T>>`. Did you mean to use `Vec<T>`?",
|
||||
"`Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation");
|
||||
});
|
||||
{
|
||||
// In case stuff gets moved around
|
||||
@ -71,7 +69,7 @@ fn check_ty(&mut self, cx: &Context, ty: &ast::Ty) {
|
||||
if match_ty_unwrap(ty, &path[..]).is_some() {
|
||||
span_help_and_lint(cx, LINKEDLIST, ty.span,
|
||||
"I see you're using a LinkedList! Perhaps you meant some other data structure?",
|
||||
"A RingBuf might work.");
|
||||
"a RingBuf might work");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ fn lint_zero_width(cx: &Context, span: Span, start: Option<usize>) {
|
||||
lo: span.lo + BytePos(index as u32),
|
||||
hi: span.lo + BytePos(index as u32),
|
||||
expn_id: span.expn_id,
|
||||
}, "Zero-width space detected. Consider using \\u{200B}")
|
||||
}, "zero-width space detected. Consider using `\\u{200B}`.")
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#![deny(inline_always)]
|
||||
|
||||
#[inline(always)] //~ERROR You have declared #[inline(always)] on test_attr_lint.
|
||||
#[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`.
|
||||
fn test_attr_lint() {
|
||||
assert!(true)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#![plugin(clippy)]
|
||||
#![deny(clippy)]
|
||||
|
||||
pub fn test(foo: Box<Vec<bool>>) { //~ ERROR You seem to be trying to use Box<Vec<T>>
|
||||
pub fn test(foo: Box<Vec<bool>>) { //~ ERROR you seem to be trying to use `Box<Vec<T>>`
|
||||
println!("{:?}", foo.get(0))
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
fn main() {
|
||||
let x = "hello";
|
||||
let y = "world";
|
||||
if x == "hello" { //~ERROR This if statement can be collapsed
|
||||
if x == "hello" { //~ERROR this if statement can be collapsed
|
||||
if y == "world" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if x == "hello" || x == "world" { //~ERROR This if statement can be collapsed
|
||||
if x == "hello" || x == "world" { //~ERROR this if statement can be collapsed
|
||||
if y == "world" || y == "hello" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
|
8
tests/compile-fail/eta.rs
Normal file → Executable file
8
tests/compile-fail/eta.rs
Normal file → Executable file
@ -5,11 +5,11 @@
|
||||
|
||||
fn main() {
|
||||
let a = |a, b| foo(a, b);
|
||||
//~^ ERROR Redundant closure found, consider using `foo` in its place
|
||||
//~^ ERROR redundant closure found. Consider using `foo` in its place
|
||||
let c = |a, b| {1+2; foo}(a, b);
|
||||
//~^ ERROR Redundant closure found, consider using `{ 1 + 2; foo }` in its place
|
||||
//~^ ERROR redundant closure found. Consider using `{ 1 + 2; foo }` in its place
|
||||
let d = |a, b| foo((|c, d| foo2(c,d))(a,b), b);
|
||||
//~^ ERROR Redundant closure found, consider using `foo2` in its place
|
||||
//~^ ERROR redundant closure found. Consider using `foo2` in its place
|
||||
}
|
||||
|
||||
fn foo(_: u8, _: u8) {
|
||||
@ -18,4 +18,4 @@ fn foo(_: u8, _: u8) {
|
||||
|
||||
fn foo2(_: u8, _: u8) -> u8 {
|
||||
1u8
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
#[deny(len_without_is_empty)]
|
||||
impl One {
|
||||
fn len(self: &Self) -> isize { //~ERROR Item 'One' has a '.len(_: &Self)'
|
||||
fn len(self: &Self) -> isize { //~ERROR item `One` has a `.len(_: &Self)`
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
#[deny(len_without_is_empty)]
|
||||
trait TraitsToo {
|
||||
fn len(self: &Self) -> isize; //~ERROR Trait 'TraitsToo' has a '.len(_:
|
||||
fn len(self: &Self) -> isize; //~ERROR trait `TraitsToo` has a `.len(_:
|
||||
}
|
||||
|
||||
impl TraitsToo for One {
|
||||
@ -56,7 +56,7 @@ fn is_empty(self: &Self) -> bool {
|
||||
|
||||
#[deny(len_without_is_empty)]
|
||||
impl HasWrongIsEmpty {
|
||||
fn len(self: &Self) -> isize { //~ERROR Item 'HasWrongIsEmpty' has a '.len(_: &Self)'
|
||||
fn len(self: &Self) -> isize { //~ERROR item `HasWrongIsEmpty` has a `.len(_: &Self)`
|
||||
1
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ fn is_empty(self: &Self, x : u32) -> bool {
|
||||
#[deny(len_zero)]
|
||||
fn main() {
|
||||
let x = [1, 2];
|
||||
if x.len() == 0 { //~ERROR Consider replacing the len comparison
|
||||
if x.len() == 0 { //~ERROR consider replacing the len comparison
|
||||
println!("This should not happen!");
|
||||
}
|
||||
|
||||
@ -84,13 +84,13 @@ fn main() {
|
||||
}
|
||||
|
||||
let hie = HasIsEmpty;
|
||||
if hie.len() == 0 { //~ERROR Consider replacing the len comparison
|
||||
if hie.len() == 0 { //~ERROR consider replacing the len comparison
|
||||
println!("Or this!");
|
||||
}
|
||||
assert!(!hie.is_empty());
|
||||
|
||||
let wie : &WithIsEmpty = &Wither;
|
||||
if wie.len() == 0 { //~ERROR Consider replacing the len comparison
|
||||
if wie.len() == 0 { //~ERROR consider replacing the len comparison
|
||||
println!("Or this!");
|
||||
}
|
||||
assert!(!wie.is_empty());
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
fn main(){
|
||||
let x = Some(1u8);
|
||||
match x { //~ ERROR You seem to be trying to use match
|
||||
//~^ HELP Try
|
||||
match x { //~ ERROR you seem to be trying to use match
|
||||
//~^ HELP try
|
||||
Some(y) => {
|
||||
println!("{:?}", y);
|
||||
}
|
||||
@ -18,8 +18,8 @@ fn main(){
|
||||
None => ()
|
||||
}
|
||||
let z = (1u8,1u8);
|
||||
match z { //~ ERROR You seem to be trying to use match
|
||||
//~^ HELP Try
|
||||
match z { //~ ERROR you seem to be trying to use match
|
||||
//~^ HELP try
|
||||
(2...3, 7...9) => println!("{:?}", z),
|
||||
_ => {}
|
||||
}
|
||||
|
2
tests/compile-fail/modulo_one.rs
Normal file → Executable file
2
tests/compile-fail/modulo_one.rs
Normal file → Executable file
@ -3,6 +3,6 @@
|
||||
#![deny(modulo_one)]
|
||||
|
||||
fn main() {
|
||||
10 % 1; //~ERROR Any number modulo 1 will be 0
|
||||
10 % 1; //~ERROR any number modulo 1 will be 0
|
||||
10 % 2;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#[deny(ptr_arg)]
|
||||
#[allow(unused)]
|
||||
fn do_vec(x: &Vec<i64>) { //~ERROR: Writing '&Vec<_>' instead of '&[_]'
|
||||
fn do_vec(x: &Vec<i64>) { //~ERROR: writing `&Vec<_>` instead of `&[_]`
|
||||
//Nothing here
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
#[deny(zero_width_space)]
|
||||
fn zero() {
|
||||
print!("Here >< is a ZWS, and another");
|
||||
//~^ ERROR Zero-width space detected. Consider using \u{200B}
|
||||
//~^^ ERROR Zero-width space detected. Consider using \u{200B}
|
||||
//~^ ERROR zero-width space detected. Consider using `\u{200B}`
|
||||
//~^^ ERROR zero-width space detected. Consider using `\u{200B}`
|
||||
}
|
||||
|
||||
//#[deny(unicode_canon)]
|
||||
fn canon() {
|
||||
print!("̀ah?"); //not yet ~ERROR Non-canonical unicode sequence detected. Consider using à
|
||||
print!("̀ah?"); //not yet ~ERROR non-canonical unicode sequence detected. Consider using à
|
||||
}
|
||||
|
||||
//#[deny(ascii_only)]
|
||||
|
Loading…
Reference in New Issue
Block a user