-
Notifications
You must be signed in to change notification settings - Fork 13.3k
query for def_span #41593
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
query for def_span #41593
Changes from 5 commits
932d251
93ac5df
ba90718
2f73b17
ad1959e
00d02cf
d3b7af0
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 |
---|---|---|
|
@@ -285,6 +285,12 @@ impl<'tcx> QueryDescription for queries::describe_def<'tcx> { | |
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::def_span<'tcx> { | ||
fn describe(_: TyCtxt, _: DefId) -> String { | ||
bug!("def_span") | ||
} | ||
} | ||
|
||
macro_rules! define_maps { | ||
(<$tcx:tt> | ||
$($(#[$attr:meta])* | ||
|
@@ -359,8 +365,10 @@ macro_rules! define_maps { | |
} | ||
|
||
// FIXME(eddyb) Get more valid Span's on queries. | ||
if span == DUMMY_SP { | ||
span = key.default_span(tcx); | ||
// def_span guard is necesary to prevent a recursive loop, | ||
// default_span calls def_span query internally. | ||
if span == DUMMY_SP && stringify!($name) != "def_span" { | ||
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. I guess this is not too bad of a workaround - could you leave a comment above as to why this is done? |
||
span = key.default_span(tcx) | ||
} | ||
|
||
let _task = tcx.dep_graph.in_task(Self::to_dep_node(&key)); | ||
|
@@ -568,7 +576,8 @@ define_maps! { <'tcx> | |
[] def_symbol_name: SymbolName(DefId) -> ty::SymbolName, | ||
[] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName, | ||
|
||
[] describe_def: meta_data_node(DefId) -> Option<Def> | ||
[] describe_def: describe_def(DefId) -> Option<Def>, | ||
[] def_span: def_span(DefId) -> Span | ||
} | ||
|
||
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> { | ||
|
@@ -601,6 +610,10 @@ fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> { | |
DepNode::ConstEval(def_id) | ||
} | ||
|
||
fn meta_data_node(def_id: DefId) -> DepNode<DefId> { | ||
DepNode::MetaData(def_id) | ||
fn describe_def(def_id: DefId) -> DepNode<DefId> { | ||
DepNode::DescribeDef(def_id) | ||
} | ||
|
||
fn def_span(def_id: DefId) -> DepNode<DefId> { | ||
DepNode::DefSpan(def_id) | ||
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. These aren't needed, because they're just a |
||
} |
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.
Heh, you can leave the comment off - the reason we need these is because
MetaData
can't be used, as it's reserved for cross-crate queries, e.g.ItemSignature(def_id)
will eventually depend on eitherHir(def_id)
iffdef_id.is_local()
orMetaData(def_id)
otherwise.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.
Ah that makes sense the title of the issue was deceiving. I assumed all of these were just about crate metadata.