Skip to content

Commit 23d1142

Browse files
committed
Auto merge of #8134 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 40fd785 + 646a9cf commit 23d1142

32 files changed

+144
-161
lines changed

clippy_lints/src/asm_syntax.rs

+4
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ declare_clippy_lint! {
6565
/// ```rust,no_run
6666
/// # #![feature(asm)]
6767
/// # unsafe { let ptr = "".as_ptr();
68+
/// # use std::arch::asm;
6869
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
6970
/// # }
7071
/// ```
7172
/// Use instead:
7273
/// ```rust,no_run
7374
/// # #![feature(asm)]
7475
/// # unsafe { let ptr = "".as_ptr();
76+
/// # use std::arch::asm;
7577
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
7678
/// # }
7779
/// ```
@@ -102,13 +104,15 @@ declare_clippy_lint! {
102104
/// ```rust,no_run
103105
/// # #![feature(asm)]
104106
/// # unsafe { let ptr = "".as_ptr();
107+
/// # use std::arch::asm;
105108
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
106109
/// # }
107110
/// ```
108111
/// Use instead:
109112
/// ```rust,no_run
110113
/// # #![feature(asm)]
111114
/// # unsafe { let ptr = "".as_ptr();
115+
/// # use std::arch::asm;
112116
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
113117
/// # }
114118
/// ```

clippy_lints/src/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
4242
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
4343
if_chain! {
4444
if let ExprKind::MethodCall(count, _, [count_recv], _) = expr.kind;
45-
if count.ident.name == sym!(count);
45+
if count.ident.name == sym::count;
4646
if let ExprKind::MethodCall(filter, _, [filter_recv, filter_arg], _) = count_recv.kind;
4747
if filter.ident.name == sym!(filter);
4848
if let ExprKind::Closure(_, _, body_id, _, _) = filter_arg.kind;

clippy_lints/src/future_not_send.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6868
let mut is_future = false;
6969
for &(p, _span) in preds {
7070
let p = p.subst(cx.tcx, subst);
71-
if let Some(trait_ref) = p.to_opt_poly_trait_ref() {
72-
if Some(trait_ref.value.def_id()) == cx.tcx.lang_items().future_trait() {
71+
if let Some(trait_pred) = p.to_opt_poly_trait_pred() {
72+
if Some(trait_pred.skip_binder().trait_ref.def_id) == cx.tcx.lang_items().future_trait() {
7373
is_future = true;
7474
break;
7575
}

clippy_lints/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![feature(box_patterns)]
44
#![feature(drain_filter)]
55
#![feature(in_band_lifetimes)]
6-
#![feature(iter_zip)]
76
#![feature(once_cell)]
87
#![feature(rustc_private)]
98
#![feature(stmt_expr_attributes)]

clippy_lints/src/matches.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use clippy_utils::{
1313
strip_pat_refs,
1414
};
1515
use clippy_utils::{paths, search_same, SpanlessEq, SpanlessHash};
16-
use core::array;
1716
use core::iter::{once, ExactSizeIterator};
1817
use if_chain::if_chain;
1918
use rustc_ast::ast::{Attribute, LitKind};
@@ -1314,7 +1313,7 @@ fn check_match_like_matches<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
13141313
return find_matches_sugg(
13151314
cx,
13161315
let_expr,
1317-
array::IntoIter::new([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
1316+
IntoIterator::into_iter([(&[][..], Some(let_pat), if_then, None), (&[][..], None, if_else, None)]),
13181317
expr,
13191318
true,
13201319
);

clippy_lints/src/methods/str_splitn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn parse_iter_usage(
204204
match e.kind {
205205
ExprKind::Call(
206206
Expr {
207-
kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)),
207+
kind: ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)),
208208
..
209209
},
210210
_,

clippy_lints/src/needless_late_init.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ fn assignment_suggestions<'tcx>(
155155
}
156156

157157
let suggestions = assignments
158-
.into_iter()
159-
.map(|assignment| Some((assignment.span, snippet_opt(cx, assignment.rhs_span)?)))
158+
.iter()
159+
.map(|assignment| Some((assignment.span.until(assignment.rhs_span), String::new())))
160+
.chain(assignments.iter().map(|assignment| {
161+
Some((
162+
assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()),
163+
String::new(),
164+
))
165+
}))
160166
.collect::<Option<Vec<(Span, String)>>>()?;
161167

162168
let applicability = if suggestions.len() > 1 {

clippy_lints/src/needless_question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
105105
};
106106
if let ExprKind::Match(inner_expr_with_q, _, MatchSource::TryDesugar) = &arg.kind;
107107
if let ExprKind::Call(called, [inner_expr]) = &inner_expr_with_q.kind;
108-
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, _)) = &called.kind;
108+
if let ExprKind::Path(QPath::LangItem(LangItem::TryTraitBranch, ..)) = &called.kind;
109109
if expr.span.ctxt() == inner_expr.span.ctxt();
110110
let expr_ty = cx.typeck_results().expr_ty(expr);
111111
let inner_ty = cx.typeck_results().expr_ty(inner_expr);

clippy_lints/src/redundant_clone.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::mir::{
1515
Mutability,
1616
};
1717
use rustc_middle::ty::{self, fold::TypeVisitor, Ty, TyCtxt};
18-
use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
18+
use rustc_mir_dataflow::{Analysis, AnalysisDomain, CallReturnPlaces, GenKill, GenKillAnalysis, ResultsCursor};
1919
use rustc_session::{declare_lint_pass, declare_tool_lint};
2020
use rustc_span::source_map::{BytePos, Span};
2121
use rustc_span::sym;
@@ -500,11 +500,9 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeStorageLive {
500500

501501
fn call_return_effect(
502502
&self,
503-
_in_out: &mut impl GenKill<Self::Idx>,
503+
_trans: &mut impl GenKill<Self::Idx>,
504504
_block: mir::BasicBlock,
505-
_func: &mir::Operand<'tcx>,
506-
_args: &[mir::Operand<'tcx>],
507-
_return_place: mir::Place<'tcx>,
505+
_return_places: CallReturnPlaces<'_, 'tcx>,
508506
) {
509507
// Nothing to do when a call returns successfully
510508
}

clippy_lints/src/strings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'tcx> LateLintPass<'tcx> for StringLitAsBytes {
257257
if method_names[0] == sym!(as_bytes);
258258

259259
// Check for slicer
260-
if let ExprKind::Struct(QPath::LangItem(LangItem::Range, _), _, _) = right.kind;
260+
if let ExprKind::Struct(QPath::LangItem(LangItem::Range, ..), _, _) = right.kind;
261261

262262
then {
263263
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/try_err.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'tcx> LateLintPass<'tcx> for TryErr {
6565
if let ExprKind::Match(match_arg, _, MatchSource::TryDesugar) = expr.kind;
6666
if let ExprKind::Call(match_fun, try_args) = match_arg.kind;
6767
if let ExprKind::Path(ref match_fun_path) = match_fun.kind;
68-
if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, _));
68+
if matches!(match_fun_path, QPath::LangItem(LangItem::TryTraitBranch, ..));
6969
if let Some(try_arg) = try_args.get(0);
7070
if let ExprKind::Call(err_fun, err_args) = try_arg.kind;
7171
if let Some(err_arg) = err_args.get(0);

clippy_lints/src/unused_io_amount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
4949
if let hir::ExprKind::Call(func, [ref arg_0, ..]) = res.kind {
5050
if matches!(
5151
func.kind,
52-
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, _))
52+
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, ..))
5353
) {
5454
check_map_error(cx, arg_0, expr);
5555
}

clippy_lints/src/utils/author.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
260260
}
261261

262262
fn qpath(&self, qpath: &Binding<&QPath<'_>>) {
263-
if let QPath::LangItem(lang_item, _) = *qpath.value {
263+
if let QPath::LangItem(lang_item, ..) = *qpath.value {
264264
out!("if matches!({qpath}, QPath::LangItem(LangItem::{lang_item:?}, _));");
265265
} else {
266266
out!("if match_qpath({qpath}, &[{}]);", path_to_string(qpath.value));

clippy_utils/src/higher.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> Range<'a> {
218218
hir::ExprKind::Call(path, args)
219219
if matches!(
220220
path.kind,
221-
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, _))
221+
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, ..))
222222
) =>
223223
{
224224
Some(Range {
@@ -228,27 +228,27 @@ impl<'a> Range<'a> {
228228
})
229229
},
230230
hir::ExprKind::Struct(path, fields, None) => match &path {
231-
hir::QPath::LangItem(hir::LangItem::RangeFull, _) => Some(Range {
231+
hir::QPath::LangItem(hir::LangItem::RangeFull, ..) => Some(Range {
232232
start: None,
233233
end: None,
234234
limits: ast::RangeLimits::HalfOpen,
235235
}),
236-
hir::QPath::LangItem(hir::LangItem::RangeFrom, _) => Some(Range {
236+
hir::QPath::LangItem(hir::LangItem::RangeFrom, ..) => Some(Range {
237237
start: Some(get_field("start", fields)?),
238238
end: None,
239239
limits: ast::RangeLimits::HalfOpen,
240240
}),
241-
hir::QPath::LangItem(hir::LangItem::Range, _) => Some(Range {
241+
hir::QPath::LangItem(hir::LangItem::Range, ..) => Some(Range {
242242
start: Some(get_field("start", fields)?),
243243
end: Some(get_field("end", fields)?),
244244
limits: ast::RangeLimits::HalfOpen,
245245
}),
246-
hir::QPath::LangItem(hir::LangItem::RangeToInclusive, _) => Some(Range {
246+
hir::QPath::LangItem(hir::LangItem::RangeToInclusive, ..) => Some(Range {
247247
start: None,
248248
end: Some(get_field("end", fields)?),
249249
limits: ast::RangeLimits::Closed,
250250
}),
251-
hir::QPath::LangItem(hir::LangItem::RangeTo, _) => Some(Range {
251+
hir::QPath::LangItem(hir::LangItem::RangeTo, ..) => Some(Range {
252252
start: None,
253253
end: Some(get_field("end", fields)?),
254254
limits: ast::RangeLimits::HalfOpen,

clippy_utils/src/hir_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl HirEqInterExpr<'_, '_, '_> {
348348
(&QPath::TypeRelative(lty, lseg), &QPath::TypeRelative(rty, rseg)) => {
349349
self.eq_ty(lty, rty) && self.eq_path_segment(lseg, rseg)
350350
},
351-
(&QPath::LangItem(llang_item, _), &QPath::LangItem(rlang_item, _)) => llang_item == rlang_item,
351+
(&QPath::LangItem(llang_item, ..), &QPath::LangItem(rlang_item, ..)) => llang_item == rlang_item,
352352
_ => false,
353353
}
354354
}

clippy_utils/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![feature(box_patterns)]
22
#![feature(in_band_lifetimes)]
3-
#![feature(iter_zip)]
43
#![feature(let_else)]
54
#![feature(rustc_private)]
65
#![feature(control_flow_enum)]

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-12-02"
2+
channel = "nightly-2021-12-17"
33
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

tests/ui/asm_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// only-x86_64
22
// ignore-aarch64
33

4-
#![feature(asm)]
5-
64
#[warn(clippy::inline_asm_x86_intel_syntax)]
75
mod warn_intel {
86
pub(super) unsafe fn use_asm() {
7+
use std::arch::asm;
98
asm!("");
109
asm!("", options());
1110
asm!("", options(nostack));
@@ -17,6 +16,7 @@ mod warn_intel {
1716
#[warn(clippy::inline_asm_x86_att_syntax)]
1817
mod warn_att {
1918
pub(super) unsafe fn use_asm() {
19+
use std::arch::asm;
2020
asm!("");
2121
asm!("", options());
2222
asm!("", options(nostack));

tests/ui/asm_syntax.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: Intel x86 assembly syntax used
2-
--> $DIR/asm_syntax.rs:9:9
2+
--> $DIR/asm_syntax.rs:8:9
33
|
44
LL | asm!("");
55
| ^^^^^^^^
@@ -8,15 +8,15 @@ LL | asm!("");
88
= help: use AT&T x86 assembly syntax
99

1010
error: Intel x86 assembly syntax used
11-
--> $DIR/asm_syntax.rs:10:9
11+
--> $DIR/asm_syntax.rs:9:9
1212
|
1313
LL | asm!("", options());
1414
| ^^^^^^^^^^^^^^^^^^^
1515
|
1616
= help: use AT&T x86 assembly syntax
1717

1818
error: Intel x86 assembly syntax used
19-
--> $DIR/asm_syntax.rs:11:9
19+
--> $DIR/asm_syntax.rs:10:9
2020
|
2121
LL | asm!("", options(nostack));
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/crashes/ice-6250.stderr

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
error[E0658]: destructuring assignments are unstable
2-
--> $DIR/ice-6250.rs:12:25
3-
|
4-
LL | Some(reference) = cache.data.get(key) {
5-
| --------------- ^
6-
| |
7-
| cannot assign to this expression
8-
|
9-
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
10-
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
11-
121
error[E0601]: `main` function not found in crate `ice_6250`
132
--> $DIR/ice-6250.rs:4:1
143
|
@@ -41,7 +30,7 @@ error[E0308]: mismatched types
4130
LL | Some(reference) = cache.data.get(key) {
4231
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
4332

44-
error: aborting due to 4 previous errors
33+
error: aborting due to 3 previous errors
4534

46-
Some errors have detailed explanations: E0308, E0601, E0658.
35+
Some errors have detailed explanations: E0308, E0601.
4736
For more information about an error, try `rustc --explain E0308`.

tests/ui/entry.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
44
#![warn(clippy::map_entry)]
5-
#![feature(asm)]
65

6+
use std::arch::asm;
77
use std::collections::HashMap;
88
use std::hash::Hash;
99

tests/ui/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
44
#![warn(clippy::map_entry)]
5-
#![feature(asm)]
65

6+
use std::arch::asm;
77
use std::collections::HashMap;
88
use std::hash::Hash;
99

0 commit comments

Comments
 (0)