Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/data.rs')
-rw-r--r--crates/hir-def/src/data.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index 9c76969086..0e7acda4a7 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -168,6 +168,7 @@ pub struct TypeAliasData {
pub type_ref: Option<Interned<TypeRef>>,
pub visibility: RawVisibility,
pub is_extern: bool,
+ pub rustc_has_incoherent_inherent_impls: bool,
/// Bounds restricting the type alias itself (eg. `type Ty: Bound;` in a trait or impl).
pub bounds: Vec<Interned<TypeBound>>,
}
@@ -186,11 +187,17 @@ impl TypeAliasData {
item_tree[typ.visibility].clone()
};
+ let rustc_has_incoherent_inherent_impls = item_tree
+ .attrs(db, loc.container.module(db).krate(), ModItem::from(loc.id.value).into())
+ .by_key("rustc_has_incoherent_inherent_impls")
+ .exists();
+
Arc::new(TypeAliasData {
name: typ.name.clone(),
type_ref: typ.type_ref.clone(),
visibility,
is_extern: matches!(loc.container, ItemContainerId::ExternBlockId(_)),
+ rustc_has_incoherent_inherent_impls,
bounds: typ.bounds.to_vec(),
})
}
@@ -202,6 +209,7 @@ pub struct TraitData {
pub items: Vec<(Name, AssocItemId)>,
pub is_auto: bool,
pub is_unsafe: bool,
+ pub rustc_has_incoherent_inherent_impls: bool,
pub visibility: RawVisibility,
/// Whether the trait has `#[rust_skip_array_during_method_dispatch]`. `hir_ty` will ignore
/// method calls to this trait's methods when the receiver is an array and the crate edition is
@@ -231,11 +239,11 @@ impl TraitData {
let is_auto = tr_def.is_auto;
let is_unsafe = tr_def.is_unsafe;
let visibility = item_tree[tr_def.visibility].clone();
- let skip_array_during_method_dispatch = item_tree
- .attrs(db, module_id.krate(), ModItem::from(tree_id.value).into())
- .by_key("rustc_skip_array_during_method_dispatch")
- .exists();
-
+ let attrs = item_tree.attrs(db, module_id.krate(), ModItem::from(tree_id.value).into());
+ let skip_array_during_method_dispatch =
+ attrs.by_key("rustc_skip_array_during_method_dispatch").exists();
+ let rustc_has_incoherent_inherent_impls =
+ attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
let (items, attribute_calls, diagnostics) = match &tr_def.items {
Some(items) => {
let mut collector = AssocItemCollector::new(
@@ -258,6 +266,7 @@ impl TraitData {
is_unsafe,
visibility,
skip_array_during_method_dispatch,
+ rustc_has_incoherent_inherent_impls,
}),
diagnostics.into(),
)