Skip to content

Commit 8703661

Browse files
committed
Auto merge of #11316 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` cc `@max-niederman` With the latest sync, I'm getting a lot of FP in the `redundant_locals` lint you recently added. Any ideas where this could come from? changelog: none
2 parents bd1554c + 3927677 commit 8703661

Some content is hidden

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

60 files changed

+156
-148
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ fn in_postfix_position<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> boo
800800
&& parent.span.ctxt() == e.span.ctxt()
801801
{
802802
match parent.kind {
803-
ExprKind::Call(child, _) | ExprKind::MethodCall(_, child, _, _) | ExprKind::Index(child, _)
803+
ExprKind::Call(child, _) | ExprKind::MethodCall(_, child, _, _) | ExprKind::Index(child, _, _)
804804
if child.hir_id == e.hir_id => true,
805805
ExprKind::Field(_, _) | ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar) => true,
806806
_ => false,
@@ -1170,7 +1170,7 @@ fn referent_used_exactly_once<'tcx>(
11701170
&& let [location] = *local_assignments(mir, local).as_slice()
11711171
&& let Some(statement) = mir.basic_blocks[location.block].statements.get(location.statement_index)
11721172
&& let StatementKind::Assign(box (_, Rvalue::Ref(_, _, place))) = statement.kind
1173-
&& !place.has_deref()
1173+
&& !place.is_indirect_first_projection()
11741174
// Ensure not in a loop (https://github.com/rust-lang/rust-clippy/issues/9710)
11751175
&& TriColorDepthFirstSearch::new(&mir.basic_blocks).run_from(location.block, &mut CycleDetector).is_none()
11761176
{

clippy_lints/src/derive.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ use rustc_errors::Applicability;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, Visitor};
88
use rustc_hir::{
9-
self as hir, BlockCheckMode, BodyId, Constness, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource,
10-
Unsafety,
9+
self as hir, BlockCheckMode, BodyId, Expr, ExprKind, FnDecl, Impl, Item, ItemKind, UnsafeSource, Unsafety,
1110
};
1211
use rustc_lint::{LateContext, LateLintPass};
1312
use rustc_middle::hir::nested_filter;
1413
use rustc_middle::traits::Reveal;
1514
use rustc_middle::ty::{
16-
self, BoundConstness, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate,
17-
TraitPredicate, Ty, TyCtxt,
15+
self, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate, TraitPredicate, Ty,
16+
TyCtxt,
1817
};
1918
use rustc_session::{declare_lint_pass, declare_tool_lint};
2019
use rustc_span::def_id::LocalDefId;
@@ -346,9 +345,10 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
346345
if !is_copy(cx, ty) {
347346
if ty_subs.non_erasable_generics().next().is_some() {
348347
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
349-
impls
350-
.iter()
351-
.any(|&id| matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
348+
impls.iter().any(|&id| {
349+
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
350+
if ty_adt.did() == adt.did())
351+
})
352352
});
353353
if !has_copy_impl {
354354
return;
@@ -507,7 +507,6 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
507507
if let ClauseKind::Trait(p) = p.kind().skip_binder()
508508
&& p.trait_ref.def_id == eq_trait_id
509509
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
510-
&& p.constness == BoundConstness::NotConst
511510
{
512511
// Flag types which already have an `Eq` bound.
513512
params[self_ty.index as usize].1 = false;
@@ -519,13 +518,11 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
519518
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
520519
ClauseKind::Trait(TraitPredicate {
521520
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
522-
constness: BoundConstness::NotConst,
523521
polarity: ImplPolarity::Positive,
524522
})
525523
.to_predicate(tcx)
526524
}),
527525
)),
528526
Reveal::UserFacing,
529-
Constness::NotConst,
530527
)
531528
}

clippy_lints/src/doc.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_ast::token::CommentKind;
1616
use rustc_data_structures::fx::FxHashSet;
1717
use rustc_data_structures::sync::Lrc;
1818
use rustc_errors::emitter::EmitterWriter;
19-
use rustc_errors::{Applicability, Handler, SuggestionStyle, TerminalUrl};
19+
use rustc_errors::{Applicability, Handler, SuggestionStyle};
2020
use rustc_hir as hir;
2121
use rustc_hir::intravisit::{self, Visitor};
2222
use rustc_hir::{AnonConst, Expr};
@@ -716,19 +716,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
716716
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
717717
let fallback_bundle =
718718
rustc_errors::fallback_fluent_bundle(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
719-
let emitter = EmitterWriter::new(
720-
Box::new(io::sink()),
721-
None,
722-
None,
723-
fallback_bundle,
724-
false,
725-
false,
726-
false,
727-
None,
728-
false,
729-
false,
730-
TerminalUrl::No,
731-
);
719+
let emitter = EmitterWriter::new(Box::new(io::sink()), fallback_bundle);
732720
let handler = Handler::with_emitter(Box::new(emitter)).disable_warnings();
733721
let sess = ParseSess::with_span_handler(handler, sm);
734722

clippy_lints/src/eta_reduction.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPat
1010
use rustc_infer::infer::TyCtxtInferExt;
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::ty::{
13-
self, Binder, BoundConstness, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind,
14-
GenericArgsRef, ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
13+
self, Binder, ClosureArgs, ClosureKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, GenericArgsRef,
14+
ImplPolarity, List, Region, RegionKind, Ty, TypeVisitableExt, TypeckResults,
1515
};
1616
use rustc_session::{declare_lint_pass, declare_tool_lint};
1717
use rustc_span::symbol::sym;
@@ -171,7 +171,6 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
171171
= cx.tcx.infer_ctxt().build().type_implements_fn_trait(
172172
cx.param_env,
173173
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
174-
BoundConstness::NotConst,
175174
ImplPolarity::Positive,
176175
) && path_to_local(callee)
177176
.map_or(

clippy_lints/src/functions/must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn is_mutated_static(e: &hir::Expr<'_>) -> bool {
221221
match e.kind {
222222
Path(QPath::Resolved(_, path)) => !matches!(path.res, Res::Local(_)),
223223
Path(_) => true,
224-
Field(inner, _) | Index(inner, _) => is_mutated_static(inner),
224+
Field(inner, _) | Index(inner, _, _) => is_mutated_static(inner),
225225
_ => false,
226226
}
227227
}

clippy_lints/src/index_refutable_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
254254
// Checking for slice indexing
255255
let parent_id = map.parent_id(expr.hir_id);
256256
if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id);
257-
if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind;
257+
if let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind;
258258
if let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr);
259259
if let Ok(index_value) = index_value.try_into();
260260
if index_value < max_suggested_slice;

clippy_lints/src/indexing_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
103103
return;
104104
}
105105

106-
if let ExprKind::Index(array, index) = &expr.kind {
106+
if let ExprKind::Index(array, index, _) = &expr.kind {
107107
let note = "the suggestion might not be applicable in constant blocks";
108108
let ty = cx.typeck_results().expr_ty(array).peel_refs();
109109
if let Some(range) = higher::Range::hir(index) {

clippy_lints/src/init_numbered_fields.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
5050
&& fields
5151
.iter()
5252
.all(|f| f.ident.as_str().as_bytes().iter().all(u8::is_ascii_digit))
53-
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias, ..))
53+
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias { .. }, ..))
5454
{
5555
let expr_spans = fields
5656
.iter()

clippy_lints/src/large_const_arrays.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
5050
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
5151
if_chain! {
5252
if !item.span.from_expansion();
53-
if let ItemKind::Const(hir_ty, _) = &item.kind;
53+
if let ItemKind::Const(hir_ty, generics, _) = &item.kind;
54+
// Since static items may not have generics, skip generic const items.
55+
// FIXME(generic_const_items): I don't think checking `generics.hwcp` suffices as it
56+
// doesn't account for empty where-clauses that only consist of keyword `where` IINM.
57+
if generics.params.is_empty() && !generics.has_where_clause_predicates;
5458
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
5559
if let ty::Array(element_type, cst) = ty.kind();
5660
if let ConstKind::Value(ty::ValTree::Leaf(element_count)) = cst.kind();

clippy_lints/src/loops/manual_memcpy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub(super) fn check<'tcx>(
6060
o.and_then(|(lhs, rhs)| {
6161
let rhs = fetch_cloned_expr(rhs);
6262
if_chain! {
63-
if let ExprKind::Index(base_left, idx_left) = lhs.kind;
64-
if let ExprKind::Index(base_right, idx_right) = rhs.kind;
63+
if let ExprKind::Index(base_left, idx_left, _) = lhs.kind;
64+
if let ExprKind::Index(base_right, idx_right, _) = rhs.kind;
6565
if let Some(ty) = get_slice_like_element_ty(cx, cx.typeck_results().expr_ty(base_left));
6666
if get_slice_like_element_ty(cx, cx.typeck_results().expr_ty(base_right)).is_some();
6767
if let Some((start_left, offset_left)) = get_details_from_idx(cx, idx_left, &starts);

0 commit comments

Comments
 (0)