-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Crate metadata nondefid args #41780
Crate metadata nondefid args #41780
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; | |
use hir::def::Def; | ||
use hir; | ||
use middle::const_val; | ||
use middle::cstore::NativeLibrary; | ||
use middle::privacy::AccessLevels; | ||
use middle::region::RegionMaps; | ||
use mir; | ||
|
@@ -347,13 +348,44 @@ impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'t | |
} | ||
} | ||
|
||
impl<'tcx> QueryDescription for queries::is_mir_available<'tcx> { | ||
fn describe(tcx: TyCtxt, def_id: DefId) -> String { | ||
format!("checking if item is mir available: `{}`", | ||
tcx.item_path_str(def_id)) | ||
macro_rules! simple_query_description { | ||
($($fn_name:ident, $desc:expr),*,) => { | ||
$( | ||
impl<'tcx> QueryDescription for queries::$fn_name<'tcx> { | ||
fn describe(tcx: TyCtxt, def_id: DefId) -> String { | ||
format!(concat!($desc, "`: {}`"), | ||
tcx.item_path_str(def_id)) | ||
} | ||
} | ||
)* | ||
} | ||
} | ||
|
||
simple_query_description! { | ||
is_mir_available, "checking if item is mir available", | ||
is_const_fn, "checking if item is const fn", | ||
is_dllimport_foreign_item, "checking if item is dll import foreign item", | ||
} | ||
|
||
macro_rules! cratenum_query_description { | ||
($($fn_name:ident, $desc:expr),*,) => { | ||
$( | ||
impl<'tcx> QueryDescription for queries::$fn_name<'tcx> { | ||
fn describe(_tcx: TyCtxt, crate_num: CrateNum) -> String { | ||
format!(concat!($desc, "`: crate {}`"), crate_num) | ||
} | ||
} | ||
)* | ||
} | ||
} | ||
|
||
cratenum_query_description! { | ||
derive_registrar_fn, "getting the derive_registrar_fn", | ||
native_libraries, "getting native libraries", | ||
exported_symbols, "getting the exported symbols", | ||
is_no_builtins, "checking if is_no_builtins", | ||
} | ||
|
||
macro_rules! define_maps { | ||
(<$tcx:tt> | ||
$($(#[$attr:meta])* | ||
|
@@ -786,6 +818,15 @@ define_maps! { <'tcx> | |
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>, | ||
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool, | ||
[] is_mir_available: metadata_dep_node(DefId) -> bool, | ||
|
||
[] is_const_fn: metadata_dep_node(DefId) -> bool, | ||
[] is_default_impl: metadata_dep_node(DefId) -> bool, | ||
[] is_dllimport_foreign_item: metadata_dep_node(DefId) -> bool, | ||
|
||
[] derive_registrar_fn: cratenum_metadata_dep_node(CrateNum) -> Option<DefId>, | ||
[] native_libraries: cratenum_metadata_dep_node(CrateNum) -> Vec<NativeLibrary>, | ||
[] exported_symbols: cratenum_metadata_dep_node(CrateNum) -> Vec<DefId>, | ||
[] is_no_builtins: cratenum_metadata_dep_node(CrateNum) -> bool, | ||
} | ||
|
||
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> { | ||
|
@@ -804,6 +845,10 @@ fn metadata_dep_node(def_id: DefId) -> DepNode<DefId> { | |
DepNode::MetaData(def_id) | ||
} | ||
|
||
fn cratenum_metadata_dep_node(crate_num: CrateNum) -> DepNode<DefId> { | ||
DepNode::MetaDataByCrateNum(crate_num) | ||
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. You can just 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 don't think we should have 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. @nikomatsakis what would you suggest instead? |
||
} | ||
|
||
fn mir_shim_dep_node(instance: ty::InstanceDef) -> DepNode<DefId> { | ||
instance.dep_node() | ||
} | ||
|
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.
There's something in MIR const qualif doing this check, so that could be fully replaced by this (right now users of this query have to take into account the fact that it only works cross-crate).