diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-14 11:39:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 11:39:38 +0200 |
| commit | ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3 (patch) | |
| tree | 50511e481adb021187feccd4081f19198650b996 /compiler/rustc_lint/src | |
| parent | 952584942cdedc7e9e4d4037f2355932f8d75a2e (diff) | |
| parent | d4eb0947f133d8f44594d7551d99a48daff21c02 (diff) | |
| download | rust-ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3.tar.gz rust-ad21c6d89822a7444cd4e10fc47c7af1dbc9c0b3.zip | |
Rollup merge of #145266 - camsteffen:reduce-queries, r=petrochenkov
Reduce some queries around associated items
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/pass_by_value.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index 4f65acd8001..29006732aad 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -24,10 +24,8 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue { fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx hir::Ty<'tcx, AmbigArg>) { match &ty.kind { TyKind::Ref(_, hir::MutTy { ty: inner_ty, mutbl: hir::Mutability::Not }) => { - if let Some(impl_did) = cx.tcx.impl_of_assoc(ty.hir_id.owner.to_def_id()) { - if cx.tcx.impl_trait_ref(impl_did).is_some() { - return; - } + if cx.tcx.trait_impl_of_assoc(ty.hir_id.owner.to_def_id()).is_some() { + return; } if let Some(t) = path_for_pass_by_value(cx, inner_ty) { cx.emit_span_lint( diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index b0afc333ebe..f8a692313f0 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -1904,10 +1904,9 @@ impl InvalidAtomicOrdering { if let ExprKind::MethodCall(method_path, _, args, _) = &expr.kind && recognized_names.contains(&method_path.ident.name) && let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && let Some(impl_did) = cx.tcx.impl_of_assoc(m_def_id) - && let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def() // skip extension traits, only lint functions from the standard library - && cx.tcx.trait_id_of_impl(impl_did).is_none() + && let Some(impl_did) = cx.tcx.inherent_impl_of_assoc(m_def_id) + && let Some(adt) = cx.tcx.type_of(impl_did).instantiate_identity().ty_adt_def() && let parent = cx.tcx.parent(adt.did()) && cx.tcx.is_diagnostic_item(sym::atomic_mod, parent) && ATOMIC_TYPES.contains(&cx.tcx.item_name(adt.did())) |
