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

@ -410,13 +410,8 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
} }
if let ExprKind::Block(block, _) = expr.kind { if let ExprKind::Block(block, _) = expr.kind {
match block.rules { if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided)
| BlockCheckMode::PushUnsafeBlock(UnsafeSource::UserProvided)
| BlockCheckMode::PopUnsafeBlock(UnsafeSource::UserProvided) => {
self.has_unsafe = true; self.has_unsafe = true;
},
_ => {},
} }
} }

View file

@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for GetLastWithLen {
// LHS of subtraction is "x.len()" // LHS of subtraction is "x.len()"
if let ExprKind::MethodCall(arg_lhs_path, _, lhs_args, _) = &lhs.kind; 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); if let Some(arg_lhs_struct) = lhs_args.get(0);
// The two vectors referenced (x in x.get(...) and in x.len()) // 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<'_>) { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
if_chain! { if_chain! {
if item.ident.as_str() == "len"; if item.ident.name == sym::len;
if let ImplItemKind::Fn(sig, _) = &item.kind; if let ImplItemKind::Fn(sig, _) = &item.kind;
if sig.decl.implicit_self.has_implicit_self(); if sig.decl.implicit_self.has_implicit_self();
if cx.access_levels.is_exported(item.hir_id()); 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 check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items: &[TraitItemRef]) {
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: &str) -> bool { fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: Symbol) -> bool {
item.ident.name.as_str() == name item.ident.name == name
&& if let AssocItemKind::Fn { has_self } = item.kind { && if let AssocItemKind::Fn { has_self } = item.kind {
has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 } has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 }
} else { } 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(); let mut current_and_super_traits = DefIdSet::default();
fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx); fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx);
@ -401,7 +403,7 @@ fn check_len(
return; 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; let mut applicability = Applicability::MachineApplicable;
span_lint_and_sugg( span_lint_and_sugg(
cx, 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>| { let print_limit = |end: &Expr<'_>, end_str: &str, base: &Expr<'_>, sugg: MinifyingSugg<'static>| {
if_chain! { if_chain! {
if let ExprKind::MethodCall(method, _, len_args, _) = end.kind; 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 len_args.len() == 1;
if let Some(arg) = len_args.get(0); if let Some(arg) = len_args.get(0);
if path_to_local(arg) == path_to_local(base); 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_chain! {
if let ExprKind::MethodCall(method, _, len_args, _) = expr.kind; if let ExprKind::MethodCall(method, _, len_args, _) = expr.kind;
if len_args.len() == 1; 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 let ExprKind::Path(QPath::Resolved(_, path)) = len_args[0].kind;
if path.segments.len() == 1; if path.segments.len() == 1;
if path.segments[0].ident.name == var; 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 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(); let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
match ty.kind() { 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::UnsafeBlock(UnsafeSource::UserProvided) => None,
BlockCheckMode::DefaultBlock => Some(vec![&**e]), BlockCheckMode::DefaultBlock => Some(vec![&**e]),
// in case of compiler-inserted signaling blocks // in case of compiler-inserted signaling blocks
_ => reduce_expression(cx, e), BlockCheckMode::UnsafeBlock(_) => reduce_expression(cx, e),
} }
}) })
} else { } 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); if is_integer_const(cx, start, 0);
// `.len()` call // `.len()` call
if let ExprKind::MethodCall(len_path, _, len_args, _) = end.kind; 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` // `.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(_, iter_path)) = iter_args[0].kind;
if let ExprKind::Path(QPath::Resolved(_, len_path)) = len_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_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 a = cx.typeck_results().expr_ty(e);
let b = cx.typeck_results().expr_ty(&args[0]); let b = cx.typeck_results().expr_ty(&args[0]);
if is_type_diagnostic_item(cx, a, sym::result_type); if is_type_diagnostic_item(cx, a, sym::result_type);

View file

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

View file

@ -6,6 +6,6 @@
fn main() { fn main() {
let s = String::from("String"); let s = String::from("String");
s.as_bytes().get(3); s.as_bytes().get(3);
&s.as_bytes().get(3); let _ = &s.as_bytes().get(3);
s[..].as_bytes().get(3); s[..].as_bytes().get(3);
} }

View file

@ -6,6 +6,6 @@
fn main() { fn main() {
let s = String::from("String"); let s = String::from("String");
s.bytes().nth(3); s.bytes().nth(3);
&s.bytes().nth(3); let _ = &s.bytes().nth(3);
s[..].bytes().nth(3); s[..].bytes().nth(3);
} }

View file

@ -7,9 +7,9 @@ LL | s.bytes().nth(3);
= note: `-D clippy::bytes-nth` implied by `-D warnings` = note: `-D clippy::bytes-nth` implied by `-D warnings`
error: called `.byte().nth()` on a `String` error: called `.byte().nth()` on a `String`
--> $DIR/bytes_nth.rs:9:6 --> $DIR/bytes_nth.rs:9:14
| |
LL | &s.bytes().nth(3); LL | let _ = &s.bytes().nth(3);
| ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)` | ^^^^^^^^^^^^^^^^ help: try: `s.as_bytes().get(3)`
error: called `.byte().nth()` on a `str` error: called `.byte().nth()` on a `str`

View file

@ -5,7 +5,7 @@ LL | for<'a> Dst<A + 'a>: Sized,
| ^^^^^^ help: use `dyn`: `dyn A + 'a` | ^^^^^^ help: use `dyn`: `dyn A + 'a`
| |
= note: `-D bare-trait-objects` implied by `-D warnings` = 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> = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: trait objects without an explicit `dyn` are deprecated 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>>); LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
| ^ help: use `dyn`: `dyn 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> = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: trait objects without an explicit `dyn` are deprecated 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>>); LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
| ^ help: use `dyn`: `dyn 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> = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View file

@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1); linked_list.push_back(1);
binary_heap.push(1); binary_heap.push(1);
&vec[..].len(); let _ = &vec[..].len();
vec.len(); vec.len();
boxed_slice.len(); boxed_slice.len();
vec_deque.len(); vec_deque.len();
@ -62,13 +62,13 @@ fn main() {
binary_heap.len(); binary_heap.len();
vec.len(); vec.len();
&vec[..].len(); let _ = &vec[..].len();
vec_deque.len(); vec_deque.len();
hash_map.len(); hash_map.len();
b_tree_map.len(); b_tree_map.len();
linked_list.len(); linked_list.len();
&vec[..].len(); let _ = &vec[..].len();
vec.len(); vec.len();
vec_deque.len(); vec_deque.len();
hash_set.len(); hash_set.len();

View file

@ -50,7 +50,7 @@ fn main() {
linked_list.push_back(1); linked_list.push_back(1);
binary_heap.push(1); binary_heap.push(1);
&vec[..].iter().count(); let _ = &vec[..].iter().count();
vec.iter().count(); vec.iter().count();
boxed_slice.iter().count(); boxed_slice.iter().count();
vec_deque.iter().count(); vec_deque.iter().count();
@ -62,13 +62,13 @@ fn main() {
binary_heap.iter().count(); binary_heap.iter().count();
vec.iter_mut().count(); vec.iter_mut().count();
&vec[..].iter_mut().count(); let _ = &vec[..].iter_mut().count();
vec_deque.iter_mut().count(); vec_deque.iter_mut().count();
hash_map.iter_mut().count(); hash_map.iter_mut().count();
b_tree_map.iter_mut().count(); b_tree_map.iter_mut().count();
linked_list.iter_mut().count(); linked_list.iter_mut().count();
&vec[..].into_iter().count(); let _ = &vec[..].into_iter().count();
vec.into_iter().count(); vec.into_iter().count();
vec_deque.into_iter().count(); vec_deque.into_iter().count();
hash_set.into_iter().count(); hash_set.into_iter().count();

View file

@ -1,7 +1,7 @@
error: called `.iter().count()` on a `slice` error: called `.iter().count()` on a `slice`
--> $DIR/iter_count.rs:53:6 --> $DIR/iter_count.rs:53:14
| |
LL | &vec[..].iter().count(); LL | let _ = &vec[..].iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
| |
= note: `-D clippy::iter-count` implied by `-D warnings` = note: `-D clippy::iter-count` implied by `-D warnings`
@ -67,9 +67,9 @@ LL | vec.iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()` | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec.len()`
error: called `.iter_mut().count()` on a `slice` 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(); LL | let _ = &vec[..].iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
error: called `.iter_mut().count()` on a `VecDeque` error: called `.iter_mut().count()` on a `VecDeque`
@ -97,9 +97,9 @@ LL | linked_list.iter_mut().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `linked_list.len()`
error: called `.into_iter().count()` on a `slice` 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(); LL | let _ = &vec[..].into_iter().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `vec[..].len()`
error: called `.into_iter().count()` on a `Vec` error: called `.into_iter().count()` on a `Vec`