mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
Get the right analyzer for impls
This commit is contained in:
parent
7d2080a031
commit
f4f8b81474
@ -37,7 +37,7 @@ use crate::{
|
||||
InEnvironment, TraitEnvironment, Ty,
|
||||
},
|
||||
Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam,
|
||||
Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias,
|
||||
ImplBlock, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias,
|
||||
};
|
||||
|
||||
fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> {
|
||||
@ -59,6 +59,10 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -
|
||||
let src = node.with_value(it);
|
||||
Some(Enum::from_source(db, src)?.id.resolver(db))
|
||||
},
|
||||
ast::ImplBlock(it) => {
|
||||
let src = node.with_value(it);
|
||||
Some(ImplBlock::from_source(db, src)?.id.resolver(db))
|
||||
},
|
||||
_ => match node.value.kind() {
|
||||
FN_DEF | CONST_DEF | STATIC_DEF => {
|
||||
let def = def_with_body_from_child_node(db, node)?;
|
||||
|
@ -178,7 +178,6 @@ pub(crate) fn classify_name_ref(
|
||||
Some(NameDefinition { kind, container, visibility: None })
|
||||
}
|
||||
PathResolution::GenericParam(par) => {
|
||||
// FIXME: get generic param def
|
||||
let kind = NameKind::GenericParam(par);
|
||||
Some(NameDefinition { kind, container, visibility })
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
.parameter { color: #94BFF3; }
|
||||
.builtin { color: #DD6718; }
|
||||
.text { color: #DCDCCC; }
|
||||
.type { color: #7CB8BB; }
|
||||
.attribute { color: #94BFF3; }
|
||||
.literal { color: #BFEBBF; }
|
||||
.macro { color: #94BFF3; }
|
||||
@ -45,4 +46,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
<span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable.mut">y</span>;
|
||||
|
||||
<span class="variable.mut">y</span>;
|
||||
}
|
||||
|
||||
<span class="keyword">enum</span> <span class="type">E</span><<span class="type">X</span>> {
|
||||
<span class="constant">V</span>(<span class="type">X</span>)
|
||||
}
|
||||
|
||||
<span class="keyword">impl</span><<span class="type">X</span>> <span class="type">E</span><<span class="type">X</span>> {
|
||||
<span class="keyword">fn</span> <span class="function">new</span><<span class="type">T</span>>() -> <span class="type">E</span><<span class="type">T</span>> {}
|
||||
}</code></pre>
|
@ -255,6 +255,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||
.parameter { color: #94BFF3; }
|
||||
.builtin { color: #DD6718; }
|
||||
.text { color: #DCDCCC; }
|
||||
.type { color: #7CB8BB; }
|
||||
.attribute { color: #94BFF3; }
|
||||
.literal { color: #BFEBBF; }
|
||||
.macro { color: #94BFF3; }
|
||||
@ -303,6 +304,14 @@ fn main() {
|
||||
|
||||
y;
|
||||
}
|
||||
|
||||
enum E<X> {
|
||||
V(X)
|
||||
}
|
||||
|
||||
impl<X> E<X> {
|
||||
fn new<T>() -> E<T> {}
|
||||
}
|
||||
"#
|
||||
.trim(),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user