mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-11 17:37:41 +00:00
Fix tests
This commit is contained in:
parent
ca743ecb77
commit
aa10c93e8f
@ -113,14 +113,9 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItem]) {
|
|||||||
if is_named_self(i, "len") {
|
if is_named_self(i, "len") {
|
||||||
let ty = cx.tcx.node_id_to_type(item.id);
|
let ty = cx.tcx.node_id_to_type(item.id);
|
||||||
|
|
||||||
let s = i.span;
|
|
||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
LEN_WITHOUT_IS_EMPTY,
|
LEN_WITHOUT_IS_EMPTY,
|
||||||
Span {
|
i.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. \
|
&format!("item `{}` has a `.len(_: &Self)` method, but no `.is_empty(_: &Self)` method. \
|
||||||
Consider adding one",
|
Consider adding one",
|
||||||
ty));
|
ty));
|
||||||
|
15
src/regex.rs
15
src/regex.rs
@ -143,16 +143,19 @@ impl LateLintPass for RegexPass {
|
|||||||
|
|
||||||
#[allow(cast_possible_truncation)]
|
#[allow(cast_possible_truncation)]
|
||||||
fn str_span(base: Span, s: &str, c: usize) -> Span {
|
fn str_span(base: Span, s: &str, c: usize) -> Span {
|
||||||
let lo = match s.char_indices().nth(c) {
|
let mut si = s.char_indices().skip(c);
|
||||||
Some((b, _)) => base.lo + BytePos(b as u32),
|
|
||||||
_ => base.hi,
|
match (si.next(), si.next()) {
|
||||||
};
|
(Some((l, _)), Some((h, _))) => {
|
||||||
Span {
|
Span {
|
||||||
lo: lo,
|
lo: base.lo + BytePos(l as u32),
|
||||||
hi: lo,
|
hi: base.lo + BytePos(h as u32),
|
||||||
..base
|
..base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => base,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn const_str(cx: &LateContext, e: &Expr) -> Option<InternedString> {
|
fn const_str(cx: &LateContext, e: &Expr) -> Option<InternedString> {
|
||||||
match eval_const_expr_partial(cx.tcx, e, ExprTypeChecked, None) {
|
match eval_const_expr_partial(cx.tcx, e, ExprTypeChecked, None) {
|
||||||
|
@ -340,7 +340,7 @@ fn main() {
|
|||||||
for (_, v) in &m {
|
for (_, v) in &m {
|
||||||
//~^ you seem to want to iterate on a map's values
|
//~^ you seem to want to iterate on a map's values
|
||||||
//~| HELP use the corresponding method
|
//~| HELP use the corresponding method
|
||||||
//~| SUGGESTION for v in &m.values()
|
//~| SUGGESTION for v in m.values()
|
||||||
let _v = v;
|
let _v = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ fn ref_pats() {
|
|||||||
match v {
|
match v {
|
||||||
//~^ERROR add `&` to all patterns
|
//~^ERROR add `&` to all patterns
|
||||||
//~|HELP instead of
|
//~|HELP instead of
|
||||||
//~|SUGGESTION `match *v { .. }`
|
//~|SUGGESTION match *v { .. }
|
||||||
&Some(v) => println!("{:?}", v),
|
&Some(v) => println!("{:?}", v),
|
||||||
&None => println!("none"),
|
&None => println!("none"),
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ fn ref_pats() {
|
|||||||
match tup {
|
match tup {
|
||||||
//~^ERROR add `&` to all patterns
|
//~^ERROR add `&` to all patterns
|
||||||
//~|HELP instead of
|
//~|HELP instead of
|
||||||
//~|SUGGESTION `match *tup { .. }`
|
//~|SUGGESTION match *tup { .. }
|
||||||
&(v, 1) => println!("{}", v),
|
&(v, 1) => println!("{}", v),
|
||||||
_ => println!("none"),
|
_ => println!("none"),
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ fn ref_pats() {
|
|||||||
match &w {
|
match &w {
|
||||||
//~^ERROR add `&` to both
|
//~^ERROR add `&` to both
|
||||||
//~|HELP try
|
//~|HELP try
|
||||||
//~|SUGGESTION `match w { .. }`
|
//~|SUGGESTION match w { .. }
|
||||||
&Some(v) => println!("{:?}", v),
|
&Some(v) => println!("{:?}", v),
|
||||||
&None => println!("none"),
|
&None => println!("none"),
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ fn ref_pats() {
|
|||||||
if let &None = a {
|
if let &None = a {
|
||||||
//~^ERROR add `&` to all patterns
|
//~^ERROR add `&` to all patterns
|
||||||
//~|HELP instead of
|
//~|HELP instead of
|
||||||
//~|SUGGESTION `if let ... = *a { .. }`
|
//~|SUGGESTION if let .. = *a { .. }
|
||||||
println!("none");
|
println!("none");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ fn ref_pats() {
|
|||||||
if let &None = &b {
|
if let &None = &b {
|
||||||
//~^ERROR add `&` to both
|
//~^ERROR add `&` to both
|
||||||
//~|HELP try
|
//~|HELP try
|
||||||
//~|SUGGESTION `if let ... = b { .. }`
|
//~|SUGGESTION if let .. = b { .. }
|
||||||
println!("none");
|
println!("none");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ fn syntax_error() {
|
|||||||
//~^ERROR: regex syntax error: empty alternate
|
//~^ERROR: regex syntax error: empty alternate
|
||||||
let wrong_char_ranice = Regex::new("[z-a]");
|
let wrong_char_ranice = Regex::new("[z-a]");
|
||||||
//~^ERROR: regex syntax error: invalid character class range
|
//~^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);
|
let some_regex = Regex::new(OPENING_PAREN);
|
||||||
//~^ERROR: regex syntax error on position 0: unclosed
|
//~^ERROR: regex syntax error on position 0: unclosed
|
||||||
|
Loading…
Reference in New Issue
Block a user