-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Hi!
I was hacking a little bit on syntax highlighting support (forked the backend from #2061)
Overall I was able to able to get it to work quite nicely (I've made it a bit more granular so I could have finer control of the scopes)
However, it seems that some itemsaren't getting resolved correctly.
If you look at the definition from calc_binding_hash for the inner hash definition the first instance of T (the declaration) is correctly resolved and colored as a generic parameter.
However when trying to use T is than gets marked as text.
The reason is that for some reason classify_name_ref returns None for this instance of T.
in classify_name_ref, analyzer.resolve_path returns None for T, but I couldn't understand why it was doing that.
You could also see that further definitions inside calc_binding_hash aren't correctly colored as well, perhaps because of similar reasons.
To reproduce I used the test test_highlighting, with the following text
#[derive(Clone, Debug)]
struct Foo {
pub x: i32,
pub y: i32,
}
fn bar<T>() -> T {
unimplemented!();
foo::<i32>();
}
fn bar_params(a: u8) {
unimplemented!();
}
// comment
fn main() {
println!("Hello, {}!", 92);
let e = Option::None;
let mut vec = Vec::new();
if true {
vec.push(Foo { x: 0, y: 1 });
}
unsafe { vec.set_len(0); }
let mut x = 42;
let y = &mut x;
let z = &y;
y;
}
fn calc_binding_hash() -> u64 {
fn hash<T: std::hash::Hash + std::fmt::Debug>(x: T) -> u64 {
use std::{collections::hash_map::DefaultHasher, hash::Hasher};
let mut hasher = DefaultHasher::new();
x.hash(&mut hasher);
hasher.finish()
}
}
