-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Track more crate metadata #42598
Track more crate metadata #42598
Changes from 5 commits
9f71053
532a08b
328c6c8
b0f05d4
4835698
c98ca95
e6dd869
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; | |
use hir::def::Def; | ||
use hir; | ||
use middle::const_val; | ||
use middle::cstore::{ExternCrate, LinkagePreference}; | ||
use middle::privacy::AccessLevels; | ||
use middle::region::RegionMaps; | ||
use mir; | ||
|
@@ -476,6 +477,36 @@ impl<'tcx> QueryDescription for queries::is_object_safe<'tcx> { | |
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::is_const_fn<'tcx> { | ||
fn describe(tcx: TyCtxt, def_id: DefId) -> String { | ||
format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)) | ||
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::dylib_dependency_formats<'tcx> { | ||
fn describe(_: TyCtxt, _: CrateNum) -> String { | ||
"dylib dependency formats of crate".to_string() | ||
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::is_allocator<'tcx> { | ||
fn describe(_: TyCtxt, _: CrateNum) -> String { | ||
"checking if the crate is_allocator".to_string() | ||
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::is_panic_runtime<'tcx> { | ||
fn describe(_: TyCtxt, _: CrateNum) -> String { | ||
"checking if the crate is_panic_runtime".to_string() | ||
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::extern_crate<'tcx> { | ||
fn describe(_: TyCtxt, _: CrateNum) -> String { | ||
"getting crate's ExternCrateData".to_string() | ||
} | ||
} | ||
|
||
macro_rules! define_maps { | ||
(<$tcx:tt> | ||
$($(#[$attr:meta])* | ||
|
@@ -791,6 +822,9 @@ define_maps! { <'tcx> | |
[] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>], | ||
[] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>, | ||
|
||
/// True if this is a const fn | ||
[] is_const_fn: IsConstFn(DefId) -> bool, | ||
|
||
/// True if this is a foreign item (i.e., linked via `extern { ... }`). | ||
[] is_foreign_item: IsForeignItem(DefId) -> bool, | ||
|
||
|
@@ -929,6 +963,14 @@ define_maps! { <'tcx> | |
[] needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool, | ||
[] layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) | ||
-> Result<&'tcx Layout, LayoutError<'tcx>>, | ||
|
||
[] dylib_dependency_formats: MetaDataByCrateNum(CrateNum) | ||
-> Rc<Vec<(CrateNum, LinkagePreference)>>, | ||
|
||
[] is_allocator: MetaDataByCrateNum(CrateNum) -> bool, | ||
[] is_panic_runtime: MetaDataByCrateNum(CrateNum) -> bool, | ||
|
||
[] extern_crate: MetaDataByCrateNum(CrateNum) -> Rc<Option<ExternCrate>>, | ||
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 think I'd rather all of these use 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 would think that One note: under the new dep-node system, a 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. Some of these are literally the same as querying the attributes of the crate root of some extern crate (they should also probably be replaced with an actual attribute query but that's another question), so to me they make more sense as a property of that 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. OK. I don't see it that way -- that is, I see putting the attributes on the crate root as a way of specifying properties that apply to the crate as a whole, but I have no strong opinion here. I'd be happy either way. |
||
} | ||
|
||
fn type_param_predicates((item_id, param_id): (DefId, DefId)) -> DepConstructor { | ||
|
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.
Random aside: I feel like a
GlobalTyCtxt<'a, 'tcx>
alias might be nice.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.
At that point, the
Ty
part is maybe a bit unnecessary and we should move towards a generalized idea of a "global context" (aka god object).