mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
fix: Panic when displaying generic params with defaults
This commit is contained in:
parent
e7c8b2fd81
commit
405520150d
2 changed files with 55 additions and 1 deletions
|
@ -1047,10 +1047,14 @@ impl HirDisplay for Ty {
|
|||
);
|
||||
// We print all params except implicit impl Trait params. Still a bit weird; should we leave out parent and self?
|
||||
if parameters.len() - impl_ > 0 {
|
||||
let params_len = parameters.len();
|
||||
// `parameters` are in the order of fn's params (including impl traits), fn's lifetimes
|
||||
let parameters =
|
||||
generic_args_sans_defaults(f, Some(generic_def_id), parameters);
|
||||
let without_impl = self_param as usize + type_ + const_ + lifetime;
|
||||
assert!(params_len >= parameters.len());
|
||||
let defaults = params_len - parameters.len();
|
||||
let without_impl =
|
||||
self_param as usize + type_ + const_ + lifetime - defaults;
|
||||
// parent's params (those from enclosing impl or trait, if any).
|
||||
let (fn_params, parent_params) = parameters.split_at(without_impl + impl_);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue