Skip to content

Commit 73df096

Browse files
committed
Update clippy
1 parent f9a5348 commit 73df096

16 files changed

+90
-67
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ semver = "0.9"
4545
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
4646

4747
[dev-dependencies]
48-
cargo_metadata = "0.7.1"
48+
cargo_metadata = "0.8.0"
4949
compiletest_rs = { version = "0.3.22", features = ["tmp"] }
5050
lazy_static = "1.0"
5151
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }

clippy_dev/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Philipp Hansch <dev@phansch.net>"]
55
edition = "2018"
66

77
[dependencies]
8-
clap = "~2.32"
8+
clap = "2.33"
99
itertools = "0.8"
1010
regex = "1"
1111
lazy_static = "1.0"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ keywords = ["clippy", "lint", "plugin"]
1717
edition = "2018"
1818

1919
[dependencies]
20-
cargo_metadata = "0.7.1"
20+
cargo_metadata = "0.8.0"
2121
itertools = "0.8"
2222
lazy_static = "1.0.2"
2323
matches = "0.1.7"

clippy_lints/src/escape.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
7979

8080
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
8181
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
82-
ExprUseVisitor::new(&mut v, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).consume_body(body);
82+
ExprUseVisitor::new(
83+
&mut v,
84+
cx.tcx,
85+
fn_def_id,
86+
cx.param_env,
87+
region_scope_tree,
88+
cx.tables,
89+
None,
90+
)
91+
.consume_body(body);
8392

8493
for node in v.set {
8594
span_lint(

clippy_lints/src/loops.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ declare_clippy_lint! {
6161
/// **Known problems:** None.
6262
///
6363
/// **Example:**
64-
/// ```ignore
64+
/// ```rust
65+
/// let vec = vec!['a', 'b', 'c'];
6566
/// for i in 0..vec.len() {
6667
/// println!("{}", vec[i]);
6768
/// }
6869
/// ```
70+
/// Could be written as:
71+
/// ```rust
72+
/// let vec = vec!['a', 'b', 'c'];
73+
/// for i in vec {
74+
/// println!("{}", i);
75+
/// }
76+
/// ```
6977
pub NEEDLESS_RANGE_LOOP,
7078
style,
7179
"for-looping over a range of indices where an iterator over items would do"
@@ -1662,7 +1670,16 @@ fn check_for_mutation(
16621670
};
16631671
let def_id = def_id::DefId::local(body.hir_id.owner);
16641672
let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
1665-
ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(body);
1673+
ExprUseVisitor::new(
1674+
&mut delegate,
1675+
cx.tcx,
1676+
def_id,
1677+
cx.param_env,
1678+
region_scope_tree,
1679+
cx.tables,
1680+
None,
1681+
)
1682+
.walk_expr(body);
16661683
delegate.mutation_span()
16671684
}
16681685

@@ -1769,7 +1786,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
17691786
}
17701787
let res = self.cx.tables.qpath_res(seqpath, seqexpr.hir_id);
17711788
match res {
1772-
Res::Local(hir_id) | Res::Upvar(hir_id, ..) => {
1789+
Res::Local(hir_id) => {
17731790
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
17741791
let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
17751792
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
@@ -1829,24 +1846,13 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
18291846
if let QPath::Resolved(None, ref path) = *qpath;
18301847
if path.segments.len() == 1;
18311848
then {
1832-
match self.cx.tables.qpath_res(qpath, expr.hir_id) {
1833-
Res::Upvar(local_id, ..) => {
1834-
if local_id == self.var {
1835-
// we are not indexing anything, record that
1836-
self.nonindex = true;
1837-
}
1838-
}
1839-
Res::Local(local_id) =>
1840-
{
1841-
1842-
if local_id == self.var {
1843-
self.nonindex = true;
1844-
} else {
1845-
// not the correct variable, but still a variable
1846-
self.referenced.insert(path.segments[0].ident.name);
1847-
}
1849+
if let Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id) {
1850+
if local_id == self.var {
1851+
self.nonindex = true;
1852+
} else {
1853+
// not the correct variable, but still a variable
1854+
self.referenced.insert(path.segments[0].ident.name);
18481855
}
1849-
_ => {}
18501856
}
18511857
}
18521858
}
@@ -2378,7 +2384,7 @@ impl<'a, 'tcx> VarCollectorVisitor<'a, 'tcx> {
23782384
let res = self.cx.tables.qpath_res(qpath, ex.hir_id);
23792385
then {
23802386
match res {
2381-
Res::Local(node_id) | Res::Upvar(node_id, ..) => {
2387+
Res::Local(node_id) => {
23822388
self.ids.insert(node_id);
23832389
},
23842390
Res::Def(DefKind::Static, def_id) => {

clippy_lints/src/misc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,16 @@ fn is_used(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
594594
fn in_attributes_expansion(expr: &Expr) -> bool {
595595
expr.span
596596
.ctxt()
597-
.outer()
598-
.expn_info()
597+
.outer_expn_info()
599598
.map_or(false, |info| matches!(info.format, ExpnFormat::MacroAttribute(_)))
600599
}
601600

602601
/// Tests whether `res` is a variable defined outside a macro.
603602
fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool {
604-
match res {
605-
def::Res::Local(id) | def::Res::Upvar(id, ..) => !in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id)),
606-
_ => false,
603+
if let def::Res::Local(id) = res {
604+
!in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id))
605+
} else {
606+
false
607607
}
608608
}
609609

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
137137
} = {
138138
let mut ctx = MovedVariablesCtxt::new(cx);
139139
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
140-
euv::ExprUseVisitor::new(&mut ctx, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None)
141-
.consume_body(body);
140+
euv::ExprUseVisitor::new(
141+
&mut ctx,
142+
cx.tcx,
143+
fn_def_id,
144+
cx.param_env,
145+
region_scope_tree,
146+
cx.tables,
147+
None,
148+
)
149+
.consume_body(body);
142150
ctx
143151
};
144152

clippy_lints/src/panic_unimplemented.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
6969

7070
fn get_outer_span(expr: &Expr) -> Span {
7171
if_chain! {
72-
if let Some(first) = expr.span.ctxt().outer().expn_info();
73-
if let Some(second) = first.call_site.ctxt().outer().expn_info();
72+
if let Some(first) = expr.span.ctxt().outer_expn_info();
73+
if let Some(second) = first.call_site.ctxt().outer_expn_info();
7474
then {
7575
second.call_site
7676
} else {

clippy_lints/src/ranges.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ranges {
148148
then {
149149
let span = expr.span
150150
.ctxt()
151-
.outer()
152-
.expn_info()
151+
.outer_expn_info()
153152
.map_or(expr.span, |info| info.call_site);
154153
span_lint_and_then(
155154
cx,

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn attr_is_cfg(attr: &ast::Attribute) -> bool {
272272

273273
// get the def site
274274
fn get_def(span: Span) -> Option<Span> {
275-
span.ctxt().outer().expn_info().and_then(|info| info.def_site)
275+
span.ctxt().outer_expn_info().and_then(|info| info.def_site)
276276
}
277277

278278
// is this expr a `()` unit?

0 commit comments

Comments
 (0)