Skip to content

Commit f49f1b1

Browse files
committed
Auto merge of #7364 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 7c9da3c + 8302eef commit f49f1b1

11 files changed

+38
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.54"
3+
version = "0.1.55"
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

Lines changed: 1 addition & 1 deletion
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.54"
4+
version = "0.1.55"
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/misc_early/unneeded_field_pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_lint::{EarlyContext, LintContext};
55
use super::UNNEEDED_FIELD_PATTERN;
66

77
pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) {
8-
if let PatKind::Struct(ref npat, ref pfields, _) = pat.kind {
8+
if let PatKind::Struct(_, ref npat, ref pfields, _) = pat.kind {
99
let mut wilds = 0;
1010
let type_name = npat
1111
.segments

clippy_lints/src/misc_early/unneeded_wildcard_pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_span::source_map::Span;
77
use super::UNNEEDED_WILDCARD_PATTERN;
88

99
pub(super) fn check(cx: &EarlyContext<'_>, pat: &Pat) {
10-
if let PatKind::TupleStruct(_, ref patterns) | PatKind::Tuple(ref patterns) = pat.kind {
10+
if let PatKind::TupleStruct(_, _, ref patterns) | PatKind::Tuple(ref patterns) = pat.kind {
1111
if let Some(rest_index) = patterns.iter().position(|pat| pat.is_rest()) {
1212
if let Some((left_index, left_pat)) = patterns[..rest_index]
1313
.iter()

clippy_lints/src/non_expressive_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> {
138138
self.check_ident(ident);
139139
}
140140
},
141-
PatKind::Struct(_, ref fields, _) => {
141+
PatKind::Struct(_, _, ref fields, _) => {
142142
for field in fields {
143143
if !field.is_shorthand {
144144
self.visit_pat(&field.pat);

clippy_lints/src/unnested_or_patterns.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::wildcard_imports, clippy::enum_glob_use)]
22

3-
use clippy_utils::ast_utils::{eq_field_pat, eq_id, eq_pat, eq_path};
3+
use clippy_utils::ast_utils::{eq_field_pat, eq_id, eq_maybe_qself, eq_pat, eq_path};
44
use clippy_utils::diagnostics::span_lint_and_then;
55
use clippy_utils::{meets_msrv, msrvs, over};
66
use rustc_ast::mut_visit::*;
@@ -273,16 +273,17 @@ fn transform_with_focus_on_idx(alternatives: &mut Vec<P<Pat>>, focus_idx: usize)
273273
|k| always_pat!(k, Tuple(ps) => ps),
274274
),
275275
// Transform `S(pre, x, post) | ... | S(pre, y, post)` into `S(pre, x | y, post)`.
276-
TupleStruct(path1, ps1) => extend_with_matching_product(
276+
TupleStruct(qself1, path1, ps1) => extend_with_matching_product(
277277
ps1, start, alternatives,
278278
|k, ps1, idx| matches!(
279279
k,
280-
TupleStruct(path2, ps2) if eq_path(path1, path2) && eq_pre_post(ps1, ps2, idx)
280+
TupleStruct(qself2, path2, ps2)
281+
if eq_maybe_qself(qself1, qself2) && eq_path(path1, path2) && eq_pre_post(ps1, ps2, idx)
281282
),
282-
|k| always_pat!(k, TupleStruct(_, ps) => ps),
283+
|k| always_pat!(k, TupleStruct(_, _, ps) => ps),
283284
),
284285
// Transform a record pattern `S { fp_0, ..., fp_n }`.
285-
Struct(path1, fps1, rest1) => extend_with_struct_pat(path1, fps1, *rest1, start, alternatives),
286+
Struct(qself1, path1, fps1, rest1) => extend_with_struct_pat(qself1, path1, fps1, *rest1, start, alternatives),
286287
};
287288

288289
alternatives[focus_idx].kind = focus_kind;
@@ -294,6 +295,7 @@ fn transform_with_focus_on_idx(alternatives: &mut Vec<P<Pat>>, focus_idx: usize)
294295
/// So when we fixate on some `ident_k: pat_k`, we try to find `ident_k` in the other pattern
295296
/// and check that all `fp_i` where `i ∈ ((0...n) \ k)` between two patterns are equal.
296297
fn extend_with_struct_pat(
298+
qself1: &Option<ast::QSelf>,
297299
path1: &ast::Path,
298300
fps1: &mut Vec<ast::PatField>,
299301
rest1: bool,
@@ -306,8 +308,9 @@ fn extend_with_struct_pat(
306308
start,
307309
alternatives,
308310
|k| {
309-
matches!(k, Struct(path2, fps2, rest2)
311+
matches!(k, Struct(qself2, path2, fps2, rest2)
310312
if rest1 == *rest2 // If one struct pattern has `..` so must the other.
313+
&& eq_maybe_qself(qself1, qself2)
311314
&& eq_path(path1, path2)
312315
&& fps1.len() == fps2.len()
313316
&& fps1.iter().enumerate().all(|(idx_1, fp1)| {
@@ -323,7 +326,7 @@ fn extend_with_struct_pat(
323326
}))
324327
},
325328
// Extract `p2_k`.
326-
|k| always_pat!(k, Struct(_, mut fps, _) => fps.swap_remove(pos_in_2.take().unwrap()).pat),
329+
|k| always_pat!(k, Struct(_, _, mut fps, _) => fps.swap_remove(pos_in_2.take().unwrap()).pat),
327330
);
328331
extend_with_tail_or(&mut fps1[idx].pat, tail_or)
329332
})

clippy_utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_utils"
3-
version = "0.1.54"
3+
version = "0.1.55"
44
authors = ["The Rust Clippy Developers"]
55
edition = "2018"
66
publish = false

clippy_utils/src/ast_utils.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ pub fn eq_pat(l: &Pat, r: &Pat) -> bool {
4747
| (Ref(l, Mutability::Mut), Ref(r, Mutability::Mut)) => eq_pat(l, r),
4848
(Tuple(l), Tuple(r)) | (Slice(l), Slice(r)) => over(l, r, |l, r| eq_pat(l, r)),
4949
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, |l, r| eq_qself(l, r)) && eq_path(lp, rp),
50-
(TupleStruct(lp, lfs), TupleStruct(rp, rfs)) => eq_path(lp, rp) && over(lfs, rfs, |l, r| eq_pat(l, r)),
51-
(Struct(lp, lfs, lr), Struct(rp, rfs, rr)) => {
52-
lr == rr && eq_path(lp, rp) && unordered_over(lfs, rfs, |lf, rf| eq_field_pat(lf, rf))
50+
(TupleStruct(lqself, lp, lfs), TupleStruct(rqself, rp, rfs)) => {
51+
eq_maybe_qself(lqself, rqself) && eq_path(lp, rp) && over(lfs, rfs, |l, r| eq_pat(l, r))
52+
},
53+
(Struct(lqself, lp, lfs, lr), Struct(rqself, rp, rfs, rr)) => {
54+
lr == rr
55+
&& eq_maybe_qself(lqself, rqself)
56+
&& eq_path(lp, rp)
57+
&& unordered_over(lfs, rfs, |lf, rf| eq_field_pat(lf, rf))
5358
},
5459
(Or(ls), Or(rs)) => unordered_over(ls, rs, |l, r| eq_pat(l, r)),
5560
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
@@ -78,6 +83,14 @@ pub fn eq_qself(l: &QSelf, r: &QSelf) -> bool {
7883
l.position == r.position && eq_ty(&l.ty, &r.ty)
7984
}
8085

86+
pub fn eq_maybe_qself(l: &Option<QSelf>, r: &Option<QSelf>) -> bool {
87+
match (l, r) {
88+
(Some(l), Some(r)) => eq_qself(l, r),
89+
(None, None) => true,
90+
_ => false,
91+
}
92+
}
93+
8194
pub fn eq_path(l: &Path, r: &Path) -> bool {
8295
over(&l.segments, &r.segments, |l, r| eq_path_seg(l, r))
8396
}
@@ -170,7 +183,8 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
170183
(Path(lq, lp), Path(rq, rp)) => both(lq, rq, |l, r| eq_qself(l, r)) && eq_path(lp, rp),
171184
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
172185
(Struct(lse), Struct(rse)) => {
173-
eq_path(&lse.path, &rse.path)
186+
eq_maybe_qself(&lse.qself, &rse.qself)
187+
&& eq_path(&lse.path, &rse.path)
174188
&& eq_struct_rest(&lse.rest, &rse.rest)
175189
&& unordered_over(&lse.fields, &rse.fields, |l, r| eq_field(l, r))
176190
},

clippy_utils/src/paths.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ pub const PERMISSIONS_FROM_MODE: [&str; 7] = ["std", "os", "imp", "unix", "fs",
116116
pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"];
117117
pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"];
118118
pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];
119-
pub const PTR_COPY: [&str; 4] = ["core", "intrinsics", "", "copy"];
120-
pub const PTR_COPY_NONOVERLAPPING: [&str; 4] = ["core", "intrinsics", "", "copy_nonoverlapping"];
119+
pub const PTR_COPY: [&str; 3] = ["core", "intrinsics", "copy"];
120+
pub const PTR_COPY_NONOVERLAPPING: [&str; 3] = ["core", "intrinsics", "copy_nonoverlapping"];
121121
pub const PTR_EQ: [&str; 3] = ["core", "ptr", "eq"];
122122
pub const PTR_NULL: [&str; 3] = ["core", "ptr", "null"];
123123
pub const PTR_NULL_MUT: [&str; 3] = ["core", "ptr", "null_mut"];

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2021-06-03"
2+
channel = "nightly-2021-06-17"
33
components = ["llvm-tools-preview", "rustc-dev", "rust-src"]

tests/ui/missing-doc-crate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![warn(clippy::missing_docs_in_private_items)]
2-
#![feature(external_doc)]
3-
#![doc(include = "../../README.md")]
2+
#![doc = include_str!("../../README.md")]
43

54
fn main() {}

0 commit comments

Comments
 (0)