Skip to content

Commit cb7915b

Browse files
committed
Auto merge of #7733 - flip1995:rustup, r=flip1995
Rustup This needs a review this time. Especially rust-lang/rust-clippy@521bf8f cc `@camsteffen` I think this is necessary now, because `itertools` is no longer a dependency of `clippy_utils` and therefore this path can't be found 🤔 ( I forgot about the sync last week. I should get to document this process better, so other people can do it when I'm not around ) changelog: none
2 parents 08cead3 + c2b8882 commit cb7915b

38 files changed

+127
-169
lines changed

Cargo.toml

+10-12
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,35 @@ name = "clippy-driver"
2121
path = "src/driver.rs"
2222

2323
[dependencies]
24-
# begin automatic update
25-
clippy_lints = { version = "0.1.50", path = "clippy_lints" }
26-
# end automatic update
24+
clippy_lints = { version = "0.1", path = "clippy_lints" }
2725
semver = "0.11"
28-
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
29-
tempfile = { version = "3.1.0", optional = true }
26+
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
27+
tempfile = { version = "3.2", optional = true }
3028

3129
[dev-dependencies]
3230
cargo_metadata = "0.12"
33-
compiletest_rs = { version = "0.6.0", features = ["tmp"] }
31+
compiletest_rs = { version = "0.7", features = ["tmp"] }
3432
tester = "0.9"
35-
regex = "1.4"
33+
regex = "1.5"
3634
# This is used by the `collect-metadata` alias.
3735
filetime = "0.2"
3836

3937
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
4038
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
4139
# for more information.
42-
rustc-workspace-hack = "1.0.0"
40+
rustc-workspace-hack = "1.0"
4341

4442
# UI test dependencies
4543
clippy_utils = { path = "clippy_utils" }
4644
derive-new = "0.5"
4745
if_chain = "1.0"
48-
itertools = "0.10.1"
49-
quote = "1"
46+
itertools = "0.10"
47+
quote = "1.0"
5048
serde = { version = "1.0", features = ["derive"] }
51-
syn = { version = "1", features = ["full"] }
49+
syn = { version = "1.0", features = ["full"] }
5250

5351
[build-dependencies]
54-
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
52+
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
5553

5654
[features]
5755
deny-warnings = ["clippy_lints/deny-warnings"]

clippy_dev/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ edition = "2021"
66
[dependencies]
77
bytecount = "0.6"
88
clap = "2.33"
9-
itertools = "0.9"
9+
itertools = "0.10"
1010
opener = "0.5"
11-
regex = "1"
11+
regex = "1.5"
1212
shell-escape = "0.1"
13-
walkdir = "2"
13+
walkdir = "2.3"
1414

1515
[features]
1616
deny-warnings = []

clippy_dummy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ keywords = ["clippy", "lint", "plugin"]
1313
categories = ["development-tools", "development-tools::cargo-plugins"]
1414

1515
[build-dependencies]
16-
term = "0.6"
16+
term = "0.7"

clippy_lints/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ edition = "2021"
1111
[dependencies]
1212
cargo_metadata = "0.12"
1313
clippy_utils = { path = "../clippy_utils" }
14-
if_chain = "1.0.0"
15-
itertools = "0.9"
14+
if_chain = "1.0"
15+
itertools = "0.10"
1616
pulldown-cmark = { version = "0.8", default-features = false }
17-
quine-mc_cluskey = "0.2.2"
17+
quine-mc_cluskey = "0.2"
1818
regex-syntax = "0.6"
1919
serde = { version = "1.0", features = ["derive"] }
2020
serde_json = { version = "1.0", optional = true }
21-
toml = "0.5.3"
21+
toml = "0.5"
2222
unicode-normalization = "0.1"
23-
unicode-script = { version = "0.5.3", default-features = false }
23+
unicode-script = { version = "0.5", default-features = false }
2424
semver = "0.11"
25-
rustc-semver = "1.1.0"
25+
rustc-semver = "1.1"
2626
# NOTE: cargo requires serde feat in its url dep
2727
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
28-
url = { version = "2.1.0", features = ["serde"] }
28+
url = { version = "2.2", features = ["serde"] }
2929

3030
[features]
3131
deny-warnings = ["clippy_utils/deny-warnings"]

clippy_lints/src/attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
527527
return;
528528
}
529529

530-
let begin_of_attr_to_item = Span::new(attr.span.lo(), item.span.lo(), item.span.ctxt());
531-
let end_of_attr_to_item = Span::new(attr.span.hi(), item.span.lo(), item.span.ctxt());
530+
let begin_of_attr_to_item = Span::new(attr.span.lo(), item.span.lo(), item.span.ctxt(), item.span.parent());
531+
let end_of_attr_to_item = Span::new(attr.span.hi(), item.span.lo(), item.span.ctxt(), item.span.parent());
532532

533533
if let Some(snippet) = snippet_opt(cx, end_of_attr_to_item) {
534534
let lines = snippet.split('\n').collect::<Vec<_>>();

clippy_lints/src/cargo_common_metadata.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! lint on missing cargo common metadata
22
3-
use std::path::PathBuf;
4-
53
use clippy_utils::{diagnostics::span_lint, is_lint_allowed};
64
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
75
use rustc_lint::{LateContext, LateLintPass};
@@ -69,12 +67,8 @@ fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, fiel
6967
span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message);
7068
}
7169

72-
fn is_empty_str(value: &Option<String>) -> bool {
73-
value.as_ref().map_or(true, String::is_empty)
74-
}
75-
76-
fn is_empty_path(value: &Option<PathBuf>) -> bool {
77-
value.as_ref().and_then(|x| x.to_str()).map_or(true, str::is_empty)
70+
fn is_empty_str<T: AsRef<std::ffi::OsStr>>(value: &Option<T>) -> bool {
71+
value.as_ref().map_or(true, |s| s.as_ref().is_empty())
7872
}
7973

8074
fn is_empty_vec(value: &[String]) -> bool {
@@ -98,15 +92,15 @@ impl LateLintPass<'_> for CargoCommonMetadata {
9892
missing_warning(cx, &package, "package.description");
9993
}
10094

101-
if is_empty_str(&package.license) && is_empty_path(&package.license_file) {
95+
if is_empty_str(&package.license) && is_empty_str(&package.license_file) {
10296
missing_warning(cx, &package, "either package.license or package.license_file");
10397
}
10498

10599
if is_empty_str(&package.repository) {
106100
missing_warning(cx, &package, "package.repository");
107101
}
108102

109-
if is_empty_path(&package.readme) {
103+
if is_empty_str(&package.readme) {
110104
missing_warning(cx, &package, "package.readme");
111105
}
112106

clippy_lints/src/cognitive_complexity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CognitiveComplexity {
9595
});
9696

9797
if let Some((low, high)) = pos {
98-
Span::new(low, high, header_span.ctxt())
98+
Span::new(low, high, header_span.ctxt(), header_span.parent())
9999
} else {
100100
return;
101101
}

clippy_lints/src/copies.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn emit_branches_sharing_code_lint(
472472

473473
let mut span = moved_start.to(span_end);
474474
// Improve formatting if the inner block has indention (i.e. normal Rust formatting)
475-
let test_span = Span::new(span.lo() - BytePos(4), span.lo(), span.ctxt());
475+
let test_span = Span::new(span.lo() - BytePos(4), span.lo(), span.ctxt(), span.parent());
476476
if snippet_opt(cx, test_span)
477477
.map(|snip| snip == " ")
478478
.unwrap_or_default()

clippy_lints/src/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ fn check_text(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, text: &str
665665
span.lo() + BytePos::from_usize(offset),
666666
span.lo() + BytePos::from_usize(offset + word.len()),
667667
span.ctxt(),
668+
span.parent(),
668669
);
669670

670671
check_word(cx, word, span);

clippy_lints/src/escape.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
9191
if trait_item.id.hir_id() == hir_id {
9292
// be sure we have `self` parameter in this function
9393
if let AssocItemKind::Fn { has_self: true } = trait_item.kind {
94-
trait_self_ty =
95-
Some(TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id()).self_ty());
94+
trait_self_ty = Some(
95+
TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id())
96+
.self_ty()
97+
.skip_binder(),
98+
);
9699
}
97100
}
98101
}

clippy_lints/src/fallible_impl_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom {
6565
}
6666
}
6767

68-
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef<'_>]) {
68+
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[hir::ImplItemRef]) {
6969
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
7070
use rustc_hir::{Expr, ExprKind, ImplItemKind, QPath};
7171

clippy_lints/src/implicit_hasher.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
130130
let pos = snippet_opt(cx, item.span.until(target.span()))
131131
.and_then(|snip| Some(item.span.lo() + BytePos(snip.find("impl")? as u32 + 4)));
132132
if let Some(pos) = pos {
133-
Span::new(pos, pos, item.span.data().ctxt)
133+
Span::new(pos, pos, item.span.ctxt(), item.span.parent())
134134
} else {
135135
return;
136136
}
@@ -173,7 +173,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher {
173173
Some(item.span.lo() + BytePos((i + (&snip[i..]).find('(')?) as u32))
174174
})
175175
.expect("failed to create span for type parameters");
176-
Span::new(pos, pos, item.span.data().ctxt)
176+
Span::new(pos, pos, item.span.ctxt(), item.span.parent())
177177
});
178178

179179
let mut ctr_vis = ImplicitHasherConstructorVisitor::new(cx, target);

clippy_lints/src/large_const_arrays.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
6363
hi_pos - BytePos::from_usize("const".len()),
6464
hi_pos,
6565
item.span.ctxt(),
66+
item.span.parent(),
6667
);
6768
span_lint_and_then(
6869
cx,

clippy_lints/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern crate rustc_infer;
3131
extern crate rustc_lexer;
3232
extern crate rustc_lint;
3333
extern crate rustc_middle;
34-
extern crate rustc_mir;
34+
extern crate rustc_mir_dataflow;
3535
extern crate rustc_parse;
3636
extern crate rustc_parse_format;
3737
extern crate rustc_session;
@@ -1961,7 +1961,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
19611961
store.register_late_pass(|| Box::new(empty_enum::EmptyEnum));
19621962
store.register_late_pass(|| Box::new(absurd_extreme_comparisons::AbsurdExtremeComparisons));
19631963
store.register_late_pass(|| Box::new(invalid_upcast_comparisons::InvalidUpcastComparisons));
1964-
store.register_late_pass(|| Box::new(regex::Regex::default()));
1964+
store.register_late_pass(|| Box::new(regex::Regex));
19651965
store.register_late_pass(|| Box::new(copies::CopyAndPaste));
19661966
store.register_late_pass(|| Box::new(copy_iterator::CopyIterator));
19671967
store.register_late_pass(|| Box::new(format::UselessFormat));

clippy_lints/src/loops/for_kv_map.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ use rustc_middle::ty;
1010
use rustc_span::sym;
1111

1212
/// Checks for the `FOR_KV_MAP` lint.
13-
pub(super) fn check<'tcx>(
14-
cx: &LateContext<'tcx>,
15-
pat: &'tcx Pat<'_>,
16-
arg: &'tcx Expr<'_>,
17-
body: &'tcx Expr<'_>,
18-
expr: &'tcx Expr<'_>,
19-
) {
13+
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>, arg: &'tcx Expr<'_>, body: &'tcx Expr<'_>) {
2014
let pat_span = pat.span;
2115

2216
if let PatKind::Tuple(pat, _) = pat.kind {
@@ -43,7 +37,7 @@ pub(super) fn check<'tcx>(
4337
span_lint_and_then(
4438
cx,
4539
FOR_KV_MAP,
46-
expr.span,
40+
arg_span,
4741
&format!("you seem to want to iterate on a map's {}s", kind),
4842
|diag| {
4943
let map = sugg::Sugg::hir(cx, arg, "map");

clippy_lints/src/loops/iter_next_loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use rustc_hir::Expr;
55
use rustc_lint::LateContext;
66
use rustc_span::sym;
77

8-
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, expr: &Expr<'_>) -> bool {
8+
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>) -> bool {
99
if is_trait_method(cx, arg, sym::Iterator) {
1010
span_lint(
1111
cx,
1212
ITER_NEXT_LOOP,
13-
expr.span,
13+
arg.span,
1414
"you are iterating over `Iterator::next()` which is an Option; this will compile but is \
1515
probably not what you want",
1616
);

clippy_lints/src/loops/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -616,15 +616,15 @@ fn check_for_loop<'tcx>(
616616
needless_range_loop::check(cx, pat, arg, body, expr);
617617
explicit_counter_loop::check(cx, pat, arg, body, expr);
618618
}
619-
check_for_loop_arg(cx, pat, arg, expr);
620-
for_kv_map::check(cx, pat, arg, body, expr);
619+
check_for_loop_arg(cx, pat, arg);
620+
for_kv_map::check(cx, pat, arg, body);
621621
mut_range_bound::check(cx, arg, body);
622622
single_element_loop::check(cx, pat, arg, body, expr);
623623
same_item_push::check(cx, pat, arg, body, expr);
624624
manual_flatten::check(cx, pat, arg, body, span);
625625
}
626626

627-
fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr: &Expr<'_>) {
627+
fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
628628
let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
629629

630630
if let ExprKind::MethodCall(method, _, [self_arg], _) = arg.kind {
@@ -637,7 +637,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>, expr:
637637
explicit_into_iter_loop::check(cx, self_arg, arg);
638638
},
639639
"next" => {
640-
next_loop_linted = iter_next_loop::check(cx, arg, expr);
640+
next_loop_linted = iter_next_loop::check(cx, arg);
641641
},
642642
_ => {},
643643
}

clippy_lints/src/loops/needless_range_loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub(super) fn check<'tcx>(
144144
span_lint_and_then(
145145
cx,
146146
NEEDLESS_RANGE_LOOP,
147-
expr.span,
147+
arg.span,
148148
&format!("the loop variable `{}` is used to index `{}`", ident.name, indexed),
149149
|diag| {
150150
multispan_sugg(
@@ -170,7 +170,7 @@ pub(super) fn check<'tcx>(
170170
span_lint_and_then(
171171
cx,
172172
NEEDLESS_RANGE_LOOP,
173-
expr.span,
173+
arg.span,
174174
&format!("the loop variable `{}` is only used to index `{}`", ident.name, indexed),
175175
|diag| {
176176
multispan_sugg(

clippy_lints/src/loops/while_let_on_iterator.rs

-4
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
6969
struct IterExpr {
7070
/// The span of the whole expression, not just the path and fields stored here.
7171
span: Span,
72-
/// The HIR id of the whole expression, not just the path and fields stored here.
73-
hir_id: HirId,
7472
/// The fields used, in order of child to parent.
7573
fields: Vec<Symbol>,
7674
/// The path being used.
@@ -81,14 +79,12 @@ struct IterExpr {
8179
/// the expression might have side effects.
8280
fn try_parse_iter_expr(cx: &LateContext<'_>, mut e: &Expr<'_>) -> Option<IterExpr> {
8381
let span = e.span;
84-
let hir_id = e.hir_id;
8582
let mut fields = Vec::new();
8683
loop {
8784
match e.kind {
8885
ExprKind::Path(ref path) => {
8986
break Some(IterExpr {
9087
span,
91-
hir_id,
9288
fields,
9389
path: cx.qpath_res(path, e.hir_id),
9490
});

0 commit comments

Comments
 (0)