make intrinsic
query legal for any DefId
This commit is contained in:
parent
bf5fc6e5d7
commit
c04f0caaff
3 changed files with 11 additions and 11 deletions
|
@ -1051,17 +1051,15 @@ fn should_encode_mir(
|
||||||
// Coroutines require optimized MIR to compute layout.
|
// Coroutines require optimized MIR to compute layout.
|
||||||
DefKind::Closure if tcx.is_coroutine(def_id.to_def_id()) => (false, true),
|
DefKind::Closure if tcx.is_coroutine(def_id.to_def_id()) => (false, true),
|
||||||
// Full-fledged functions + closures
|
// Full-fledged functions + closures
|
||||||
def_kind @ (DefKind::AssocFn | DefKind::Fn | DefKind::Closure) => {
|
DefKind::AssocFn | DefKind::Fn | DefKind::Closure => {
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let mut opt = tcx.sess.opts.unstable_opts.always_encode_mir
|
let mut opt = tcx.sess.opts.unstable_opts.always_encode_mir
|
||||||
|| (tcx.sess.opts.output_types.should_codegen()
|
|| (tcx.sess.opts.output_types.should_codegen()
|
||||||
&& reachable_set.contains(&def_id)
|
&& reachable_set.contains(&def_id)
|
||||||
&& (generics.requires_monomorphization(tcx)
|
&& (generics.requires_monomorphization(tcx)
|
||||||
|| tcx.cross_crate_inlinable(def_id)));
|
|| tcx.cross_crate_inlinable(def_id)));
|
||||||
if matches!(def_kind, DefKind::AssocFn | DefKind::Fn) {
|
if let Some(intrinsic) = tcx.intrinsic(def_id) {
|
||||||
if let Some(intrinsic) = tcx.intrinsic(def_id) {
|
opt &= !intrinsic.must_be_overridden;
|
||||||
opt &= !intrinsic.must_be_overridden;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// The function has a `const` modifier or is in a `#[const_trait]`.
|
// The function has a `const` modifier or is in a `#[const_trait]`.
|
||||||
let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
|
let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id())
|
||||||
|
@ -1414,9 +1412,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||||
if let DefKind::Fn | DefKind::AssocFn = def_kind {
|
if let DefKind::Fn | DefKind::AssocFn = def_kind {
|
||||||
self.tables.asyncness.set_some(def_id.index, tcx.asyncness(def_id));
|
self.tables.asyncness.set_some(def_id.index, tcx.asyncness(def_id));
|
||||||
record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id));
|
record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id));
|
||||||
if let Some(name) = tcx.intrinsic(def_id) {
|
}
|
||||||
record!(self.tables.intrinsic[def_id] <- name);
|
if let Some(name) = tcx.intrinsic(def_id) {
|
||||||
}
|
record!(self.tables.intrinsic[def_id] <- name);
|
||||||
}
|
}
|
||||||
if let DefKind::TyParam = def_kind {
|
if let DefKind::TyParam = def_kind {
|
||||||
let default = self.tcx.object_lifetime_default(def_id);
|
let default = self.tcx.object_lifetime_default(def_id);
|
||||||
|
|
|
@ -1643,6 +1643,10 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||||
|
|
||||||
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute)
|
/// Determines whether an item is an intrinsic (which may be via Abi or via the `rustc_intrinsic` attribute)
|
||||||
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
|
pub fn intrinsic(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::IntrinsicDef> {
|
||||||
|
match tcx.def_kind(def_id) {
|
||||||
|
DefKind::Fn | DefKind::AssocFn => {}
|
||||||
|
_ => return None,
|
||||||
|
}
|
||||||
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|
if matches!(tcx.fn_sig(def_id).skip_binder().abi(), Abi::RustIntrinsic)
|
||||||
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
|
|| tcx.has_attr(def_id, sym::rustc_intrinsic)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
use rustc_hir::def::DefKind;
|
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
|
@ -28,8 +27,7 @@ fn resolve_instance<'tcx>(
|
||||||
tcx.normalize_erasing_regions(param_env, args),
|
tcx.normalize_erasing_regions(param_env, args),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let def = if matches!(tcx.def_kind(def_id), DefKind::Fn) && tcx.intrinsic(def_id).is_some()
|
let def = if tcx.intrinsic(def_id).is_some() {
|
||||||
{
|
|
||||||
debug!(" => intrinsic");
|
debug!(" => intrinsic");
|
||||||
ty::InstanceDef::Intrinsic(def_id)
|
ty::InstanceDef::Intrinsic(def_id)
|
||||||
} else if Some(def_id) == tcx.lang_items().drop_in_place_fn() {
|
} else if Some(def_id) == tcx.lang_items().drop_in_place_fn() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue