Skip to content

Commit d70e7bb

Browse files
committed
Merge pull request #906 from Manishearth/birkenfeld-master
Rustup to *rustc 1.10.0-nightly (62e2b2f 2016-05-06)*
2 parents eb5d87c + 7566484 commit d70e7bb

File tree

10 files changed

+47
-45
lines changed

10 files changed

+47
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.65 — 2016-05-08
5+
* Rustup to *rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)*
6+
* New lints: [`float_arithmetic`], [`integer_arithmetic`]
7+
48
## 0.0.64 — 2016-04-26
59
* Rustup to *rustc 1.10.0-nightly (645dd013a 2016-04-24)*
610
* New lints: [`temporary_cstring_as_ptr`], [`unsafe_removed_from_name`], and [`mem_forget`]

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.64"
3+
version = "0.0.65"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",

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/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ fn lint_cstring_as_ptr(cx: &LateContext, expr: &Expr, new: &Expr, unwrap: &Expr)
602602
span_lint_and_then(cx, TEMPORARY_CSTRING_AS_PTR, expr.span,
603603
"you are getting the inner pointer of a temporary `CString`",
604604
|db| {
605-
db.fileline_note(expr.span, "that pointer will be invalid outside this expression");
605+
db.note("that pointer will be invalid outside this expression");
606606
db.span_help(unwrap.span, "assign the `CString` to a variable to extend its lifetime");
607607
});
608608
}}

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

src/swap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
9595
if !what.is_empty() {
9696
db.span_suggestion(span, "try",
9797
format!("std::mem::swap(&mut {}, &mut {})", lhs, rhs));
98-
db.fileline_note(span, "or maybe you should use `std::mem::replace`?");
98+
db.note("or maybe you should use `std::mem::replace`?");
9999
}
100100
});
101101
}}
@@ -130,7 +130,7 @@ fn check_suspicious_swap(cx: &LateContext, block: &Block) {
130130
if !what.is_empty() {
131131
db.span_suggestion(span, "try",
132132
format!("std::mem::swap(&mut {}, &mut {})", lhs, rhs));
133-
db.fileline_note(span, "or maybe you should use `std::mem::replace`?");
133+
db.note("or maybe you should use `std::mem::replace`?");
134134
}
135135
});
136136
}}

src/utils/mod.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -471,44 +471,44 @@ impl<'a> Deref for DiagnosticWrapper<'a> {
471471
}
472472
}
473473

474+
impl<'a> DiagnosticWrapper<'a> {
475+
fn wiki_link(&mut self, lint: &'static Lint) {
476+
self.help(&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
477+
lint.name_lower()));
478+
}
479+
}
480+
474481
pub fn span_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str) -> DiagnosticWrapper<'a> {
475-
let mut db = cx.struct_span_lint(lint, sp, msg);
482+
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg));
476483
if cx.current_level(lint) != Level::Allow {
477-
db.fileline_help(sp,
478-
&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
479-
lint.name_lower()));
484+
db.wiki_link(lint);
480485
}
481-
DiagnosticWrapper(db)
486+
db
482487
}
483488

484489
pub fn span_help_and_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, help: &str)
485490
-> DiagnosticWrapper<'a> {
486-
let mut db = cx.struct_span_lint(lint, span, msg);
491+
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg));
487492
if cx.current_level(lint) != Level::Allow {
488-
db.fileline_help(span,
489-
&format!("{}\nfor further information visit \
490-
https://github.com/Manishearth/rust-clippy/wiki#{}",
491-
help,
492-
lint.name_lower()));
493+
db.help(help);
494+
db.wiki_link(lint);
493495
}
494-
DiagnosticWrapper(db)
496+
db
495497
}
496498

497499
pub fn span_note_and_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, note_span: Span,
498500
note: &str)
499501
-> DiagnosticWrapper<'a> {
500-
let mut db = cx.struct_span_lint(lint, span, msg);
502+
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg));
501503
if cx.current_level(lint) != Level::Allow {
502504
if note_span == span {
503-
db.fileline_note(note_span, note);
505+
db.note(note);
504506
} else {
505507
db.span_note(note_span, note);
506508
}
507-
db.fileline_help(span,
508-
&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
509-
lint.name_lower()));
509+
db.wiki_link(lint);
510510
}
511-
DiagnosticWrapper(db)
511+
db
512512
}
513513

514514
pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F)
@@ -518,9 +518,7 @@ pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint,
518518
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg));
519519
if cx.current_level(lint) != Level::Allow {
520520
f(&mut db);
521-
db.fileline_help(sp,
522-
&format!("for further information visit https://github.com/Manishearth/rust-clippy/wiki#{}",
523-
lint.name_lower()));
521+
db.wiki_link(lint);
524522
}
525523
db
526524
}

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)