Auto merge of #14185 - anergictcell:fix_14142, r=HKalbasi

Fix: Run doctests for structs with lifetime parameters from IDE

Fixes #14142: Doctests can't be triggered for structs with lifetimes

This MR adds lifetime parameters to the structs path for runnables so that they can be triggered from an IDE as well.

This is my first MR for rust-analyzer, please let me know if I should change something, either in code or the description here.
This commit is contained in:
bors 2023-02-28 09:52:03 +00:00
commit c386316fe0
3 changed files with 370 additions and 10 deletions

View file

@ -459,6 +459,13 @@ impl Resolver {
})
}
pub fn generic_params(&self) -> Option<&Interned<GenericParams>> {
self.scopes().find_map(|scope| match scope {
Scope::GenericParams { params, .. } => Some(params),
_ => None,
})
}
pub fn body_owner(&self) -> Option<DefWithBodyId> {
self.scopes().find_map(|scope| match scope {
Scope::ExprScope(it) => Some(it.owner),