Skip to content

Commit d2c53d8

Browse files
committed
Auto merge of #9881 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` It took >4 weeks, but I finally got to do the sync 🎉 changelog: none
2 parents f60186f + 182fbb8 commit d2c53d8

File tree

113 files changed

+526
-622
lines changed

Some content is hidden

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

113 files changed

+526
-622
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.66"
3+
version = "0.1.67"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.66"
3+
version = "0.1.67"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

clippy_lints/src/almost_complete_letter_range.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,21 @@ impl EarlyLintPass for AlmostCompleteLetterRange {
7373
}
7474

7575
fn check_range(cx: &EarlyContext<'_>, span: Span, start: &Expr, end: &Expr, sugg: Option<(Span, &str)>) {
76-
if let ExprKind::Lit(start_lit) = &start.peel_parens().kind
77-
&& let ExprKind::Lit(end_lit) = &end.peel_parens().kind
76+
if let ExprKind::Lit(start_token_lit) = start.peel_parens().kind
77+
&& let ExprKind::Lit(end_token_lit) = end.peel_parens().kind
7878
&& matches!(
79-
(&start_lit.kind, &end_lit.kind),
80-
(LitKind::Byte(b'a') | LitKind::Char('a'), LitKind::Byte(b'z') | LitKind::Char('z'))
81-
| (LitKind::Byte(b'A') | LitKind::Char('A'), LitKind::Byte(b'Z') | LitKind::Char('Z'))
79+
(
80+
LitKind::from_token_lit(start_token_lit),
81+
LitKind::from_token_lit(end_token_lit),
82+
),
83+
(
84+
Ok(LitKind::Byte(b'a') | LitKind::Char('a')),
85+
Ok(LitKind::Byte(b'z') | LitKind::Char('z'))
86+
)
87+
| (
88+
Ok(LitKind::Byte(b'A') | LitKind::Char('A')),
89+
Ok(LitKind::Byte(b'Z') | LitKind::Char('Z')),
90+
)
8291
)
8392
&& !in_external_macro(cx.sess(), span)
8493
{

clippy_lints/src/casts/ptr_as_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Option<RustcVer
2626
(Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut));
2727
// The `U` in `pointer::cast` have to be `Sized`
2828
// as explained here: https://github.com/rust-lang/rust/issues/60602.
29-
if to_pointee_ty.is_sized(cx.tcx.at(expr.span), cx.param_env);
29+
if to_pointee_ty.is_sized(cx.tcx, cx.param_env);
3030
then {
3131
let mut applicability = Applicability::MachineApplicable;
3232
let cast_expr_sugg = Sugg::hir_with_applicability(cx, cast_expr, "_", &mut applicability);

clippy_lints/src/copy_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
4343
of_trait: Some(ref trait_ref),
4444
..
4545
}) = item.kind;
46-
let ty = cx.tcx.type_of(item.def_id);
46+
let ty = cx.tcx.type_of(item.owner_id);
4747
if is_copy(cx, ty);
4848
if let Some(trait_id) = trait_ref.trait_def_id();
4949
if cx.tcx.is_diagnostic_item(sym::Iterator, trait_id);

clippy_lints/src/default_union_representation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultUnionRepresentation {
6161
None,
6262
&format!(
6363
"consider annotating `{}` with `#[repr(C)]` to explicitly specify memory layout",
64-
cx.tcx.def_path_str(item.def_id.to_def_id())
64+
cx.tcx.def_path_str(item.owner_id.to_def_id())
6565
),
6666
);
6767
}

clippy_lints/src/dereference.rs

+17-19
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::ty::{
3030
};
3131
use rustc_semver::RustcVersion;
3232
use rustc_session::{declare_tool_lint, impl_lint_pass};
33-
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
33+
use rustc_span::{symbol::sym, Span, Symbol};
3434
use rustc_trait_selection::infer::InferCtxtExt as _;
3535
use rustc_trait_selection::traits::{query::evaluate_obligation::InferCtxtExt as _, Obligation, ObligationCause};
3636
use std::collections::VecDeque;
@@ -714,47 +714,47 @@ fn walk_parents<'tcx>(
714714
},
715715
Node::Item(&Item {
716716
kind: ItemKind::Static(..) | ItemKind::Const(..),
717-
def_id,
717+
owner_id,
718718
span,
719719
..
720720
})
721721
| Node::TraitItem(&TraitItem {
722722
kind: TraitItemKind::Const(..),
723-
def_id,
723+
owner_id,
724724
span,
725725
..
726726
})
727727
| Node::ImplItem(&ImplItem {
728728
kind: ImplItemKind::Const(..),
729-
def_id,
729+
owner_id,
730730
span,
731731
..
732732
}) if span.ctxt() == ctxt => {
733-
let ty = cx.tcx.type_of(def_id.def_id);
733+
let ty = cx.tcx.type_of(owner_id.def_id);
734734
Some(ty_auto_deref_stability(cx, ty, precedence).position_for_result(cx))
735735
},
736736

737737
Node::Item(&Item {
738738
kind: ItemKind::Fn(..),
739-
def_id,
739+
owner_id,
740740
span,
741741
..
742742
})
743743
| Node::TraitItem(&TraitItem {
744744
kind: TraitItemKind::Fn(..),
745-
def_id,
745+
owner_id,
746746
span,
747747
..
748748
})
749749
| Node::ImplItem(&ImplItem {
750750
kind: ImplItemKind::Fn(..),
751-
def_id,
751+
owner_id,
752752
span,
753753
..
754754
}) if span.ctxt() == ctxt => {
755755
let output = cx
756756
.tcx
757-
.erase_late_bound_regions(cx.tcx.fn_sig(def_id.to_def_id()).output());
757+
.erase_late_bound_regions(cx.tcx.fn_sig(owner_id.to_def_id()).output());
758758
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
759759
},
760760

@@ -1000,7 +1000,7 @@ fn binding_ty_auto_deref_stability<'tcx>(
10001000
cx.typeck_results().node_type(ty.ty.hir_id),
10011001
binder_args,
10021002
))
1003-
.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
1003+
.is_sized(cx.tcx, cx.param_env.without_caller_bounds()),
10041004
)
10051005
}
10061006
},
@@ -1015,7 +1015,7 @@ fn binding_ty_auto_deref_stability<'tcx>(
10151015
cx.typeck_results().node_type(ty.ty.hir_id),
10161016
binder_args,
10171017
))
1018-
.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
1018+
.is_sized(cx.tcx, cx.param_env.without_caller_bounds()),
10191019
),
10201020
TyKind::OpaqueDef(..) | TyKind::Infer | TyKind::Typeof(..) | TyKind::TraitObject(..) | TyKind::Err => {
10211021
Position::ReborrowStable(precedence)
@@ -1116,7 +1116,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
11161116
.iter()
11171117
.filter_map(|predicate| {
11181118
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
1119-
&& trait_predicate.self_ty() == param_ty.to_ty(cx.tcx)
1119+
&& trait_predicate.trait_ref.self_ty() == param_ty.to_ty(cx.tcx)
11201120
{
11211121
Some(trait_predicate.trait_ref.def_id)
11221122
} else {
@@ -1188,7 +1188,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
11881188
}
11891189

11901190
let predicate = EarlyBinder(predicate).subst(cx.tcx, &substs_with_referent_ty);
1191-
let obligation = Obligation::new(ObligationCause::dummy(), cx.param_env, predicate);
1191+
let obligation = Obligation::new(cx.tcx, ObligationCause::dummy(), cx.param_env, predicate);
11921192
let infcx = cx.tcx.infer_ctxt().build();
11931193
infcx.predicate_must_hold_modulo_regions(&obligation)
11941194
})
@@ -1362,7 +1362,7 @@ impl<'tcx> TyPosition<'tcx> {
13621362
fn position_for_result(self, cx: &LateContext<'tcx>) -> Position {
13631363
match (self.position, self.ty) {
13641364
(Position::ReborrowStable(precedence), Some(ty)) => {
1365-
Position::DerefStable(precedence, ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env))
1365+
Position::DerefStable(precedence, ty.is_sized(cx.tcx, cx.param_env))
13661366
},
13671367
(position, _) => position,
13681368
}
@@ -1412,11 +1412,9 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
14121412
| ty::Closure(..)
14131413
| ty::Never
14141414
| ty::Tuple(_)
1415-
| ty::Projection(_) => Position::DerefStable(
1416-
precedence,
1417-
ty.is_sized(cx.tcx.at(DUMMY_SP), cx.param_env.without_caller_bounds()),
1418-
)
1419-
.into(),
1415+
| ty::Projection(_) => {
1416+
Position::DerefStable(precedence, ty.is_sized(cx.tcx, cx.param_env.without_caller_bounds())).into()
1417+
},
14201418
};
14211419
}
14221420
}

clippy_lints/src/derivable_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
7070
self_ty,
7171
..
7272
}) = item.kind;
73-
if !cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
73+
if !cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
7474
if !item.span.from_expansion();
7575
if let Some(def_id) = trait_ref.trait_def_id();
7676
if cx.tcx.is_diagnostic_item(sym::Default, def_id);
7777
if let impl_item_hir = child.id.hir_id();
7878
if let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir);
7979
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
8080
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
81-
if let Some(adt_def) = cx.tcx.type_of(item.def_id).ty_adt_def();
81+
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).ty_adt_def();
8282
if let attrs = cx.tcx.hir().attrs(item.hir_id());
8383
if !attrs.iter().any(|attr| attr.doc_str().is_some());
8484
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
210210
..
211211
}) = item.kind
212212
{
213-
let ty = cx.tcx.type_of(item.def_id);
214-
let is_automatically_derived = cx.tcx.has_attr(item.def_id.to_def_id(), sym::automatically_derived);
213+
let ty = cx.tcx.type_of(item.owner_id);
214+
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
215215

216216
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
217217
check_ord_partial_ord(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/doc.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
294294
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return };
295295
match item.kind {
296296
hir::ItemKind::Fn(ref sig, _, body_id) => {
297-
if !(is_entrypoint_fn(cx, item.def_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
297+
if !(is_entrypoint_fn(cx, item.owner_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
298298
let body = cx.tcx.hir().body(body_id);
299299
let mut fpu = FindPanicUnwrap {
300300
cx,
301-
typeck_results: cx.tcx.typeck(item.def_id.def_id),
301+
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
302302
panic_span: None,
303303
};
304304
fpu.visit_expr(body.value);
305-
lint_for_missing_headers(cx, item.def_id.def_id, sig, headers, Some(body_id), fpu.panic_span);
305+
lint_for_missing_headers(cx, item.owner_id.def_id, sig, headers, Some(body_id), fpu.panic_span);
306306
}
307307
},
308308
hir::ItemKind::Impl(impl_) => {
@@ -312,13 +312,13 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
312312
(false, hir::Unsafety::Unsafe) => span_lint(
313313
cx,
314314
MISSING_SAFETY_DOC,
315-
cx.tcx.def_span(item.def_id),
315+
cx.tcx.def_span(item.owner_id),
316316
"docs for unsafe trait missing `# Safety` section",
317317
),
318318
(true, hir::Unsafety::Normal) => span_lint(
319319
cx,
320320
UNNECESSARY_SAFETY_DOC,
321-
cx.tcx.def_span(item.def_id),
321+
cx.tcx.def_span(item.owner_id),
322322
"docs for safe trait have unnecessary `# Safety` section",
323323
),
324324
_ => (),
@@ -338,7 +338,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
338338
let Some(headers) = check_attrs(cx, &self.valid_idents, attrs) else { return };
339339
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
340340
if !in_external_macro(cx.tcx.sess, item.span) {
341-
lint_for_missing_headers(cx, item.def_id.def_id, sig, headers, None, None);
341+
lint_for_missing_headers(cx, item.owner_id.def_id, sig, headers, None, None);
342342
}
343343
}
344344
}
@@ -353,11 +353,11 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
353353
let body = cx.tcx.hir().body(body_id);
354354
let mut fpu = FindPanicUnwrap {
355355
cx,
356-
typeck_results: cx.tcx.typeck(item.def_id.def_id),
356+
typeck_results: cx.tcx.typeck(item.owner_id.def_id),
357357
panic_span: None,
358358
};
359359
fpu.visit_expr(body.value);
360-
lint_for_missing_headers(cx, item.def_id.def_id, sig, headers, Some(body_id), fpu.panic_span);
360+
lint_for_missing_headers(cx, item.owner_id.def_id, sig, headers, Some(body_id), fpu.panic_span);
361361
}
362362
}
363363
}
@@ -370,7 +370,7 @@ fn lint_for_missing_headers(
370370
body_id: Option<hir::BodyId>,
371371
panic_span: Option<Span>,
372372
) {
373-
if !cx.access_levels.is_exported(def_id) {
373+
if !cx.effective_visibilities.is_exported(def_id) {
374374
return; // Private functions do not require doc comments
375375
}
376376

@@ -720,6 +720,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
720720
false,
721721
None,
722722
false,
723+
false,
723724
);
724725
let handler = Handler::with_emitter(false, None, Box::new(emitter));
725726
let sess = ParseSess::with_span_handler(handler, sm);

clippy_lints/src/double_parens.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ impl EarlyLintPass for DoubleParens {
6161
}
6262
}
6363
},
64-
ExprKind::MethodCall(_, _, ref params, _) => {
65-
if let [ref param] = params[..] {
66-
if let ExprKind::Paren(_) = param.kind {
67-
span_lint(cx, DOUBLE_PARENS, param.span, msg);
64+
ExprKind::MethodCall(ref call) => {
65+
if let [ref arg] = call.args[..] {
66+
if let ExprKind::Paren(_) = arg.kind {
67+
span_lint(cx, DOUBLE_PARENS, arg.span, msg);
6868
}
6969
}
7070
},

clippy_lints/src/empty_enum.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
4949
}
5050

5151
if let ItemKind::Enum(..) = item.kind {
52-
let ty = cx.tcx.type_of(item.def_id);
52+
let ty = cx.tcx.type_of(item.owner_id);
5353
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
5454
if adt.variants().is_empty() {
5555
span_lint_and_help(

clippy_lints/src/enum_variants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl LateLintPass<'_> for EnumVariantNames {
265265
}
266266
// The `module_name_repetitions` lint should only trigger if the item has the module in its
267267
// name. Having the same name is accepted.
268-
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
268+
if cx.tcx.visibility(item.owner_id).is_public() && item_camel.len() > mod_camel.len() {
269269
let matching = count_match_start(mod_camel, &item_camel);
270270
let rmatching = count_match_end(mod_camel, &item_camel);
271271
let nchars = mod_camel.chars().count();
@@ -296,7 +296,7 @@ impl LateLintPass<'_> for EnumVariantNames {
296296
}
297297
}
298298
if let ItemKind::Enum(ref def, _) = item.kind {
299-
if !(self.avoid_breaking_exported_api && cx.access_levels.is_exported(item.def_id.def_id)) {
299+
if !(self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(item.owner_id.def_id)) {
300300
check_variant(cx, self.threshold, def, item_name, item.span);
301301
}
302302
}

clippy_lints/src/escape.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_hir;
22
use rustc_hir::intravisit;
33
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind};
4-
use rustc_hir_analysis::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
4+
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_middle::mir::FakeReadCause;
@@ -88,7 +88,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
8888
// be sure we have `self` parameter in this function
8989
if trait_item.kind == (AssocItemKind::Fn { has_self: true }) {
9090
trait_self_ty = Some(
91-
TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id())
91+
TraitRef::identity(cx.tcx, trait_item.id.owner_id.to_def_id())
9292
.self_ty()
9393
.skip_binder(),
9494
);
@@ -176,13 +176,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
176176
}
177177
}
178178

179-
fn fake_read(
180-
&mut self,
181-
_: &rustc_hir_analysis::expr_use_visitor::PlaceWithHirId<'tcx>,
182-
_: FakeReadCause,
183-
_: HirId,
184-
) {
185-
}
179+
fn fake_read(&mut self, _: &rustc_hir_typeck::expr_use_visitor::PlaceWithHirId<'tcx>, _: FakeReadCause, _: HirId) {}
186180
}
187181

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

clippy_lints/src/exhaustive_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
7373
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
7474
if_chain! {
7575
if let ItemKind::Enum(..) | ItemKind::Struct(..) = item.kind;
76-
if cx.access_levels.is_exported(item.def_id.def_id);
76+
if cx.effective_visibilities.is_exported(item.owner_id.def_id);
7777
let attrs = cx.tcx.hir().attrs(item.hir_id());
7878
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
7979
then {

0 commit comments

Comments
 (0)