Skip to content

Commit 28ec27b

Browse files
committed
Auto merge of #9388 - Jarcho:rustup, r=Jarcho
Rustup Hopefully this is done right. changelog: None
2 parents 4e31c8c + e550739 commit 28ec27b

24 files changed

+65
-61
lines changed

.github/workflows/clippy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ env:
2424
RUST_BACKTRACE: 1
2525
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
2626
NO_FMT_TEST: 1
27+
CARGO_INCREMENTAL: 0
2728

2829
jobs:
2930
base:

.github/workflows/clippy_bors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
RUST_BACKTRACE: 1
1111
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
1212
NO_FMT_TEST: 1
13+
CARGO_INCREMENTAL: 0
1314

1415
defaults:
1516
run:

clippy_lints/src/crate_in_macro_def.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef {
7474

7575
fn is_macro_export(attr: &Attribute) -> bool {
7676
if_chain! {
77-
if let AttrKind::Normal(attr_item, _) = &attr.kind;
78-
if let [segment] = attr_item.path.segments.as_slice();
77+
if let AttrKind::Normal(normal) = &attr.kind;
78+
if let [segment] = normal.item.path.segments.as_slice();
7979
then {
8080
segment.ident.name == sym::macro_export
8181
} else {

clippy_lints/src/dereference.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
22
use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
33
use clippy_utils::sugg::has_enclosing_paren;
44
use clippy_utils::ty::{expr_sig, is_copy, peel_mid_ty_refs, ty_sig, variant_of_res};
5-
use clippy_utils::{fn_def_id, get_parent_expr, is_lint_allowed, meets_msrv, msrvs, path_to_local, walk_to_expr_usage};
5+
use clippy_utils::{
6+
fn_def_id, get_parent_expr, get_parent_expr_for_hir, is_lint_allowed, meets_msrv, msrvs, path_to_local,
7+
walk_to_expr_usage,
8+
};
69
use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX};
710
use rustc_data_structures::fx::FxIndexMap;
811
use rustc_errors::Applicability;
@@ -732,6 +735,19 @@ fn walk_parents<'tcx>(
732735
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
733736
},
734737

738+
Node::ExprField(field) if field.span.ctxt() == ctxt => match get_parent_expr_for_hir(cx, field.hir_id) {
739+
Some(Expr {
740+
hir_id,
741+
kind: ExprKind::Struct(path, ..),
742+
..
743+
}) => variant_of_res(cx, cx.qpath_res(path, *hir_id))
744+
.and_then(|variant| variant.fields.iter().find(|f| f.name == field.ident.name))
745+
.map(|field_def| {
746+
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did), precedence).position_for_arg()
747+
}),
748+
_ => None,
749+
},
750+
735751
Node::Expr(parent) if parent.span.ctxt() == ctxt => match parent.kind {
736752
ExprKind::Ret(_) => {
737753
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
@@ -833,17 +849,6 @@ fn walk_parents<'tcx>(
833849
}
834850
})
835851
},
836-
ExprKind::Struct(path, fields, _) => {
837-
let variant = variant_of_res(cx, cx.qpath_res(path, parent.hir_id));
838-
fields
839-
.iter()
840-
.find(|f| f.expr.hir_id == child_id)
841-
.zip(variant)
842-
.and_then(|(field, variant)| variant.fields.iter().find(|f| f.name == field.ident.name))
843-
.map(|field| {
844-
ty_auto_deref_stability(cx, cx.tcx.type_of(field.did), precedence).position_for_arg()
845-
})
846-
},
847852
ExprKind::Field(child, name) if child.hir_id == e.hir_id => Some(Position::FieldAccess(name.name)),
848853
ExprKind::Unary(UnOp::Deref, child) if child.hir_id == e.hir_id => Some(Position::Deref),
849854
ExprKind::Match(child, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)

clippy_lints/src/double_parens.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ impl EarlyLintPass for DoubleParens {
6161
}
6262
}
6363
},
64-
ExprKind::MethodCall(_, ref params, _) => {
65-
if params.len() == 2 {
66-
let param = &params[1];
64+
ExprKind::MethodCall(_, _, ref params, _) => {
65+
if let [ref param] = params[..] {
6766
if let ExprKind::Paren(_) = param.kind {
6867
span_lint(cx, DOUBLE_PARENS, param.span, msg);
6968
}

clippy_lints/src/matches/match_same_arms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'a> NormalizedPat<'a> {
290290
LitKind::Char(val) => Self::LitInt(val.into()),
291291
LitKind::Int(val, _) => Self::LitInt(val),
292292
LitKind::Bool(val) => Self::LitBool(val),
293-
LitKind::Float(..) | LitKind::Err(_) => Self::Wild,
293+
LitKind::Float(..) | LitKind::Err => Self::Wild,
294294
},
295295
_ => Self::Wild,
296296
},

clippy_lints/src/octal_escapes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ impl EarlyLintPass for OctalEscapes {
5757
}
5858

5959
if let ExprKind::Lit(lit) = &expr.kind {
60-
if matches!(lit.token.kind, LitKind::Str) {
61-
check_lit(cx, &lit.token, lit.span, true);
62-
} else if matches!(lit.token.kind, LitKind::ByteStr) {
63-
check_lit(cx, &lit.token, lit.span, false);
60+
if matches!(lit.token_lit.kind, LitKind::Str) {
61+
check_lit(cx, &lit.token_lit, lit.span, true);
62+
} else if matches!(lit.token_lit.kind, LitKind::ByteStr) {
63+
check_lit(cx, &lit.token_lit, lit.span, false);
6464
}
6565
}
6666
}

clippy_lints/src/option_env_unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]);
3737
impl EarlyLintPass for OptionEnvUnwrap {
3838
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
3939
if_chain! {
40-
if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
40+
if let ExprKind::MethodCall(path_segment, receiver, _, _) = &expr.kind;
4141
if matches!(path_segment.ident.name, sym::expect | sym::unwrap);
42-
if let ExprKind::Call(caller, _) = &args[0].kind;
42+
if let ExprKind::Call(caller, _) = &receiver.kind;
4343
if is_direct_expn_of(caller.span, "option_env").is_some();
4444
then {
4545
span_lint_and_help(

clippy_lints/src/precedence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ impl EarlyLintPass for Precedence {
109109
let mut arg = operand;
110110

111111
let mut all_odd = true;
112-
while let ExprKind::MethodCall(path_segment, args, _) = &arg.kind {
112+
while let ExprKind::MethodCall(path_segment, receiver, _, _) = &arg.kind {
113113
let path_segment_str = path_segment.ident.name.as_str();
114114
all_odd &= ALLOWED_ODD_FUNCTIONS
115115
.iter()
116116
.any(|odd_function| **odd_function == *path_segment_str);
117-
arg = args.first().expect("A method always has a receiver.");
117+
arg = receiver;
118118
}
119119

120120
if_chain! {

clippy_lints/src/suspicious_operation_groupings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ fn ident_difference_expr_with_base_location(
595595
| (Unary(_, _), Unary(_, _))
596596
| (Binary(_, _, _), Binary(_, _, _))
597597
| (Tup(_), Tup(_))
598-
| (MethodCall(_, _, _), MethodCall(_, _, _))
598+
| (MethodCall(_, _, _, _), MethodCall(_, _, _, _))
599599
| (Call(_, _), Call(_, _))
600600
| (ConstBlock(_), ConstBlock(_))
601601
| (Array(_), Array(_))

clippy_lints/src/unused_peekable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> Visitor<'_> for PeekableVisitor<'_, 'tcx> {
201201
return;
202202
},
203203
},
204-
Node::Block(_) => {},
204+
Node::Block(_) | Node::ExprField(_) => {},
205205
_ => {
206206
break;
207207
},

clippy_lints/src/unused_rounding.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ declare_clippy_lint! {
3030
declare_lint_pass!(UnusedRounding => [UNUSED_ROUNDING]);
3131

3232
fn is_useless_rounding(expr: &Expr) -> Option<(&str, String)> {
33-
if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind
33+
if let ExprKind::MethodCall(name_ident, receiver, _, _) = &expr.kind
3434
&& let method_name = name_ident.ident.name.as_str()
3535
&& (method_name == "ceil" || method_name == "round" || method_name == "floor")
36-
&& !args.is_empty()
37-
&& let ExprKind::Lit(spanned) = &args[0].kind
36+
&& let ExprKind::Lit(spanned) = &receiver.kind
3837
&& let LitKind::Float(symbol, ty) = spanned.kind {
3938
let f = symbol.as_str().parse::<f64>().unwrap();
4039
let f_str = symbol.to_string() + if let LitFloatType::Suffixed(ty) = ty {

clippy_lints/src/unused_unit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl EarlyLintPass for UnusedUnit {
8989
}
9090
}
9191

92-
fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef, _: &ast::TraitBoundModifier) {
92+
fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef) {
9393
let segments = &poly.trait_ref.path.segments;
9494

9595
if_chain! {

clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
276276
match lit.value.node {
277277
LitKind::Bool(val) => kind!("Bool({val:?})"),
278278
LitKind::Char(c) => kind!("Char({c:?})"),
279-
LitKind::Err(val) => kind!("Err({val})"),
279+
LitKind::Err => kind!("Err"),
280280
LitKind::Byte(b) => kind!("Byte({b})"),
281281
LitKind::Int(i, suffix) => {
282282
let int_ty = match suffix {

clippy_lints/src/utils/internal_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ fn extract_clippy_version_value(cx: &LateContext<'_>, item: &'_ Item<'_>) -> Opt
593593
attrs.iter().find_map(|attr| {
594594
if_chain! {
595595
// Identify attribute
596-
if let ast::AttrKind::Normal(ref attr_kind, _) = &attr.kind;
597-
if let [tool_name, attr_name] = &attr_kind.path.segments[..];
596+
if let ast::AttrKind::Normal(ref attr_kind) = &attr.kind;
597+
if let [tool_name, attr_name] = &attr_kind.item.path.segments[..];
598598
if tool_name.ident.name == sym::clippy;
599599
if attr_name.ident.name == sym::version;
600600
if let Some(version) = attr.value_str();

clippy_lints/src/write.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,12 @@ impl Write {
683683
},
684684
};
685685

686-
let replacement: String = match lit.token.kind {
686+
let replacement: String = match lit.token_lit.kind {
687687
LitKind::StrRaw(_) | LitKind::ByteStrRaw(_) if matches!(fmtstr.style, StrStyle::Raw(_)) => {
688-
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
688+
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
689689
},
690690
LitKind::Str | LitKind::ByteStr if matches!(fmtstr.style, StrStyle::Cooked) => {
691-
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
691+
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
692692
},
693693
LitKind::StrRaw(_)
694694
| LitKind::Str
@@ -697,7 +697,7 @@ impl Write {
697697
| LitKind::Integer
698698
| LitKind::Float
699699
| LitKind::Err => continue,
700-
LitKind::Byte | LitKind::Char => match lit.token.symbol.as_str() {
700+
LitKind::Byte | LitKind::Char => match lit.token_lit.symbol.as_str() {
701701
"\"" if matches!(fmtstr.style, StrStyle::Cooked) => "\\\"",
702702
"\"" if matches!(fmtstr.style, StrStyle::Raw(0)) => continue,
703703
"\\\\" if matches!(fmtstr.style, StrStyle::Raw(_)) => "\\",
@@ -708,7 +708,7 @@ impl Write {
708708
x => x,
709709
}
710710
.into(),
711-
LitKind::Bool => lit.token.symbol.as_str().deref().into(),
711+
LitKind::Bool => lit.token_lit.symbol.as_str().deref().into(),
712712
};
713713

714714
if !fmt_spans.is_empty() {

clippy_utils/src/ast_utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
147147
(Array(l), Array(r)) | (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)),
148148
(Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value),
149149
(Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
150-
(MethodCall(lc, la, _), MethodCall(rc, ra, _)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
150+
(MethodCall(lc, ls, la, _), MethodCall(rc, rs, ra, _)) => {
151+
eq_path_seg(lc, rc) && eq_expr(ls, rs) && over(la, ra, |l, r| eq_expr(l, r))
152+
},
151153
(Binary(lo, ll, lr), Binary(ro, rl, rr)) => lo.node == ro.node && eq_expr(ll, rl) && eq_expr(lr, rr),
152154
(Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
153155
(Lit(l), Lit(r)) => l.kind == r.kind,
@@ -693,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
693695
l.style == r.style
694696
&& match (&l.kind, &r.kind) {
695697
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
696-
(Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
698+
(Normal(l), Normal(r)) => eq_path(&l.item.path, &r.item.path) && eq_mac_args(&l.item.args, &r.item.args),
697699
_ => false,
698700
}
699701
}

clippy_utils/src/attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub fn get_attr<'a>(
5959
name: &'static str,
6060
) -> impl Iterator<Item = &'a ast::Attribute> {
6161
attrs.iter().filter(move |attr| {
62-
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
63-
attr
62+
let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind {
63+
&normal.item
6464
} else {
6565
return false;
6666
};

clippy_utils/src/consts.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum Constant {
4545
/// A reference
4646
Ref(Box<Constant>),
4747
/// A literal with syntax error.
48-
Err(Symbol),
48+
Err,
4949
}
5050

5151
impl PartialEq for Constant {
@@ -118,9 +118,7 @@ impl Hash for Constant {
118118
Self::Ref(ref r) => {
119119
r.hash(state);
120120
},
121-
Self::Err(ref s) => {
122-
s.hash(state);
123-
},
121+
Self::Err => {},
124122
}
125123
}
126124
}
@@ -194,7 +192,7 @@ pub fn lit_to_mir_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
194192
_ => bug!(),
195193
},
196194
LitKind::Bool(b) => Constant::Bool(b),
197-
LitKind::Err(s) => Constant::Err(s),
195+
LitKind::Err => Constant::Err,
198196
}
199197
}
200198

clippy_utils/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,8 +1900,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {
19001900

19011901
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
19021902
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
1903-
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
1904-
attr.path == sym::no_std
1903+
if let ast::AttrKind::Normal(ref normal) = attr.kind {
1904+
normal.item.path == sym::no_std
19051905
} else {
19061906
false
19071907
}
@@ -1910,8 +1910,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
19101910

19111911
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
19121912
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
1913-
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
1914-
attr.path == sym::no_core
1913+
if let ast::AttrKind::Normal(ref normal) = attr.kind {
1914+
normal.item.path == sym::no_core
19151915
} else {
19161916
false
19171917
}

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-2022-08-11"
2+
channel = "nightly-2022-08-27"
33
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

src/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct ClippyCallbacks {
9595

9696
impl rustc_driver::Callbacks for ClippyCallbacks {
9797
// JUSTIFICATION: necessary in clippy driver to set `mir_opt_level`
98-
#[cfg_attr(not(bootstrap), allow(rustc::bad_opt_access))]
98+
#[allow(rustc::bad_opt_access)]
9999
fn config(&mut self, config: &mut interface::Config) {
100100
let previous = config.register_lints.take();
101101
let clippy_args_var = self.clippy_args_var.take();

tests/ui/semicolon_if_nothing_returned.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![warn(clippy::semicolon_if_nothing_returned)]
22
#![allow(clippy::redundant_closure)]
3-
#![feature(label_break_value)]
43
#![feature(let_else)]
54

65
fn get_unit() {}

tests/ui/semicolon_if_nothing_returned.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: consider adding a `;` to the last statement for consistent formatting
2-
--> $DIR/semicolon_if_nothing_returned.rs:10:5
2+
--> $DIR/semicolon_if_nothing_returned.rs:9:5
33
|
44
LL | println!("Hello")
55
| ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");`
66
|
77
= note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings`
88

99
error: consider adding a `;` to the last statement for consistent formatting
10-
--> $DIR/semicolon_if_nothing_returned.rs:14:5
10+
--> $DIR/semicolon_if_nothing_returned.rs:13:5
1111
|
1212
LL | get_unit()
1313
| ^^^^^^^^^^ help: add a `;` here: `get_unit();`
1414

1515
error: consider adding a `;` to the last statement for consistent formatting
16-
--> $DIR/semicolon_if_nothing_returned.rs:19:5
16+
--> $DIR/semicolon_if_nothing_returned.rs:18:5
1717
|
1818
LL | y = x + 1
1919
| ^^^^^^^^^ help: add a `;` here: `y = x + 1;`
2020

2121
error: consider adding a `;` to the last statement for consistent formatting
22-
--> $DIR/semicolon_if_nothing_returned.rs:25:9
22+
--> $DIR/semicolon_if_nothing_returned.rs:24:9
2323
|
2424
LL | hello()
2525
| ^^^^^^^ help: add a `;` here: `hello();`
2626

2727
error: consider adding a `;` to the last statement for consistent formatting
28-
--> $DIR/semicolon_if_nothing_returned.rs:36:9
28+
--> $DIR/semicolon_if_nothing_returned.rs:35:9
2929
|
3030
LL | ptr::drop_in_place(s.as_mut_ptr())
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());`

0 commit comments

Comments
 (0)