diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2023-04-06 19:44:06 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2023-04-06 19:44:29 +0200 |
| commit | 40c068f502e9bbc38fb66ea3e5b36dcb316dc761 (patch) | |
| tree | 77bde060929ffeabe2a21b2262923237bc5034c8 | |
| parent | 99b69525f426c14e0a3b18bda6d848fd35b5833b (diff) | |
| download | rust-40c068f502e9bbc38fb66ea3e5b36dcb316dc761.tar.gz rust-40c068f502e9bbc38fb66ea3e5b36dcb316dc761.zip | |
Use hir_def::builtin_attr::find_builtin_attr_idx
| -rw-r--r-- | crates/hir-def/src/nameres/attr_resolution.rs | 9 | ||||
| -rw-r--r-- | crates/hir/src/lib.rs | 4 |
2 files changed, 4 insertions, 9 deletions
diff --git a/crates/hir-def/src/nameres/attr_resolution.rs b/crates/hir-def/src/nameres/attr_resolution.rs index 79cabeb0fb7..9eb3eaa489e 100644 --- a/crates/hir-def/src/nameres/attr_resolution.rs +++ b/crates/hir-def/src/nameres/attr_resolution.rs @@ -83,12 +83,9 @@ impl DefMap { } if segments.len() == 1 { - let registered = self.registered_attrs.iter().map(SmolStr::as_str); - let is_inert = builtin_attr::INERT_ATTRIBUTES - .iter() - .map(|it| it.name) - .chain(registered) - .any(pred); + let mut registered = self.registered_attrs.iter().map(SmolStr::as_str); + let is_inert = + builtin_attr::find_builtin_attr_idx(&name).is_some() || registered.any(pred); return is_inert; } } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index bb78ee549be..05bcf12be5b 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2697,9 +2697,7 @@ impl BuiltinAttr { } fn builtin(name: &str) -> Option<Self> { - hir_def::builtin_attr::INERT_ATTRIBUTES - .iter() - .position(|tool| tool.name == name) + hir_def::builtin_attr::find_builtin_attr_idx(name) .map(|idx| BuiltinAttr { krate: None, idx: idx as u32 }) } |
