1
Fork 0

Auto merge of #7418 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none
This commit is contained in:
bors 2021-07-01 15:43:14 +00:00
commit 61eb38aeda
22 changed files with 49 additions and 52 deletions

View file

@ -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.

View file

@ -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`)

View file

@ -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;
}
}

View file

@ -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())

View file

@ -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());
@ -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 {
@ -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);
@ -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,

View file

@ -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);

View file

@ -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;

View file

@ -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() {

View file

@ -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 {

View file

@ -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;

View file

@ -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);

View file

@ -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.

View file

@ -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.

View file

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2021-06-17"
channel = "nightly-2021-07-01"
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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

View file

@ -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
@ -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
@ -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

View file

@ -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();
@ -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();

View file

@ -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();
@ -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();

View file

@ -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`
@ -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
@ -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

View file

@ -363,7 +363,7 @@
$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;
}
@ -375,7 +375,7 @@
}
// 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) {
@ -463,7 +463,7 @@
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);
});
@ -476,7 +476,7 @@
let enableHighlight = false;
let enableNight = false;
let enableAyu = false;
if (theme == "ayu") {
enableAyu = true;
} else if (theme == "coal" || theme == "navy") {