Skip to content

Commit

Permalink
Auto merge of #7418 - flip1995:rustup, r=flip1995
Browse files Browse the repository at this point in the history
Rustup

r? `@ghost`

changelog: none
  • Loading branch information
bors committed Jul 1, 2021
2 parents 753bce3 + d446d5e commit 61eb38a
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 52 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ We have prioritization labels and a sync-blocker label, which are described belo
- [P-low][p-low]: Requires attention (fix/response/evaluation) by a team member but isn't urgent.
- [P-medium][p-medium]: Should be addressed by a team member until the next sync.
- [P-high][p-high]: Should be immediately addressed and will require an out-of-cycle sync or a backport.
- [L-sync-blocker][l-sync-blocker]: An issue that "blocks" a sync.
- [L-sync-blocker][l-sync-blocker]: An issue that "blocks" a sync.
Or rather: before the sync this should be addressed,
e.g. by removing a lint again, so it doesn't hit beta/stable.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ As with `cargo check`, this includes dependencies that are members of the worksp
If you want to run Clippy **only** on the given crate, use the `--no-deps` option like this:

```terminal
cargo clippy -p example -- --no-deps
cargo clippy -p example -- --no-deps
```

### As a rustc replacement (`clippy-driver`)
Expand Down
9 changes: 2 additions & 7 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,8 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
}

if let ExprKind::Block(block, _) = expr.kind {
match block.rules {
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided)
| BlockCheckMode::PushUnsafeBlock(UnsafeSource::UserProvided)
| BlockCheckMode::PopUnsafeBlock(UnsafeSource::UserProvided) => {
self.has_unsafe = true;
},
_ => {},
if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
self.has_unsafe = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/get_last_with_len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for GetLastWithLen {

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

// The two vectors referenced (x in x.get(...) and in x.len())
Expand Down
12 changes: 7 additions & 5 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {

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

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

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

Expand Down Expand Up @@ -401,7 +403,7 @@ fn check_len(
return;
}

if method_name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
if method_name == sym::len && args.len() == 1 && has_is_empty(cx, &args[0]) {
let mut applicability = Applicability::MachineApplicable;
span_lint_and_sugg(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/manual_memcpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn build_manual_memcpy_suggestion<'tcx>(
let print_limit = |end: &Expr<'_>, end_str: &str, base: &Expr<'_>, sugg: MinifyingSugg<'static>| {
if_chain! {
if let ExprKind::MethodCall(method, _, len_args, _) = end.kind;
if method.ident.name == sym!(len);
if method.ident.name == sym::len;
if len_args.len() == 1;
if let Some(arg) = len_args.get(0);
if path_to_local(arg) == path_to_local(base);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/needless_range_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn is_len_call(expr: &Expr<'_>, var: Symbol) -> bool {
if_chain! {
if let ExprKind::MethodCall(method, _, len_args, _) = expr.kind;
if len_args.len() == 1;
if method.ident.name == sym!(len);
if method.ident.name == sym::len;
if let ExprKind::Path(QPath::Resolved(_, path)) = len_args[0].kind;
if path.segments.len() == 1;
if path.segments[0].ident.name == var;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/or_fun_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(super) fn check<'tcx>(
];

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

match ty.kind() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/no_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
BlockCheckMode::DefaultBlock => Some(vec![&**e]),
// in case of compiler-inserted signaling blocks
_ => reduce_expression(cx, e),
BlockCheckMode::UnsafeBlock(_) => reduce_expression(cx, e),
}
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ fn check_range_zip_with_len(cx: &LateContext<'_>, path: &PathSegment<'_>, args:
if is_integer_const(cx, start, 0);
// `.len()` call
if let ExprKind::MethodCall(len_path, _, len_args, _) = end.kind;
if len_path.ident.name == sym!(len) && len_args.len() == 1;
if len_path.ident.name == sym::len && len_args.len() == 1;
// `.iter()` and `.len()` called on same `Path`
if let ExprKind::Path(QPath::Resolved(_, iter_path)) = iter_args[0].kind;
if let ExprKind::Path(QPath::Resolved(_, len_path)) = len_args[0].kind;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/useless_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
}
}
if_chain! {
if match_trait_method(cx, e, &paths::TRY_INTO_TRAIT) && &*name.ident.as_str() == "try_into";
if match_trait_method(cx, e, &paths::TRY_INTO_TRAIT) && name.ident.name == sym::try_into;
let a = cx.typeck_results().expr_ty(e);
let b = cx.typeck_results().expr_ty(&args[0]);
if is_type_diagnostic_item(cx, a, sym::result_type);
Expand Down
4 changes: 2 additions & 2 deletions doc/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ cargo dev setup intellij

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

Refer to the tools [README] for more details.
Expand Down
2 changes: 1 addition & 1 deletion lintcheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ You can run `./lintcheck/target/debug/lintcheck --fix` which will run Clippy wit
print a warning if Clippys suggestions fail to apply (if the resulting code does not build).
This lets us spot bad suggestions or false positives automatically in some cases.

Please note that the target dir should be cleaned afterwards since clippy will modify
Please note that the target dir should be cleaned afterwards since clippy will modify
the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-06-17"
channel = "nightly-2021-07-01"
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]
2 changes: 1 addition & 1 deletion tests/ui/bytes_nth.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
fn main() {
let s = String::from("String");
s.as_bytes().get(3);
&s.as_bytes().get(3);
let _ = &s.as_bytes().get(3);
s[..].as_bytes().get(3);
}
2 changes: 1 addition & 1 deletion tests/ui/bytes_nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
fn main() {
let s = String::from("String");
s.bytes().nth(3);
&s.bytes().nth(3);
let _ = &s.bytes().nth(3);
s[..].bytes().nth(3);
}
6 changes: 3 additions & 3 deletions tests/ui/bytes_nth.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LL | s.bytes().nth(3);
= note: `-D clippy::bytes-nth` implied by `-D warnings`

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

error: called `.byte().nth()` on a `str`
--> $DIR/bytes_nth.rs:10:5
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/crashes/ice-3969.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | for<'a> Dst<A + 'a>: Sized,
| ^^^^^^ help: use `dyn`: `dyn A + 'a`
|
= note: `-D bare-trait-objects` implied by `-D warnings`
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

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

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

error: aborting due to 3 previous errors
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iter_count.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1);
binary_heap.push(1);

&vec[..].len();
let _ = &vec[..].len();
vec.len();
boxed_slice.len();
vec_deque.len();
Expand All @@ -62,13 +62,13 @@ fn main() {
binary_heap.len();

vec.len();
&vec[..].len();
let _ = &vec[..].len();
vec_deque.len();
hash_map.len();
b_tree_map.len();
linked_list.len();

&vec[..].len();
let _ = &vec[..].len();
vec.len();
vec_deque.len();
hash_set.len();
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/iter_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1);
binary_heap.push(1);

&vec[..].iter().count();
let _ = &vec[..].iter().count();
vec.iter().count();
boxed_slice.iter().count();
vec_deque.iter().count();
Expand All @@ -62,13 +62,13 @@ fn main() {
binary_heap.iter().count();

vec.iter_mut().count();
&vec[..].iter_mut().count();
let _ = &vec[..].iter_mut().count();
vec_deque.iter_mut().count();
hash_map.iter_mut().count();
b_tree_map.iter_mut().count();
linked_list.iter_mut().count();

&vec[..].into_iter().count();
let _ = &vec[..].into_iter().count();
vec.into_iter().count();
vec_deque.into_iter().count();
hash_set.into_iter().count();
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/iter_count.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: called `.iter().count()` on a `slice`
--> $DIR/iter_count.rs:53:6
--> $DIR/iter_count.rs:53:14
|
LL | &vec[..].iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
LL | let _ = &vec[..].iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
|
= note: `-D clippy::iter-count` implied by `-D warnings`

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

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

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

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

error: called `.into_iter().count()` on a `Vec`
--> $DIR/iter_count.rs:72:5
Expand Down
8 changes: 4 additions & 4 deletions util/gh-pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ <h4 class="list-group-item-heading">

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

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

let children = themeMenu.children;
for (let index = 0; index < children.length; index++) {
let child = children[index];
let child = children[index];
child.addEventListener("click", function(e) {
setTheme(child.id, true);
});
Expand All @@ -476,7 +476,7 @@ <h4 class="list-group-item-heading">
let enableHighlight = false;
let enableNight = false;
let enableAyu = false;

if (theme == "ayu") {
enableAyu = true;
} else if (theme == "coal" || theme == "navy") {
Expand Down

0 comments on commit 61eb38a

Please sign in to comment.