mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 15:47:31 +00:00
Highlight unsafe trait refs as unsafe only in impl blocks and definitions
This commit is contained in:
parent
7f482afada
commit
29054e02fb
13 changed files with 60 additions and 19 deletions
|
@ -325,6 +325,15 @@ impl ast::Impl {
|
|||
let second = types.next();
|
||||
(first, second)
|
||||
}
|
||||
|
||||
pub fn for_trait_name_ref(name_ref: &ast::NameRef) -> Option<ast::Impl> {
|
||||
let this = name_ref.syntax().ancestors().find_map(ast::Impl::cast)?;
|
||||
if this.trait_()?.syntax().text_range().start() == name_ref.syntax().text_range().start() {
|
||||
Some(this)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue