Skip to content

Commit dbc457c

Browse files
committed
Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests Successful merges: - #138374 (Enable contracts for const functions) - #138380 (ci: add runners for vanilla LLVM 20) - #138393 (Allow const patterns of matches to contain pattern types) - #139517 (std: sys: process: uefi: Use NULL stdin by default) - #139554 (std: add Output::exit_ok) - #139660 (compiletest: Add an experimental new executor to replace libtest) - #139669 (Overhaul `AssocItem`) - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file}) - #139750 (std/thread: Use default stack size from menuconfig for NuttX) - #139772 (Remove `hir::Map`) - #139785 (Let CStrings be either 1 or 2 byte aligned.) - #139789 (do not unnecessarily leak auto traits in item bounds) - #139791 (drop global where-bounds before merging candidates) - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates) - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix) - #139833 (Fix some HIR pretty-printing problems) - #139836 (Basic tests of MPMC receiver cloning) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 15c6f38 + a8c1a54 commit dbc457c

17 files changed

+31
-33
lines changed

clippy_lints/src/assigning_clones.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
111111
// Only suggest if `clone_from`/`clone_into` is explicitly implemented
112112
&& resolved_assoc_items.in_definition_order().any(|assoc|
113113
match which_trait {
114-
CloneTrait::Clone => assoc.name == sym::clone_from,
115-
CloneTrait::ToOwned => assoc.name.as_str() == "clone_into",
114+
CloneTrait::Clone => assoc.name() == sym::clone_from,
115+
CloneTrait::ToOwned => assoc.name().as_str() == "clone_into",
116116
}
117117
)
118118
&& !clone_source_borrows_from_dest(cx, lhs, rhs.span)

clippy_lints/src/bool_assert_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
5656
cx.tcx.associated_items(trait_id).find_by_ident_and_kind(
5757
cx.tcx,
5858
Ident::from_str("Output"),
59-
ty::AssocKind::Type,
59+
ty::AssocTag::Type,
6060
trait_id,
6161
)
6262
})

clippy_lints/src/format_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'tcx> FormatArgsExpr<'_, 'tcx> {
550550
// a `Target` that is in `self.ty_msrv_map`.
551551
if let Some(deref_trait_id) = self.cx.tcx.lang_items().deref_trait()
552552
&& implements_trait(self.cx, ty, deref_trait_id, &[])
553-
&& let Some(target_ty) = self.cx.get_associated_type(ty, deref_trait_id, "Target")
553+
&& let Some(target_ty) = self.cx.get_associated_type(ty, deref_trait_id, sym::Target)
554554
&& let Some(msrv) = self.ty_msrv_map.get(&target_ty)
555555
&& msrv.is_none_or(|msrv| self.msrv.meets(self.cx, msrv))
556556
{

clippy_lints/src/implied_bounds_in_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn check<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds<'tcx>) {
315315
assocs
316316
.filter_by_name_unhygienic(constraint.ident.name)
317317
.next()
318-
.is_some_and(|assoc| assoc.kind == ty::AssocKind::Type)
318+
.is_some_and(|assoc| assoc.is_type())
319319
})
320320
{
321321
emit_lint(cx, poly_trait, bounds, index, implied_constraints, bound);

clippy_lints/src/len_zero.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_hir::{
1313
QPath, TraitItemRef, TyKind,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass};
16-
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
16+
use rustc_middle::ty::{self, FnSig, Ty};
1717
use rustc_session::declare_lint_pass;
1818
use rustc_span::source_map::Spanned;
1919
use rustc_span::symbol::sym;
@@ -288,8 +288,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, ident: Iden
288288
.items()
289289
.flat_map(|&i| cx.tcx.associated_items(i).filter_by_name_unhygienic(is_empty))
290290
.any(|i| {
291-
i.kind == AssocKind::Fn
292-
&& i.fn_has_self_parameter
291+
i.is_method()
293292
&& cx.tcx.fn_sig(i.def_id).skip_binder().inputs().skip_binder().len() == 1
294293
});
295294

@@ -466,7 +465,7 @@ fn check_for_is_empty(
466465
.inherent_impls(impl_ty)
467466
.iter()
468467
.flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
469-
.find(|item| item.kind == AssocKind::Fn);
468+
.find(|item| item.is_fn());
470469

471470
let (msg, is_empty_span, self_kind) = match is_empty {
472471
None => (
@@ -486,7 +485,7 @@ fn check_for_is_empty(
486485
None,
487486
),
488487
Some(is_empty)
489-
if !(is_empty.fn_has_self_parameter
488+
if !(is_empty.is_method()
490489
&& check_is_empty_sig(
491490
cx,
492491
cx.tcx.fn_sig(is_empty.def_id).instantiate_identity().skip_binder(),
@@ -608,7 +607,7 @@ fn is_empty_array(expr: &Expr<'_>) -> bool {
608607
fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
609608
/// Gets an `AssocItem` and return true if it matches `is_empty(self)`.
610609
fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool {
611-
if item.kind == AssocKind::Fn {
610+
if item.is_fn() {
612611
let sig = cx.tcx.fn_sig(item.def_id).skip_binder();
613612
let ty = sig.skip_binder();
614613
ty.inputs().len() == 1
@@ -644,7 +643,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
644643
&& cx.tcx.get_diagnostic_item(sym::Deref).is_some_and(|deref_id| {
645644
implements_trait(cx, ty, deref_id, &[])
646645
&& cx
647-
.get_associated_type(ty, deref_id, "Target")
646+
.get_associated_type(ty, deref_id, sym::Target)
648647
.is_some_and(|deref_ty| ty_has_is_empty(cx, deref_ty, depth + 1))
649648
}))
650649
},

clippy_lints/src/methods/double_ended_iterator_last.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, self_expr: &'_ Exp
2424
&& let Ok(Some(fn_def)) = Instance::try_resolve(cx.tcx, cx.typing_env(), id, args)
2525
// find the provided definition of Iterator::last
2626
&& let Some(item) = cx.tcx.get_diagnostic_item(sym::Iterator)
27-
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name.as_str() == "last")
27+
&& let Some(last_def) = cx.tcx.provided_trait_methods(item).find(|m| m.name().as_str() == "last")
2828
// if the resolved method is the same as the provided definition
2929
&& fn_def.def_id() == last_def.def_id
3030
{

clippy_lints/src/methods/iter_overeager_cloned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub(super) fn check<'tcx>(
4848
&& let Some(method_id) = typeck.type_dependent_def_id(cloned_call.hir_id)
4949
&& cx.tcx.trait_of_item(method_id) == Some(iter_id)
5050
&& let cloned_recv_ty = typeck.expr_ty_adjusted(cloned_recv)
51-
&& let Some(iter_assoc_ty) = cx.get_associated_type(cloned_recv_ty, iter_id, "Item")
51+
&& let Some(iter_assoc_ty) = cx.get_associated_type(cloned_recv_ty, iter_id, sym::Item)
5252
&& matches!(*iter_assoc_ty.kind(), ty::Ref(_, ty, _) if !is_copy(cx, ty))
5353
{
5454
if needs_into_iter

clippy_lints/src/methods/needless_collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hir::{
1717
};
1818
use rustc_lint::LateContext;
1919
use rustc_middle::hir::nested_filter;
20-
use rustc_middle::ty::{self, AssocKind, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty};
20+
use rustc_middle::ty::{self, AssocTag, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty};
2121
use rustc_span::symbol::Ident;
2222
use rustc_span::{Span, sym};
2323

@@ -241,7 +241,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -
241241
&& let Some(iter_item) = cx.tcx.associated_items(iter_trait).find_by_ident_and_kind(
242242
cx.tcx,
243243
Ident::with_dummy_span(sym::Item),
244-
AssocKind::Type,
244+
AssocTag::Type,
245245
iter_trait,
246246
)
247247
&& let args = cx.tcx.mk_args(&[GenericArg::from(typeck.expr_ty_adjusted(iter_expr))])

clippy_lints/src/methods/or_fun_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) fn check<'tcx>(
7878
.iter()
7979
.flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg))
8080
.find_map(|assoc| {
81-
if assoc.fn_has_self_parameter
81+
if assoc.is_method()
8282
&& cx.tcx.fn_sig(assoc.def_id).skip_binder().inputs().skip_binder().len() == 1
8383
{
8484
Some(assoc.def_id)

clippy_lints/src/methods/unnecessary_iter_cloned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn check_for_loop_iter(
9999
&& let Some(into_iterator_trait_id) = cx.tcx.get_diagnostic_item(sym::IntoIterator)
100100
&& let collection_ty = cx.typeck_results().expr_ty(collection)
101101
&& implements_trait(cx, collection_ty, into_iterator_trait_id, &[])
102-
&& let Some(into_iter_item_ty) = cx.get_associated_type(collection_ty, into_iterator_trait_id, "Item")
102+
&& let Some(into_iter_item_ty) = cx.get_associated_type(collection_ty, into_iterator_trait_id, sym::Item)
103103
&& iter_item_ty == into_iter_item_ty
104104
&& let Some(collection_snippet) = collection.span.get_source_text(cx)
105105
{

0 commit comments

Comments
 (0)