-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix incremental bugs in the HIR map #69015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,10 @@ pub mod map; | |
|
||
use crate::ty::query::Providers; | ||
use crate::ty::TyCtxt; | ||
use rustc_hir::def_id::LOCAL_CRATE; | ||
use rustc_hir::def_id::{DefId, LOCAL_CRATE}; | ||
use rustc_hir::print; | ||
use rustc_hir::Crate; | ||
use rustc_hir::HirId; | ||
use std::ops::Deref; | ||
|
||
/// A wrapper type which allows you to access HIR. | ||
|
@@ -46,9 +47,17 @@ impl<'tcx> TyCtxt<'tcx> { | |
pub fn hir(self) -> Hir<'tcx> { | ||
Hir { tcx: self, map: &self.hir_map } | ||
} | ||
|
||
pub fn hir_id_parent_module(self, id: HirId) -> DefId { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe renaming the query to |
||
self.parent_module(DefId::local(id.owner)) | ||
} | ||
} | ||
|
||
pub fn provide(providers: &mut Providers<'_>) { | ||
providers.parent_module = |tcx, id| { | ||
let hir = tcx.hir(); | ||
hir.get_module_parent(hir.as_local_hir_id(id).unwrap()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this function |
||
}; | ||
providers.hir_crate = |tcx, _| tcx.hir_map.untracked_krate(); | ||
map::provide(providers); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this logic is supposed to do exactly (before or after the change)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is supposed to add a
read
to the node which reveals the parent of theHirId
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I understand the original thinking now: The fingerprint of
HirBody
contains the information of the entire item (including the "signature" parts) so adding a dependency toHirBody
is the conservative choice.But as you discovered the
parent
is not hashed into any of the two dep-nodes, so we are clearly missing dependencies here.I assume that the
if hir_id.local_id == ItemLocalId::from_u32_const(0)
check is based on the assumption that the parent of any node except the item root is part of the same HIR item and thus theHirBody
fingerprint contains the appropriate information? If that's the case it is far from obvious and a clarifying comment will be much appreciated by anybody trying to understand this code.