]> git.lizzy.rs Git - rust.git/commitdiff
Fix tests
authormcarton <cartonmartin+git@gmail.com>
Sat, 7 May 2016 22:56:23 +0000 (00:56 +0200)
committermcarton <cartonmartin+git@gmail.com>
Sat, 7 May 2016 23:13:05 +0000 (01:13 +0200)
src/len_zero.rs
src/regex.rs
tests/compile-fail/for_loop.rs
tests/compile-fail/matches.rs
tests/compile-fail/regex.rs

index 7a7a17bc79d19fb77e334e2bc82144b870f71567..7e9d17d643b16cd77438f2797c5d32d5450188cd 100644 (file)
@@ -113,14 +113,9 @@ fn is_named_self(item: &ImplItem, name: &str) -> bool {
             if is_named_self(i, "len") {
                 let ty = cx.tcx.node_id_to_type(item.id);
 
-                let s = i.span;
                 span_lint(cx,
                           LEN_WITHOUT_IS_EMPTY,
-                          Span {
-                              lo: s.lo,
-                              hi: s.lo,
-                              expn_id: s.expn_id,
-                          },
+                          i.span,
                           &format!("item `{}` has a `.len(_: &Self)` method, but no `.is_empty(_: &Self)` method. \
                                     Consider adding one",
                                    ty));
index 72a33757027e3aadbd54786c344d2bda68f7b4b5..e1b4237b9b2ec4baf37ffd6ec1c767ed1b577acd 100644 (file)
@@ -143,14 +143,17 @@ fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
 
 #[allow(cast_possible_truncation)]
 fn str_span(base: Span, s: &str, c: usize) -> Span {
-    let lo = match s.char_indices().nth(c) {
-        Some((b, _)) => base.lo + BytePos(b as u32),
-        _ => base.hi,
-    };
-    Span {
-        lo: lo,
-        hi: lo,
-        ..base
+    let mut si = s.char_indices().skip(c);
+
+    match (si.next(), si.next())  {
+        (Some((l, _)), Some((h, _))) => {
+            Span {
+                lo: base.lo + BytePos(l as u32),
+                hi: base.lo + BytePos(h as u32),
+                ..base
+            }
+        }
+        _ => base,
     }
 }
 
index 064f66537eb30255d5e2596cbff162f7611f24fd..2f164d1e5698dab93dbd5b212e4aa9caef2cd171 100644 (file)
@@ -340,7 +340,7 @@ fn main() {
     for (_, v) in &m {
         //~^ you seem to want to iterate on a map's values
         //~| HELP use the corresponding method
-        //~| SUGGESTION for v in &m.values()
+        //~| SUGGESTION for v in m.values()
         let _v = v;
     }
 
index f5f830fed513083c4b2e927c96716d9facb931c4..3444e49ec513604e0198916834eb6dacc5c5426a 100644 (file)
@@ -140,7 +140,7 @@ fn ref_pats() {
         match v {
             //~^ERROR add `&` to all patterns
             //~|HELP instead of
-            //~|SUGGESTION `match *v { .. }`
+            //~|SUGGESTION match *v { .. }
             &Some(v) => println!("{:?}", v),
             &None => println!("none"),
         }
@@ -153,7 +153,7 @@ fn ref_pats() {
     match tup {
         //~^ERROR add `&` to all patterns
         //~|HELP instead of
-        //~|SUGGESTION `match *tup { .. }`
+        //~|SUGGESTION match *tup { .. }
         &(v, 1) => println!("{}", v),
         _ => println!("none"),
     }
@@ -162,7 +162,7 @@ fn ref_pats() {
     match &w {
         //~^ERROR add `&` to both
         //~|HELP try
-        //~|SUGGESTION `match w { .. }`
+        //~|SUGGESTION match w { .. }
         &Some(v) => println!("{:?}", v),
         &None => println!("none"),
     }
@@ -176,7 +176,7 @@ fn ref_pats() {
     if let &None = a {
         //~^ERROR add `&` to all patterns
         //~|HELP instead of
-        //~|SUGGESTION `if let ... = *a { .. }`
+        //~|SUGGESTION if let .. = *a { .. }
         println!("none");
     }
 
@@ -184,7 +184,7 @@ fn ref_pats() {
     if let &None = &b {
         //~^ERROR add `&` to both
         //~|HELP try
-        //~|SUGGESTION `if let ... = b { .. }`
+        //~|SUGGESTION if let .. = b { .. }
         println!("none");
     }
 }
index 606c3d513b27d73764988a13d1a8e3c7ba2912cc..9cd2bc8098e5427cf4992fb013c6a30272b32184 100644 (file)
@@ -16,6 +16,8 @@ fn syntax_error() {
     //~^ERROR: regex syntax error: empty alternate
     let wrong_char_ranice = Regex::new("[z-a]");
     //~^ERROR: regex syntax error: invalid character class range
+    let some_unicode = Regex::new("[é-è]");
+    //~^ERROR: regex syntax error: invalid character class range
 
     let some_regex = Regex::new(OPENING_PAREN);
     //~^ERROR: regex syntax error on position 0: unclosed