Make is_intrinsic
query return the intrinsic name
This commit is contained in:
parent
de4d615e6b
commit
0eee945680
22 changed files with 38 additions and 43 deletions
|
@ -240,6 +240,7 @@ trivial! {
|
|||
Option<rustc_span::Span>,
|
||||
Option<rustc_target::spec::PanicStrategy>,
|
||||
Option<usize>,
|
||||
Option<rustc_span::Symbol>,
|
||||
Result<(), rustc_errors::ErrorGuaranteed>,
|
||||
Result<(), rustc_middle::traits::query::NoSolution>,
|
||||
Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
|
||||
|
|
|
@ -1753,8 +1753,8 @@ rustc_queries! {
|
|||
separate_provide_extern
|
||||
}
|
||||
/// Whether the function is an intrinsic
|
||||
query is_intrinsic(def_id: DefId) -> bool {
|
||||
desc { |tcx| "checking whether `{}` is an intrinsic", tcx.def_path_str(def_id) }
|
||||
query intrinsic(def_id: DefId) -> Option<Symbol> {
|
||||
desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) }
|
||||
separate_provide_extern
|
||||
}
|
||||
/// Returns the lang items defined in another crate by loading it from metadata.
|
||||
|
|
|
@ -18,7 +18,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
|||
use rustc_index::bit_set::GrowableBitSet;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::sym;
|
||||
use rustc_span::{sym, Symbol};
|
||||
use rustc_target::abi::{Integer, IntegerType, Primitive, Size};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
use smallvec::SmallVec;
|
||||
|
@ -1550,8 +1550,13 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
}
|
||||
|
||||
/// Determines whether an item is an intrinsic by Abi.
|
||||
pub fn is_intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic)
|
||||
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<Symbol> {
|
||||
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic | Abi::PlatformIntrinsic)
|
||||
{
|
||||
Some(tcx.item_name(def_id.into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
|
@ -1559,7 +1564,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
reveal_opaque_types_in_bounds,
|
||||
is_doc_hidden,
|
||||
is_doc_notable_trait,
|
||||
is_intrinsic,
|
||||
intrinsic,
|
||||
..*providers
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue