Skip to content

Commit aa10c93

Browse files
committed
Fix tests
1 parent ca743ec commit aa10c93

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/len_zero.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,9 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
113113
if is_named_self(i, "len") {
114114
let ty = cx.tcx.node_id_to_type(item.id);
115115

116-
let s = i.span;
117116
span_lint(cx,
118117
LEN_WITHOUT_IS_EMPTY,
119-
Span {
120-
lo: s.lo,
121-
hi: s.lo,
122-
expn_id: s.expn_id,
123-
},
118+
i.span,
124119
&format!("item `{}` has a `.len(_: &Self)` method, but no `.is_empty(_: &Self)` method. \
125120
Consider adding one",
126121
ty));

src/regex.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,17 @@ impl LateLintPass for RegexPass {
143143

144144
#[allow(cast_possible_truncation)]
145145
fn str_span(base: Span, s: &str, c: usize) -> Span {
146-
let lo = match s.char_indices().nth(c) {
147-
Some((b, _)) => base.lo + BytePos(b as u32),
148-
_ => base.hi,
149-
};
150-
Span {
151-
lo: lo,
152-
hi: lo,
153-
..base
146+
let mut si = s.char_indices().skip(c);
147+
148+
match (si.next(), si.next()) {
149+
(Some((l, _)), Some((h, _))) => {
150+
Span {
151+
lo: base.lo + BytePos(l as u32),
152+
hi: base.lo + BytePos(h as u32),
153+
..base
154+
}
155+
}
156+
_ => base,
154157
}
155158
}
156159

tests/compile-fail/for_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ fn main() {
340340
for (_, v) in &m {
341341
//~^ you seem to want to iterate on a map's values
342342
//~| HELP use the corresponding method
343-
//~| SUGGESTION for v in &m.values()
343+
//~| SUGGESTION for v in m.values()
344344
let _v = v;
345345
}
346346

tests/compile-fail/matches.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ fn ref_pats() {
140140
match v {
141141
//~^ERROR add `&` to all patterns
142142
//~|HELP instead of
143-
//~|SUGGESTION `match *v { .. }`
143+
//~|SUGGESTION match *v { .. }
144144
&Some(v) => println!("{:?}", v),
145145
&None => println!("none"),
146146
}
@@ -153,7 +153,7 @@ fn ref_pats() {
153153
match tup {
154154
//~^ERROR add `&` to all patterns
155155
//~|HELP instead of
156-
//~|SUGGESTION `match *tup { .. }`
156+
//~|SUGGESTION match *tup { .. }
157157
&(v, 1) => println!("{}", v),
158158
_ => println!("none"),
159159
}
@@ -162,7 +162,7 @@ fn ref_pats() {
162162
match &w {
163163
//~^ERROR add `&` to both
164164
//~|HELP try
165-
//~|SUGGESTION `match w { .. }`
165+
//~|SUGGESTION match w { .. }
166166
&Some(v) => println!("{:?}", v),
167167
&None => println!("none"),
168168
}
@@ -176,15 +176,15 @@ fn ref_pats() {
176176
if let &None = a {
177177
//~^ERROR add `&` to all patterns
178178
//~|HELP instead of
179-
//~|SUGGESTION `if let ... = *a { .. }`
179+
//~|SUGGESTION if let .. = *a { .. }
180180
println!("none");
181181
}
182182

183183
let b = Some(0);
184184
if let &None = &b {
185185
//~^ERROR add `&` to both
186186
//~|HELP try
187-
//~|SUGGESTION `if let ... = b { .. }`
187+
//~|SUGGESTION if let .. = b { .. }
188188
println!("none");
189189
}
190190
}

tests/compile-fail/regex.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ fn syntax_error() {
1616
//~^ERROR: regex syntax error: empty alternate
1717
let wrong_char_ranice = Regex::new("[z-a]");
1818
//~^ERROR: regex syntax error: invalid character class range
19+
let some_unicode = Regex::new("[é-è]");
20+
//~^ERROR: regex syntax error: invalid character class range
1921

2022
let some_regex = Regex::new(OPENING_PAREN);
2123
//~^ERROR: regex syntax error on position 0: unclosed

0 commit comments

Comments
 (0)