]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to *1.10.0-nightly (764ef92ae 2016-05-19)*
authormcarton <cartonmartin+git@gmail.com>
Fri, 20 May 2016 17:18:32 +0000 (19:18 +0200)
committermcarton <cartonmartin+git@gmail.com>
Mon, 23 May 2016 14:11:28 +0000 (16:11 +0200)
src/methods.rs
src/vec.rs
tests/compile-fail/methods.rs
tests/compile-fail/mut_mut.rs

index 14bc74d467f05d3b0e83d9b63a93a617c7b4980f..f9f557e7a9a254111b5d080523c27fe092a84eb3 100644 (file)
@@ -511,7 +511,7 @@ fn check_general_case(cx: &LateContext, name: &str, fun: &hir::Expr, self_expr:
                 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,
index 63b9952c3c824a6995d69bbd110d3948607b25c1..e62a8f9c45955ec9382cb9c4078483a1f6e24f99 100644 (file)
@@ -38,17 +38,19 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
             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) => {
@@ -69,8 +71,8 @@ fn check_vec_macro(cx: &LateContext, expr: &Expr, vec: &Expr) {
             }
         };
 
-        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);
         });
     }
 }
index 88a1e7c4cf24e1f3d84b0cb4229efdfeefc7c0a0..9753c021372083ab34da3ad85f19e2aacb951e98 100644 (file)
@@ -288,7 +288,7 @@ const fn make_const(i: i32) -> i32 { i }
     with_vec.unwrap_or(vec![]);
     //~^ERROR use of `unwrap_or`
     //~|HELP try this
-    //~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
+    // FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
 
     let without_default = Some(Foo);
     without_default.unwrap_or(Foo::new());
index 865574eaec02b4fc85ab336f0ab366927b973844..8d9bceb0d0d8ad1ae48c22efb0457ef40316bbe0 100644 (file)
@@ -18,6 +18,7 @@ fn less_fun(x : *mut *mut u32) {
 
 macro_rules! mut_ptr {
     ($p:expr) => { &mut $p }
+    //~^ ERROR generally you want to avoid `&mut &mut
 }
 
 #[deny(mut_mut)]
@@ -30,12 +31,12 @@ fn main() {
 
     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!
 }