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(_))

0 commit comments

Comments
 (0)