mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-04 02:54:00 +00:00
Adds a param_idx helper
This commit is contained in:
parent
2dfbec149f
commit
12bf008ab1
@ -992,8 +992,8 @@ impl TypeParam {
|
||||
|
||||
pub fn default(self, db: &dyn HirDatabase) -> Option<Ty> {
|
||||
let params = db.generic_defaults(self.id.parent);
|
||||
let local_idx: u32 = self.id.local_id.into_raw().into();
|
||||
params.get(local_idx as usize).map(|d| d.clone())
|
||||
let local_idx = hir_ty::param_idx(db, self.id)?;
|
||||
params.get(local_idx).map(|d| d.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,6 +427,11 @@ impl Substs {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return an index of a parameter in the generic type parameter list by it's id.
|
||||
pub fn param_idx(db: &dyn HirDatabase, id: TypeParamId) -> Option<usize> {
|
||||
generics(db.upcast(), id.parent).param_idx(id)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SubstsBuilder {
|
||||
vec: Vec<Ty>,
|
||||
|
Loading…
Reference in New Issue
Block a user