return;
}
}
- // (path, fn_has_argument, methods)
+ // (path, fn_has_argument, methods, suffix)
let know_types: &[(&[_], _, &[_], _)] = &[(&paths::BTREEMAP_ENTRY, false, &["or_insert"], "with"),
(&paths::HASHMAP_ENTRY, false, &["or_insert"], "with"),
(&paths::OPTION,
let TypeVariants::TySlice(..) = ty.ty.sty,
let ExprAddrOf(_, ref addressee) = expr.node,
], {
- check_vec_macro(cx, expr, addressee);
+ check_vec_macro(cx, addressee, expr.span);
}}
// search for `for _ in vec![…]`
if let Some((_, arg, _)) = recover_for_loop(expr) {
- check_vec_macro(cx, arg, arg);
+ // report the error around the `vec!` not inside `<std macros>:`
+ let span = cx.sess().codemap().source_callsite(arg.span);
+ check_vec_macro(cx, arg, span);
}
}
}
-fn check_vec_macro(cx: &LateContext, expr: &Expr, vec: &Expr) {
+fn check_vec_macro(cx: &LateContext, vec: &Expr, span: Span) {
if let Some(vec_args) = unexpand_vec(cx, vec) {
let snippet = match vec_args {
VecArgs::Repeat(elem, len) => {
}
};
- span_lint_and_then(cx, USELESS_VEC, expr.span, "useless use of `vec!`", |db| {
- db.span_suggestion(expr.span, "you can use a slice directly", snippet);
+ span_lint_and_then(cx, USELESS_VEC, span, "useless use of `vec!`", |db| {
+ db.span_suggestion(span, "you can use a slice directly", snippet);
});
}
}
macro_rules! mut_ptr {
($p:expr) => { &mut $p }
+ //~^ ERROR generally you want to avoid `&mut &mut
}
#[deny(mut_mut)]
if fun(x) {
let y : &mut &mut &mut u32 = &mut &mut &mut 2;
- //~^ ERROR generally you want to avoid `&mut &mut
- //~^^ ERROR generally you want to avoid `&mut &mut
- //~^^^ ERROR generally you want to avoid `&mut &mut
- //~^^^^ ERROR generally you want to avoid `&mut &mut
+ //~^ ERROR generally you want to avoid `&mut &mut
+ //~| ERROR generally you want to avoid `&mut &mut
+ //~| ERROR generally you want to avoid `&mut &mut
+ //~| ERROR generally you want to avoid `&mut &mut
***y + **x;
}
- let mut z = mut_ptr!(&mut 3u32); //~ERROR generally you want to avoid `&mut &mut
+ let mut z = mut_ptr!(&mut 3u32); //~ NOTE in this expansion of mut_ptr!
}