Propagate TraitImplHeader to hir

This commit is contained in:
Cameron Steffen
2025-07-24 09:32:58 -05:00
parent 5bc23ce255
commit bf266dc834
59 changed files with 316 additions and 299 deletions

View File

@@ -61,8 +61,8 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
// `Deref` is being implemented for `t`
if let hir::ItemKind::Impl(impl_) = item.kind
// the trait is a `Deref` implementation
&& let Some(trait_) = &impl_.of_trait
&& let Some(did) = trait_.trait_def_id()
&& let Some(of_trait) = &impl_.of_trait
&& let Some(did) = of_trait.trait_ref.trait_def_id()
&& tcx.is_lang_item(did, LangItem::Deref)
// the self type is `dyn t_principal`
&& let self_ty = tcx.type_of(item.owner_id).instantiate_identity()

View File

@@ -582,8 +582,8 @@ impl Diagnostics {
for (_hir_id, parent) in cx.tcx.hir_parent_iter(current_id) {
debug!(?parent);
if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) = parent
&& let hir::Impl { of_trait: Some(of_trait), .. } = impl_
&& let Some(def_id) = of_trait.trait_def_id()
&& let Some(of_trait) = impl_.of_trait
&& let Some(def_id) = of_trait.trait_ref.trait_def_id()
&& let Some(name) = cx.tcx.get_diagnostic_name(def_id)
&& matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::LintDiagnostic)
{

View File

@@ -129,8 +129,8 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
// of the `impl` definition
let mut collector = PathCollector { paths: Vec::new() };
collector.visit_ty_unambig(&impl_.self_ty);
if let Some(of_trait) = &impl_.of_trait {
collector.visit_trait_ref(of_trait);
if let Some(of_trait) = impl_.of_trait {
collector.visit_trait_ref(&of_trait.trait_ref);
}
// 1.5. Remove any path that doesn't resolve to a `DefId` or if it resolve to a