Remove needless hir Map ref
This commit is contained in:
parent
35c8f2612f
commit
7c8f4f7eab
4 changed files with 15 additions and 22 deletions
|
|
@ -82,12 +82,12 @@ pub struct Map<'hir> {
|
|||
|
||||
/// An iterator that walks up the ancestor tree of a given `HirId`.
|
||||
/// Constructed using `tcx.hir().parent_iter(hir_id)`.
|
||||
pub struct ParentHirIterator<'map, 'hir> {
|
||||
pub struct ParentHirIterator<'hir> {
|
||||
current_id: HirId,
|
||||
map: &'map Map<'hir>,
|
||||
map: Map<'hir>,
|
||||
}
|
||||
|
||||
impl<'hir> Iterator for ParentHirIterator<'_, 'hir> {
|
||||
impl<'hir> Iterator for ParentHirIterator<'hir> {
|
||||
type Item = (HirId, Node<'hir>);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
|
@ -114,12 +114,12 @@ impl<'hir> Iterator for ParentHirIterator<'_, 'hir> {
|
|||
|
||||
/// An iterator that walks up the ancestor tree of a given `HirId`.
|
||||
/// Constructed using `tcx.hir().parent_owner_iter(hir_id)`.
|
||||
pub struct ParentOwnerIterator<'map, 'hir> {
|
||||
pub struct ParentOwnerIterator<'hir> {
|
||||
current_id: HirId,
|
||||
map: &'map Map<'hir>,
|
||||
map: Map<'hir>,
|
||||
}
|
||||
|
||||
impl<'hir> Iterator for ParentOwnerIterator<'_, 'hir> {
|
||||
impl<'hir> Iterator for ParentOwnerIterator<'hir> {
|
||||
type Item = (HirId, OwnerNode<'hir>);
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
|
@ -560,13 +560,13 @@ impl<'hir> Map<'hir> {
|
|||
|
||||
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
|
||||
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
|
||||
pub fn parent_iter(&self, current_id: HirId) -> ParentHirIterator<'_, 'hir> {
|
||||
pub fn parent_iter(self, current_id: HirId) -> ParentHirIterator<'hir> {
|
||||
ParentHirIterator { current_id, map: self }
|
||||
}
|
||||
|
||||
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
|
||||
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
|
||||
pub fn parent_owner_iter(&self, current_id: HirId) -> ParentOwnerIterator<'_, 'hir> {
|
||||
pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> {
|
||||
ParentOwnerIterator { current_id, map: self }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -522,8 +522,7 @@ fn item_for(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> LocalDefId {
|
|||
_ => {}
|
||||
}
|
||||
let item = {
|
||||
let hir = tcx.hir();
|
||||
let mut parent_iter = hir.parent_iter(hir_id);
|
||||
let mut parent_iter = tcx.hir().parent_iter(hir_id);
|
||||
loop {
|
||||
let node = parent_iter.next().map(|n| n.1);
|
||||
match node {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue