Skip to content

Commit 610a94c

Browse files
committed
Add fundamental attributes to data
1 parent 2c364f6 commit 610a94c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

crates/hir-def/src/adt.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct StructData {
4040
pub repr: Option<ReprOptions>,
4141
pub visibility: RawVisibility,
4242
pub rustc_has_incoherent_inherent_impls: bool,
43+
pub fundamental: bool,
4344
}
4445

4546
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -173,10 +174,10 @@ impl StructData {
173174
let item_tree = loc.id.item_tree(db);
174175
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
175176
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();
176-
let rustc_has_incoherent_inherent_impls = item_tree
177-
.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into())
178-
.by_key("rustc_has_incoherent_inherent_impls")
179-
.exists();
177+
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
178+
let rustc_has_incoherent_inherent_impls =
179+
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
180+
let fundamental = attrs.by_key("fundamental").exists();
180181

181182
let strukt = &item_tree[loc.id.value];
182183
let (variant_data, diagnostics) = lower_fields(
@@ -196,6 +197,7 @@ impl StructData {
196197
repr,
197198
visibility: item_tree[strukt.visibility].clone(),
198199
rustc_has_incoherent_inherent_impls,
200+
fundamental,
199201
}),
200202
diagnostics.into(),
201203
)
@@ -215,10 +217,10 @@ impl StructData {
215217
let repr = repr_from_value(db, krate, &item_tree, ModItem::from(loc.id.value).into());
216218
let cfg_options = db.crate_graph()[loc.container.krate].cfg_options.clone();
217219

218-
let rustc_has_incoherent_inherent_impls = item_tree
219-
.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into())
220-
.by_key("rustc_has_incoherent_inherent_impls")
221-
.exists();
220+
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
221+
let rustc_has_incoherent_inherent_impls =
222+
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
223+
let fundamental = attrs.by_key("fundamental").exists();
222224

223225
let union = &item_tree[loc.id.value];
224226
let (variant_data, diagnostics) = lower_fields(
@@ -238,6 +240,7 @@ impl StructData {
238240
repr,
239241
visibility: item_tree[union.visibility].clone(),
240242
rustc_has_incoherent_inherent_impls,
243+
fundamental,
241244
}),
242245
diagnostics.into(),
243246
)

crates/hir-def/src/data.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,12 @@ pub struct TraitData {
221221
pub is_auto: bool,
222222
pub is_unsafe: bool,
223223
pub rustc_has_incoherent_inherent_impls: bool,
224+
pub skip_array_during_method_dispatch: bool,
225+
pub fundamental: bool,
224226
pub visibility: RawVisibility,
225227
/// Whether the trait has `#[rust_skip_array_during_method_dispatch]`. `hir_ty` will ignore
226228
/// method calls to this trait's methods when the receiver is an array and the crate edition is
227229
/// 2015 or 2018.
228-
pub skip_array_during_method_dispatch: bool,
229230
// box it as the vec is usually empty anyways
230231
pub attribute_calls: Option<Box<Vec<(AstId<ast::Item>, MacroCallId)>>>,
231232
}
@@ -254,6 +255,7 @@ impl TraitData {
254255
attrs.by_key("rustc_skip_array_during_method_dispatch").exists();
255256
let rustc_has_incoherent_inherent_impls =
256257
attrs.by_key("rustc_has_incoherent_inherent_impls").exists();
258+
let fundamental = attrs.by_key("fundamental").exists();
257259
let mut collector =
258260
AssocItemCollector::new(db, module_id, tree_id.file_id(), ItemContainerId::TraitId(tr));
259261
collector.collect(&item_tree, tree_id.tree_id(), &tr_def.items);
@@ -269,6 +271,7 @@ impl TraitData {
269271
visibility,
270272
skip_array_during_method_dispatch,
271273
rustc_has_incoherent_inherent_impls,
274+
fundamental,
272275
}),
273276
diagnostics.into(),
274277
)

0 commit comments

Comments
 (0)