From 955064b6aaa5c24e980328f9d9fbe731cc29636c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 1 Jun 2021 21:33:14 +0200 Subject: Implement `#[rustc_skip_array_during_method_dispatch]` --- crates/hir_def/src/data.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index d2bb381be..2f06a6e29 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -143,6 +143,7 @@ pub struct TraitData { pub is_auto: bool, pub is_unsafe: bool, pub visibility: RawVisibility, + pub skip_array_during_method_dispatch: bool, } impl TraitData { @@ -157,6 +158,10 @@ impl TraitData { let container = AssocContainerId::TraitId(tr); let visibility = item_tree[tr_def.visibility].clone(); let mut expander = Expander::new(db, tr_loc.id.file_id(), module_id); + let skip_array_during_method_dispatch = item_tree + .attrs(db, tr_loc.container.krate(), ModItem::from(tr_loc.id.value).into()) + .by_key("rustc_skip_array_during_method_dispatch") + .exists(); let items = collect_items( db, @@ -168,7 +173,14 @@ impl TraitData { 100, ); - Arc::new(TraitData { name, items, is_auto, is_unsafe, visibility }) + Arc::new(TraitData { + name, + items, + is_auto, + is_unsafe, + visibility, + skip_array_during_method_dispatch, + }) } pub fn associated_types(&self) -> impl Iterator + '_ { -- cgit v1.2.3 From 70e19fd1cb442587abb61258af341b6e530032d4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 3 Jun 2021 13:51:43 +0200 Subject: Add comment --- crates/hir_def/src/data.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/data.rs b/crates/hir_def/src/data.rs index 2f06a6e29..52cb7777b 100644 --- a/crates/hir_def/src/data.rs +++ b/crates/hir_def/src/data.rs @@ -143,6 +143,9 @@ pub struct TraitData { pub is_auto: bool, pub is_unsafe: 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 + /// 2015 or 2018. pub skip_array_during_method_dispatch: bool, } -- cgit v1.2.3