diff options
author | Lukas Wirth <[email protected]> | 2021-06-15 20:44:07 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-06-15 20:49:59 +0100 |
commit | 29054e02fbc7a858d9d4a6efd61583ac45b3213b (patch) | |
tree | 87d55a0ef8df2c6263722ea3899c4e45c11173db /crates/syntax/src/ast | |
parent | 7f482afada7519e828b8dbe8fafe063885256516 (diff) |
Highlight unsafe trait refs as unsafe only in impl blocks and definitions
Diffstat (limited to 'crates/syntax/src/ast')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index 3d27d2c1a..2bd9ad867 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -325,6 +325,15 @@ impl ast::Impl { | |||
325 | let second = types.next(); | 325 | let second = types.next(); |
326 | (first, second) | 326 | (first, second) |
327 | } | 327 | } |
328 | |||
329 | pub fn for_trait_name_ref(name_ref: &ast::NameRef) -> Option<ast::Impl> { | ||
330 | let this = name_ref.syntax().ancestors().find_map(ast::Impl::cast)?; | ||
331 | if this.trait_()?.syntax().text_range().start() == name_ref.syntax().text_range().start() { | ||
332 | Some(this) | ||
333 | } else { | ||
334 | None | ||
335 | } | ||
336 | } | ||
328 | } | 337 | } |
329 | 338 | ||
330 | #[derive(Debug, Clone, PartialEq, Eq)] | 339 | #[derive(Debug, Clone, PartialEq, Eq)] |