Unnamed repository; edit this file 'description' to name the repository.
Merge #11388
11388: fix: Fix proc-macro server not using the supplied span in Ident::new r=Veykril a=Veykril This makes the hack introduced by https://github.com/rust-analyzer/rust-analyzer/pull/10899 obsolete. For async-trait specifically, (unfortunately, but technically correct) due to how async-trait works, the self local now renders white, as it now resolves to the `__self` local introduced by the attribute. ![Code_0Ezw6PJAbh](https://user-images.githubusercontent.com/3757771/151827812-c03b8fc7-7ecf-4959-804a-2680d8e61e8b.png) bors r+ Co-authored-by: Lukas Wirth <[email protected]>
bors[bot] 2022-01-31
parent 1cc125f · parent f6def3c · commit 4800c05
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs20
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs9
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs9
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs9
-rw-r--r--crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs9
5 files changed, 8 insertions, 48 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 84732aef54..c869db3b8b 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -234,15 +234,6 @@ fn highlight_name_ref(
None if syntactic_name_ref_highlighting => {
return highlight_name_ref_by_syntax(name_ref, sema, krate)
}
- // FIXME: Workaround for https://github.com/rust-analyzer/rust-analyzer/issues/10708
- //
- // Some popular proc macros (namely async_trait) will rewrite `self` in such a way that it no
- // longer resolves via NameRefClass. If we can't be resolved, but we know we're a self token,
- // within a function with a self param, pretend to still be `self`, rather than
- // an unresolved reference.
- None if name_ref.self_token().is_some() && is_in_fn_with_self_param(&name_ref) => {
- return SymbolKind::SelfParam.into()
- }
// FIXME: This is required for helper attributes used by proc-macros, as those do not map down
// to anything when used.
// We can fix this for derive attributes since derive helpers are recorded, but not for
@@ -712,14 +703,3 @@ fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[Sy
fn parent_matches<N: AstNode>(token: &SyntaxToken) -> bool {
token.parent().map_or(false, |it| N::can_cast(it.kind()))
}
-
-fn is_in_fn_with_self_param(node: &ast::NameRef) -> bool {
- node.syntax()
- .ancestors()
- .find_map(ast::Item::cast)
- .and_then(|item| match item {
- ast::Item::Fn(fn_) => fn_.param_list()?.self_param(),
- _ => None,
- })
- .is_some()
-}
diff --git a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs
index d3d021d808..1ef137029d 100644
--- a/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs
+++ b/crates/proc_macro_srv/src/abis/abi_1_47/rustc_server.rs
@@ -463,13 +463,8 @@ impl server::Punct for Rustc {
}
impl server::Ident for Rustc {
- fn new(&mut self, string: &str, _span: Self::Span, _is_raw: bool) -> Self::Ident {
- IdentId(
- self.ident_interner.intern(&IdentData(tt::Ident {
- text: string.into(),
- id: tt::TokenId::unspecified(),
- })),
- )
+ fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident {
+ IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span })))
}
fn span(&mut self, ident: Self::Ident) -> Self::Span {
diff --git a/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs
index 6105238d0b..3904cb8f3e 100644
--- a/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs
+++ b/crates/proc_macro_srv/src/abis/abi_1_54/rustc_server.rs
@@ -463,13 +463,8 @@ impl server::Punct for Rustc {
}
impl server::Ident for Rustc {
- fn new(&mut self, string: &str, _span: Self::Span, _is_raw: bool) -> Self::Ident {
- IdentId(
- self.ident_interner.intern(&IdentData(tt::Ident {
- text: string.into(),
- id: tt::TokenId::unspecified(),
- })),
- )
+ fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident {
+ IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span })))
}
fn span(&mut self, ident: Self::Ident) -> Self::Span {
diff --git a/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs
index 1cebc289f8..cf79775231 100644
--- a/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs
+++ b/crates/proc_macro_srv/src/abis/abi_1_56/rustc_server.rs
@@ -464,13 +464,8 @@ impl server::Punct for Rustc {
}
impl server::Ident for Rustc {
- fn new(&mut self, string: &str, _span: Self::Span, _is_raw: bool) -> Self::Ident {
- IdentId(
- self.ident_interner.intern(&IdentData(tt::Ident {
- text: string.into(),
- id: tt::TokenId::unspecified(),
- })),
- )
+ fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident {
+ IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span })))
}
fn span(&mut self, ident: Self::Ident) -> Self::Span {
diff --git a/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs b/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs
index 31f3223acd..5c3f4da001 100644
--- a/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs
+++ b/crates/proc_macro_srv/src/abis/abi_1_58/rustc_server.rs
@@ -468,13 +468,8 @@ impl server::Punct for Rustc {
}
impl server::Ident for Rustc {
- fn new(&mut self, string: &str, _span: Self::Span, _is_raw: bool) -> Self::Ident {
- IdentId(
- self.ident_interner.intern(&IdentData(tt::Ident {
- text: string.into(),
- id: tt::TokenId::unspecified(),
- })),
- )
+ fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident {
+ IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span })))
}
fn span(&mut self, ident: Self::Ident) -> Self::Span {