Skip to content

Commit 0e87918

Browse files
committed
Auto merge of #6971 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 981ffa7 + 40e68e5 commit 0e87918

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+145
-156
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.52"
3+
version = "0.1.53"
44
authors = ["The Rust Clippy Developers"]
55
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
66
repository = "https://github.com/rust-lang/rust-clippy"

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.1.52"
4+
version = "0.1.53"
55
# end automatic update
66
authors = ["The Rust Clippy Developers"]
77
description = "A bunch of helpful lints to avoid common pitfalls in Rust"

clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute) {
564564
// check for `rustfmt_skip` and `rustfmt::skip`
565565
if let Some(skip_item) = &items[1].meta_item();
566566
if skip_item.has_name(sym!(rustfmt_skip)) ||
567-
skip_item.path.segments.last().expect("empty path in attribute").ident.name == sym!(skip);
567+
skip_item.path.segments.last().expect("empty path in attribute").ident.name == sym::skip;
568568
// Only lint outer attributes, because custom inner attributes are unstable
569569
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
570570
if let AttrStyle::Outer = attr.style;

clippy_lints/src/escape.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use rustc_hir::intravisit;
44
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
7+
use rustc_middle::mir::FakeReadCause;
78
use rustc_middle::ty::{self, TraitRef, Ty};
89
use rustc_session::{declare_tool_lint, impl_lint_pass};
910
use rustc_span::source_map::Span;
@@ -184,6 +185,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
184185
}
185186
}
186187
}
188+
189+
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
187190
}
188191

189192
impl<'a, 'tcx> EscapeDelegate<'a, 'tcx> {

clippy_lints/src/inconsistent_struct_constructor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl LateLintPass<'_> for InconsistentStructConstructor {
120120

121121
// Check whether the order of the fields in the constructor is consistent with the order in the
122122
// definition.
123-
fn is_consistent_order<'tcx>(fields: &'tcx [hir::Field<'tcx>], def_order_map: &FxHashMap<Symbol, usize>) -> bool {
123+
fn is_consistent_order<'tcx>(fields: &'tcx [hir::ExprField<'tcx>], def_order_map: &FxHashMap<Symbol, usize>) -> bool {
124124
let mut cur_idx = usize::MIN;
125125
for f in fields {
126126
let next_idx = def_order_map[&f.ident.name];

clippy_lints/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(drain_filter)]
66
#![feature(in_band_lifetimes)]
77
#![feature(once_cell)]
8-
#![feature(or_patterns)]
98
#![feature(rustc_private)]
109
#![feature(stmt_expr_attributes)]
1110
#![feature(control_flow_enum)]

clippy_lints/src/lifetimes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
388388
self.nested_elision_site_lts.append(&mut sub_visitor.all_lts());
389389
return;
390390
},
391-
TyKind::TraitObject(bounds, ref lt) => {
391+
TyKind::TraitObject(bounds, ref lt, _) => {
392392
if !lt.is_elided() {
393393
self.unelided_trait_object_lifetime = true;
394394
}

clippy_lints/src/loops/mut_range_bound.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use if_chain::if_chain;
55
use rustc_hir::{BindingAnnotation, Expr, HirId, Node, PatKind};
66
use rustc_infer::infer::TyCtxtInferExt;
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty;
8+
use rustc_middle::{mir::FakeReadCause, ty};
99
use rustc_span::source_map::Span;
1010
use rustc_typeck::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
1111

@@ -107,6 +107,8 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
107107
}
108108
}
109109
}
110+
111+
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
110112
}
111113

112114
impl MutatePairDelegate<'_, '_> {

clippy_lints/src/manual_non_exhaustive.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::meets_msrv;
33
use clippy_utils::source::snippet_opt;
44
use if_chain::if_chain;
5-
use rustc_ast::ast::{Attribute, Item, ItemKind, StructField, Variant, VariantData, VisibilityKind};
5+
use rustc_ast::ast::{Attribute, FieldDef, Item, ItemKind, Variant, VariantData, VisibilityKind};
66
use rustc_attr as attr;
77
use rustc_errors::Applicability;
88
use rustc_lint::{EarlyContext, EarlyLintPass};
@@ -144,11 +144,11 @@ fn check_manual_non_exhaustive_enum(cx: &EarlyContext<'_>, item: &Item, variants
144144
}
145145

146146
fn check_manual_non_exhaustive_struct(cx: &EarlyContext<'_>, item: &Item, data: &VariantData) {
147-
fn is_private(field: &StructField) -> bool {
147+
fn is_private(field: &FieldDef) -> bool {
148148
matches!(field.vis.kind, VisibilityKind::Inherited)
149149
}
150150

151-
fn is_non_exhaustive_marker(field: &StructField) -> bool {
151+
fn is_non_exhaustive_marker(field: &FieldDef) -> bool {
152152
is_private(field) && field.ty.kind.is_unit() && field.ident.map_or(true, |n| n.as_str().starts_with('_'))
153153
}
154154

clippy_lints/src/matches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_span::source_map::{Span, Spanned};
2929
use rustc_span::sym;
3030
use std::cmp::Ordering;
3131
use std::collections::hash_map::Entry;
32-
use std::collections::Bound;
32+
use std::ops::Bound;
3333

3434
declare_clippy_lint! {
3535
/// **What it does:** Checks for matches with a single arm where an `if let`

clippy_lints/src/methods/or_fun_call.rs

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub(super) fn check<'tcx>(
155155
}
156156
}
157157
}
158+
158159
if args.len() == 2 {
159160
match args[1].kind {
160161
hir::ExprKind::Call(ref fun, ref or_args) => {

clippy_lints/src/missing_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
188188
self.check_missing_docs_attrs(cx, attrs, impl_item.span, article, desc);
189189
}
190190

191-
fn check_struct_field(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::StructField<'_>) {
191+
fn check_field_def(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::FieldDef<'_>) {
192192
if !sf.is_positional() {
193193
let attrs = cx.tcx.hir().attrs(sf.hir_id);
194194
self.check_missing_docs_attrs(cx, attrs, sf.span, "a", "struct field");

clippy_lints/src/needless_pass_by_value.rs

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_hir::intravisit::FnKind;
1111
use rustc_hir::{BindingAnnotation, Body, FnDecl, GenericArg, HirId, Impl, ItemKind, Node, PatKind, QPath, TyKind};
1212
use rustc_infer::infer::TyCtxtInferExt;
1313
use rustc_lint::{LateContext, LateLintPass};
14+
use rustc_middle::mir::FakeReadCause;
1415
use rustc_middle::ty::{self, TypeFoldable};
1516
use rustc_session::{declare_lint_pass, declare_tool_lint};
1617
use rustc_span::symbol::kw;
@@ -333,4 +334,6 @@ impl<'tcx> euv::Delegate<'tcx> for MovedVariablesCtxt {
333334
fn borrow(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {}
334335

335336
fn mutate(&mut self, _: &euv::PlaceWithHirId<'tcx>, _: HirId) {}
337+
338+
fn fake_read(&mut self, _: rustc_typeck::expr_use_visitor::Place<'tcx>, _: FakeReadCause, _: HirId) {}
336339
}

clippy_lints/src/non_copy_const.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,15 @@ fn is_value_unfrozen_poly<'tcx>(cx: &LateContext<'tcx>, body_id: BodyId, ty: Ty<
179179
fn is_value_unfrozen_expr<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId, def_id: DefId, ty: Ty<'tcx>) -> bool {
180180
let substs = cx.typeck_results().node_substs(hir_id);
181181

182-
let result = cx
183-
.tcx
184-
.const_eval_resolve(cx.param_env, ty::WithOptConstParam::unknown(def_id), substs, None, None);
182+
let result = cx.tcx.const_eval_resolve(
183+
cx.param_env,
184+
ty::Unevaluated {
185+
def: ty::WithOptConstParam::unknown(def_id),
186+
substs,
187+
promoted: None,
188+
},
189+
None,
190+
);
185191
is_value_unfrozen_raw(cx, result, ty)
186192
}
187193

clippy_lints/src/pattern_type_mismatch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::last_path_segment;
33
use rustc_hir::{
4-
intravisit, Body, Expr, ExprKind, FieldPat, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatKind,
4+
intravisit, Body, Expr, ExprKind, FnDecl, HirId, LocalSource, MatchSource, Mutability, Pat, PatField, PatKind,
55
QPath, Stmt, StmtKind,
66
};
77
use rustc_lint::{LateContext, LateLintPass, LintContext};
@@ -282,7 +282,7 @@ where
282282

283283
fn find_first_mismatch_in_struct<'tcx>(
284284
cx: &LateContext<'tcx>,
285-
field_pats: &[FieldPat<'_>],
285+
field_pats: &[PatField<'_>],
286286
field_defs: &[FieldDef],
287287
substs_ref: SubstsRef<'tcx>,
288288
) -> Option<(Span, Mutability, Level)> {

clippy_lints/src/redundant_field_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl EarlyLintPass for RedundantFieldNames {
5959
if in_external_macro(cx.sess, expr.span) {
6060
return;
6161
}
62-
if let ExprKind::Struct(_, ref fields, _) = expr.kind {
63-
for field in fields {
62+
if let ExprKind::Struct(ref se) = expr.kind {
63+
for field in &se.fields {
6464
if field.is_shorthand {
6565
continue;
6666
}

clippy_lints/src/suspicious_operation_groupings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fn ident_difference_expr_with_base_location(
565565
| (Try(_), Try(_))
566566
| (Paren(_), Paren(_))
567567
| (Repeat(_, _), Repeat(_, _))
568-
| (Struct(_, _, _), Struct(_, _, _))
568+
| (Struct(_), Struct(_))
569569
| (MacCall(_), MacCall(_))
570570
| (LlvmInlineAsm(_), LlvmInlineAsm(_))
571571
| (InlineAsm(_), InlineAsm(_))

clippy_lints/src/types/borrowed_box.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
5050
// Originally reported as the issue #3128.
5151
let inner_snippet = snippet(cx, inner.span, "..");
5252
let suggestion = match &inner.kind {
53-
TyKind::TraitObject(bounds, lt_bound) if bounds.len() > 1 || !lt_bound.is_elided() => {
53+
TyKind::TraitObject(bounds, lt_bound, _) if bounds.len() > 1 || !lt_bound.is_elided() => {
5454
format!("&{}({})", ltopt, &inner_snippet)
5555
},
5656
TyKind::Path(qpath)
@@ -86,7 +86,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
8686
// Returns true if given type is `Any` trait.
8787
fn is_any_trait(t: &hir::Ty<'_>) -> bool {
8888
if_chain! {
89-
if let TyKind::TraitObject(ref traits, _) = t.kind;
89+
if let TyKind::TraitObject(ref traits, ..) = t.kind;
9090
if !traits.is_empty();
9191
// Only Send/Sync can be used as additional traits, so it is enough to
9292
// check only the first trait.

clippy_lints/src/types/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
268268
self.check_fn_decl(cx, decl);
269269
}
270270

271-
fn check_struct_field(&mut self, cx: &LateContext<'_>, field: &hir::StructField<'_>) {
271+
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
272272
self.check_ty(cx, &field.ty, false);
273273
}
274274

@@ -434,7 +434,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeComplexity {
434434
self.check_fndecl(cx, decl);
435435
}
436436

437-
fn check_struct_field(&mut self, cx: &LateContext<'tcx>, field: &'tcx hir::StructField<'_>) {
437+
fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &'tcx hir::FieldDef<'_>) {
438438
// enum variants are also struct fields now
439439
self.check_type(cx, &field.ty);
440440
}
@@ -524,7 +524,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
524524
// function types bring a lot of overhead
525525
TyKind::BareFn(ref bare) if bare.abi == Abi::Rust => (50 * self.nest, 1),
526526

527-
TyKind::TraitObject(ref param_bounds, _) => {
527+
TyKind::TraitObject(ref param_bounds, _, _) => {
528528
let has_lifetime_parameters = param_bounds.iter().any(|bound| {
529529
bound
530530
.bound_generic_params

clippy_lints/src/unnested_or_patterns.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ impl EarlyLintPass for UnnestedOrPatterns {
7373
}
7474

7575
fn lint_unnested_or_patterns(cx: &EarlyContext<'_>, pat: &Pat) {
76-
if !cx.sess.features_untracked().or_patterns {
77-
// Do not suggest nesting the patterns if the feature `or_patterns` is not enabled.
78-
return;
79-
}
80-
8176
if let Ident(.., None) | Lit(_) | Wild | Path(..) | Range(..) | Rest | MacCall(_) = pat.kind {
8277
// This is a leaf pattern, so cloning is unprofitable.
8378
return;
@@ -277,7 +272,7 @@ fn transform_with_focus_on_idx(alternatives: &mut Vec<P<Pat>>, focus_idx: usize)
277272
/// and check that all `fp_i` where `i ∈ ((0...n) \ k)` between two patterns are equal.
278273
fn extend_with_struct_pat(
279274
path1: &ast::Path,
280-
fps1: &mut Vec<ast::FieldPat>,
275+
fps1: &mut Vec<ast::PatField>,
281276
rest1: bool,
282277
start: usize,
283278
alternatives: &mut Vec<P<Pat>>,

clippy_lints/src/utils/author.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ impl<'tcx> LateLintPass<'tcx> for Author {
101101
done();
102102
}
103103

104-
fn check_struct_field(&mut self, cx: &LateContext<'tcx>, field: &'tcx hir::StructField<'_>) {
104+
fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &'tcx hir::FieldDef<'_>) {
105105
if !has_attr(cx, field.hir_id) {
106106
return;
107107
}
108108
prelude();
109-
PrintVisitor::new("field").visit_struct_field(field);
109+
PrintVisitor::new("field").visit_field_def(field);
110110
done();
111111
}
112112

clippy_lints/src/utils/inspector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
8080
// }
8181
// }
8282
//
83-
// fn check_struct_field(&mut self, cx: &LateContext<'tcx>, field: &'tcx
84-
// hir::StructField) {
83+
// fn check_field_def(&mut self, cx: &LateContext<'tcx>, field: &'tcx
84+
// hir::FieldDef) {
8585
// if !has_attr(&field.attrs) {
8686
// return;
8787
// }

clippy_utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.52"
3+
version = "0.1.53"
44
authors = ["The Rust Clippy Developers"]
55
edition = "2018"
66
publish = false

clippy_utils/src/ast_utils.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn eq_range_end(l: &RangeEnd, r: &RangeEnd) -> bool {
6666
}
6767
}
6868

69-
pub fn eq_field_pat(l: &FieldPat, r: &FieldPat) -> bool {
69+
pub fn eq_field_pat(l: &PatField, r: &PatField) -> bool {
7070
l.is_placeholder == r.is_placeholder
7171
&& eq_id(l.ident, r.ident)
7272
&& eq_pat(&l.pat, &r.pat)
@@ -168,14 +168,16 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
168168
(AddrOf(lbk, lm, le), AddrOf(rbk, rm, re)) => lbk == rbk && lm == rm && eq_expr(le, re),
169169
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, |l, r| eq_qself(l, r)) && eq_path(lp, rp),
170170
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
171-
(Struct(lp, lfs, lb), Struct(rp, rfs, rb)) => {
172-
eq_path(lp, rp) && eq_struct_rest(lb, rb) && unordered_over(lfs, rfs, |l, r| eq_field(l, r))
171+
(Struct(lse), Struct(rse)) => {
172+
eq_path(&lse.path, &rse.path)
173+
&& eq_struct_rest(&lse.rest, &rse.rest)
174+
&& unordered_over(&lse.fields, &rse.fields, |l, r| eq_field(l, r))
173175
},
174176
_ => false,
175177
}
176178
}
177179

178-
pub fn eq_field(l: &Field, r: &Field) -> bool {
180+
pub fn eq_field(l: &ExprField, r: &ExprField) -> bool {
179181
l.is_placeholder == r.is_placeholder
180182
&& eq_id(l.ident, r.ident)
181183
&& eq_expr(&l.expr, &r.expr)
@@ -359,7 +361,7 @@ pub fn eq_variant_data(l: &VariantData, r: &VariantData) -> bool {
359361
}
360362
}
361363

362-
pub fn eq_struct_field(l: &StructField, r: &StructField) -> bool {
364+
pub fn eq_struct_field(l: &FieldDef, r: &FieldDef) -> bool {
363365
l.is_placeholder == r.is_placeholder
364366
&& over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r))
365367
&& eq_vis(&l.vis, &r.vis)
@@ -406,6 +408,10 @@ pub fn eq_use_tree(l: &UseTree, r: &UseTree) -> bool {
406408
eq_path(&l.prefix, &r.prefix) && eq_use_tree_kind(&l.kind, &r.kind)
407409
}
408410

411+
pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool {
412+
eq_expr(&l.value, &r.value)
413+
}
414+
409415
pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
410416
use UseTreeKind::*;
411417
match (l, r) {
@@ -416,10 +422,6 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
416422
}
417423
}
418424

419-
pub fn eq_anon_const(l: &AnonConst, r: &AnonConst) -> bool {
420-
eq_expr(&l.value, &r.value)
421-
}
422-
423425
pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
424426
matches!(
425427
(l, r),

clippy_utils/src/consts.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,11 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
341341
.tcx
342342
.const_eval_resolve(
343343
self.param_env,
344-
ty::WithOptConstParam::unknown(def_id),
345-
substs,
346-
None,
344+
ty::Unevaluated {
345+
def: ty::WithOptConstParam::unknown(def_id),
346+
substs,
347+
promoted: None,
348+
},
347349
None,
348350
)
349351
.ok()

clippy_utils/src/higher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Range<'a> {
5151
pub fn range<'a>(expr: &'a hir::Expr<'_>) -> Option<Range<'a>> {
5252
/// Finds the field named `name` in the field. Always return `Some` for
5353
/// convenience.
54-
fn get_field<'c>(name: &str, fields: &'c [hir::Field<'_>]) -> Option<&'c hir::Expr<'c>> {
54+
fn get_field<'c>(name: &str, fields: &'c [hir::ExprField<'_>]) -> Option<&'c hir::Expr<'c>> {
5555
let expr = &fields.iter().find(|field| field.ident.name.as_str() == name)?.expr;
5656

5757
Some(expr)

0 commit comments

Comments
 (0)