Skip to content

Commit 61eb38a

Browse files
committed
Auto merge of #7418 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 753bce3 + d446d5e commit 61eb38a

22 files changed

+49
-52
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ We have prioritization labels and a sync-blocker label, which are described belo
342342
- [P-low][p-low]: Requires attention (fix/response/evaluation) by a team member but isn't urgent.
343343
- [P-medium][p-medium]: Should be addressed by a team member until the next sync.
344344
- [P-high][p-high]: Should be immediately addressed and will require an out-of-cycle sync or a backport.
345-
- [L-sync-blocker][l-sync-blocker]: An issue that "blocks" a sync.
345+
- [L-sync-blocker][l-sync-blocker]: An issue that "blocks" a sync.
346346
Or rather: before the sync this should be addressed,
347347
e.g. by removing a lint again, so it doesn't hit beta/stable.
348348

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ As with `cargo check`, this includes dependencies that are members of the worksp
9595
If you want to run Clippy **only** on the given crate, use the `--no-deps` option like this:
9696

9797
```terminal
98-
cargo clippy -p example -- --no-deps
98+
cargo clippy -p example -- --no-deps
9999
```
100100

101101
### As a rustc replacement (`clippy-driver`)

clippy_lints/src/derive.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,8 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
410410
}
411411

412412
if let ExprKind::Block(block, _) = expr.kind {
413-
match block.rules {
414-
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided)
415-
| BlockCheckMode::PushUnsafeBlock(UnsafeSource::UserProvided)
416-
| BlockCheckMode::PopUnsafeBlock(UnsafeSource::UserProvided) => {
417-
self.has_unsafe = true;
418-
},
419-
_ => {},
413+
if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
414+
self.has_unsafe = true;
420415
}
421416
}
422417

clippy_lints/src/get_last_with_len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for GetLastWithLen {
7474

7575
// LHS of subtraction is "x.len()"
7676
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args, _) = &lhs.kind;
77-
if arg_lhs_path.ident.name == sym!(len);
77+
if arg_lhs_path.ident.name == sym::len;
7878
if let Some(arg_lhs_struct) = lhs_args.get(0);
7979

8080
// The two vectors referenced (x in x.get(...) and in x.len())

clippy_lints/src/len_zero.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
128128

129129
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
130130
if_chain! {
131-
if item.ident.as_str() == "len";
131+
if item.ident.name == sym::len;
132132
if let ImplItemKind::Fn(sig, _) = &item.kind;
133133
if sig.decl.implicit_self.has_implicit_self();
134134
if cx.access_levels.is_exported(item.hir_id());
@@ -189,8 +189,8 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
189189
}
190190

191191
fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items: &[TraitItemRef]) {
192-
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: &str) -> bool {
193-
item.ident.name.as_str() == name
192+
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool {
193+
item.ident.name == name
194194
&& if let AssocItemKind::Fn { has_self } = item.kind {
195195
has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 }
196196
} else {
@@ -207,7 +207,9 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
207207
}
208208
}
209209

210-
if cx.access_levels.is_exported(visited_trait.hir_id()) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
210+
if cx.access_levels.is_exported(visited_trait.hir_id())
211+
&& trait_items.iter().any(|i| is_named_self(cx, i, sym::len))
212+
{
211213
let mut current_and_super_traits = DefIdSet::default();
212214
fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx);
213215

@@ -401,7 +403,7 @@ fn check_len(
401403
return;
402404
}
403405

404-
if method_name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
406+
if method_name == sym::len && args.len() == 1 && has_is_empty(cx, &args[0]) {
405407
let mut applicability = Applicability::MachineApplicable;
406408
span_lint_and_sugg(
407409
cx,

clippy_lints/src/loops/manual_memcpy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn build_manual_memcpy_suggestion<'tcx>(
118118
let print_limit = |end: &Expr<'_>, end_str: &str, base: &Expr<'_>, sugg: MinifyingSugg<'static>| {
119119
if_chain! {
120120
if let ExprKind::MethodCall(method, _, len_args, _) = end.kind;
121-
if method.ident.name == sym!(len);
121+
if method.ident.name == sym::len;
122122
if len_args.len() == 1;
123123
if let Some(arg) = len_args.get(0);
124124
if path_to_local(arg) == path_to_local(base);

clippy_lints/src/loops/needless_range_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn is_len_call(expr: &Expr<'_>, var: Symbol) -> bool {
192192
if_chain! {
193193
if let ExprKind::MethodCall(method, _, len_args, _) = expr.kind;
194194
if len_args.len() == 1;
195-
if method.ident.name == sym!(len);
195+
if method.ident.name == sym::len;
196196
if let ExprKind::Path(QPath::Resolved(_, path)) = len_args[0].kind;
197197
if path.segments.len() == 1;
198198
if path.segments[0].ident.name == var;

clippy_lints/src/methods/or_fun_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub(super) fn check<'tcx>(
8787
];
8888

8989
if let hir::ExprKind::MethodCall(path, _, args, _) = &arg.kind {
90-
if path.ident.as_str() == "len" {
90+
if path.ident.name == sym::len {
9191
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
9292

9393
match ty.kind() {

clippy_lints/src/no_effect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
167167
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
168168
BlockCheckMode::DefaultBlock => Some(vec![&**e]),
169169
// in case of compiler-inserted signaling blocks
170-
_ => reduce_expression(cx, e),
170+
BlockCheckMode::UnsafeBlock(_) => reduce_expression(cx, e),
171171
}
172172
})
173173
} else {

clippy_lints/src/ranges.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn check_range_zip_with_len(cx: &LateContext<'_>, path: &PathSegment<'_>, args:
329329
if is_integer_const(cx, start, 0);
330330
// `.len()` call
331331
if let ExprKind::MethodCall(len_path, _, len_args, _) = end.kind;
332-
if len_path.ident.name == sym!(len) && len_args.len() == 1;
332+
if len_path.ident.name == sym::len && len_args.len() == 1;
333333
// `.iter()` and `.len()` called on same `Path`
334334
if let ExprKind::Path(QPath::Resolved(_, iter_path)) = iter_args[0].kind;
335335
if let ExprKind::Path(QPath::Resolved(_, len_path)) = len_args[0].kind;

clippy_lints/src/useless_conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
104104
}
105105
}
106106
if_chain! {
107-
if match_trait_method(cx, e, &paths::TRY_INTO_TRAIT) && &*name.ident.as_str() == "try_into";
107+
if match_trait_method(cx, e, &paths::TRY_INTO_TRAIT) && name.ident.name == sym::try_into;
108108
let a = cx.typeck_results().expr_ty(e);
109109
let b = cx.typeck_results().expr_ty(&args[0]);
110110
if is_type_diagnostic_item(cx, a, sym::result_type);

doc/basics.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ cargo dev setup intellij
9898

9999
## lintcheck
100100
`cargo lintcheck` will build and run clippy on a fixed set of crates and generate a log of the results.
101-
You can `git diff` the updated log against its previous version and
101+
You can `git diff` the updated log against its previous version and
102102
see what impact your lint made on a small set of crates.
103-
If you add a new lint, please audit the resulting warnings and make sure
103+
If you add a new lint, please audit the resulting warnings and make sure
104104
there are no false positives and that the suggestions are valid.
105105

106106
Refer to the tools [README] for more details.

lintcheck/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy wit
7373
print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
7474
This lets us spot bad suggestions or false positives automatically in some cases.
7575

76-
Please note that the target dir should be cleaned afterwards since clippy will modify
76+
Please note that the target dir should be cleaned afterwards since clippy will modify
7777
the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-06-17"
2+
channel = "nightly-2021-07-01"
33
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]

tests/ui/bytes_nth.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
fn main() {
77
let s = String::from("String");
88
s.as_bytes().get(3);
9-
&s.as_bytes().get(3);
9+
let _ = &s.as_bytes().get(3);
1010
s[..].as_bytes().get(3);
1111
}

tests/ui/bytes_nth.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
fn main() {
77
let s = String::from("String");
88
s.bytes().nth(3);
9-
&s.bytes().nth(3);
9+
let _ = &s.bytes().nth(3);
1010
s[..].bytes().nth(3);
1111
}

tests/ui/bytes_nth.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ LL | s.bytes().nth(3);
77
= note: `-D clippy::bytes-nth` implied by `-D warnings`
88

99
error: called `.byte().nth()` on a `String`
10-
--> $DIR/bytes_nth.rs:9:6
10+
--> $DIR/bytes_nth.rs:9:14
1111
|
12-
LL | &s.bytes().nth(3);
13-
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
12+
LL | let _ = &s.bytes().nth(3);
13+
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
1414

1515
error: called `.byte().nth()` on a `str`
1616
--> $DIR/bytes_nth.rs:10:5

tests/ui/crashes/ice-3969.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | for<'a> Dst<A + 'a>: Sized,
55
| ^^^^^^ help: use `dyn`: `dyn A + 'a`
66
|
77
= note: `-D bare-trait-objects` implied by `-D warnings`
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
8+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
99
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
1010

1111
error: trait objects without an explicit `dyn` are deprecated
@@ -14,7 +14,7 @@ error: trait objects without an explicit `dyn` are deprecated
1414
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
1515
| ^ help: use `dyn`: `dyn A`
1616
|
17-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
17+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
1818
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
1919

2020
error: trait objects without an explicit `dyn` are deprecated
@@ -23,7 +23,7 @@ error: trait objects without an explicit `dyn` are deprecated
2323
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
2424
| ^ help: use `dyn`: `dyn A`
2525
|
26-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
26+
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
2727
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
2828

2929
error: aborting due to 3 previous errors

tests/ui/iter_count.fixed

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() {
5050
linked_list.push_back(1);
5151
binary_heap.push(1);
5252

53-
&vec[..].len();
53+
let _ = &vec[..].len();
5454
vec.len();
5555
boxed_slice.len();
5656
vec_deque.len();
@@ -62,13 +62,13 @@ fn main() {
6262
binary_heap.len();
6363

6464
vec.len();
65-
&vec[..].len();
65+
let _ = &vec[..].len();
6666
vec_deque.len();
6767
hash_map.len();
6868
b_tree_map.len();
6969
linked_list.len();
7070

71-
&vec[..].len();
71+
let _ = &vec[..].len();
7272
vec.len();
7373
vec_deque.len();
7474
hash_set.len();

tests/ui/iter_count.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() {
5050
linked_list.push_back(1);
5151
binary_heap.push(1);
5252

53-
&vec[..].iter().count();
53+
let _ = &vec[..].iter().count();
5454
vec.iter().count();
5555
boxed_slice.iter().count();
5656
vec_deque.iter().count();
@@ -62,13 +62,13 @@ fn main() {
6262
binary_heap.iter().count();
6363

6464
vec.iter_mut().count();
65-
&vec[..].iter_mut().count();
65+
let _ = &vec[..].iter_mut().count();
6666
vec_deque.iter_mut().count();
6767
hash_map.iter_mut().count();
6868
b_tree_map.iter_mut().count();
6969
linked_list.iter_mut().count();
7070

71-
&vec[..].into_iter().count();
71+
let _ = &vec[..].into_iter().count();
7272
vec.into_iter().count();
7373
vec_deque.into_iter().count();
7474
hash_set.into_iter().count();

tests/ui/iter_count.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: called `.iter().count()` on a `slice`
2-
--> $DIR/iter_count.rs:53:6
2+
--> $DIR/iter_count.rs:53:14
33
|
4-
LL | &vec[..].iter().count();
5-
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
4+
LL | let _ = &vec[..].iter().count();
5+
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
66
|
77
= note: `-D clippy::iter-count` implied by `-D warnings`
88

@@ -67,10 +67,10 @@ LL | vec.iter_mut().count();
6767
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()`
6868

6969
error: called `.iter_mut().count()` on a `slice`
70-
--> $DIR/iter_count.rs:65:6
70+
--> $DIR/iter_count.rs:65:14
7171
|
72-
LL | &vec[..].iter_mut().count();
73-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
72+
LL | let _ = &vec[..].iter_mut().count();
73+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
7474

7575
error: called `.iter_mut().count()` on a `VecDeque`
7676
--> $DIR/iter_count.rs:66:5
@@ -97,10 +97,10 @@ LL | linked_list.iter_mut().count();
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()`
9898

9999
error: called `.into_iter().count()` on a `slice`
100-
--> $DIR/iter_count.rs:71:6
100+
--> $DIR/iter_count.rs:71:14
101101
|
102-
LL | &vec[..].into_iter().count();
103-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
102+
LL | let _ = &vec[..].into_iter().count();
103+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
104104

105105
error: called `.into_iter().count()` on a `Vec`
106106
--> $DIR/iter_count.rs:72:5

util/gh-pages/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ <h4 class="list-group-item-heading">
363363

364364
$scope.bySearch = function (lint, index, array) {
365365
let searchStr = $scope.search;
366-
// It can be `null` I haven't missed this value
366+
// It can be `null` I haven't missed this value
367367
if (searchStr == null || searchStr.length < 3) {
368368
return true;
369369
}
@@ -375,7 +375,7 @@ <h4 class="list-group-item-heading">
375375
}
376376

377377
// Search the description
378-
// The use of `for`-loops instead of `foreach` enables us to return early
378+
// The use of `for`-loops instead of `foreach` enables us to return early
379379
let terms = searchStr.split(" ");
380380
for (index = 0; index < terms.length; index++) {
381381
if (lint.id.indexOf(terms[index]) !== -1) {
@@ -463,7 +463,7 @@ <h4 class="list-group-item-heading">
463463

464464
let children = themeMenu.children;
465465
for (let index = 0; index < children.length; index++) {
466-
let child = children[index];
466+
let child = children[index];
467467
child.addEventListener("click", function(e) {
468468
setTheme(child.id, true);
469469
});
@@ -476,7 +476,7 @@ <h4 class="list-group-item-heading">
476476
let enableHighlight = false;
477477
let enableNight = false;
478478
let enableAyu = false;
479-
479+
480480
if (theme == "ayu") {
481481
enableAyu = true;
482482
} else if (theme == "coal" || theme == "navy") {

0 commit comments

Comments
 (0)