mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
fix lifetime length are not added in count of params in highlight
This commit is contained in:
parent
4b33850c39
commit
20b12c2bac
2 changed files with 21 additions and 2 deletions
|
@ -644,7 +644,8 @@ pub fn is_dyn_method(
|
|||
let ItemContainerId::TraitId(trait_id) = func.lookup(db.upcast()).container else {
|
||||
return None;
|
||||
};
|
||||
let trait_params = db.generic_params(trait_id.into()).type_or_consts.len();
|
||||
let generic_params = db.generic_params(trait_id.into());
|
||||
let trait_params = generic_params.type_or_consts.len() + generic_params.lifetimes.len();
|
||||
let fn_params = fn_subst.len(Interner) - trait_params;
|
||||
let trait_ref = TraitRef {
|
||||
trait_id: to_chalk_trait_id(trait_id),
|
||||
|
@ -686,7 +687,8 @@ pub(crate) fn lookup_impl_method_query(
|
|||
let ItemContainerId::TraitId(trait_id) = func.lookup(db.upcast()).container else {
|
||||
return (func, fn_subst);
|
||||
};
|
||||
let trait_params = db.generic_params(trait_id.into()).type_or_consts.len();
|
||||
let generic_params = db.generic_params(trait_id.into());
|
||||
let trait_params = generic_params.type_or_consts.len() + generic_params.lifetimes.len();
|
||||
let fn_params = fn_subst.len(Interner) - trait_params;
|
||||
let trait_ref = TraitRef {
|
||||
trait_id: to_chalk_trait_id(trait_id),
|
||||
|
|
|
@ -1229,3 +1229,20 @@ fn benchmark_syntax_highlighting_parser() {
|
|||
};
|
||||
assert_eq!(hash, 1169);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn highlight_trait_with_lifetimes_regression_16958() {
|
||||
let (analysis, file_id) = fixture::file(
|
||||
r#"
|
||||
pub trait Deserialize<'de> {
|
||||
fn deserialize();
|
||||
}
|
||||
|
||||
fn f<'de, T: Deserialize<'de>>() {
|
||||
T::deserialize();
|
||||
}
|
||||
"#
|
||||
.trim(),
|
||||
);
|
||||
let _ = analysis.highlight(HL_CONFIG, file_id).unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue