Auto merge of #143582 - jieyouxu:rollup-8t9mhfj, r=jieyouxu
Rollup of 11 pull requests Successful merges: - rust-lang/rust#143130 (doc(std): clarify `NonZero<T>` usage limitation in doc comment) - rust-lang/rust#143415 (Get rid of build-powerpc64le-toolchain.sh) - rust-lang/rust#143464 (Make tests/ui/abi/debug.rs cross-compile) - rust-lang/rust#143482 (Fix short linker error output) - rust-lang/rust#143524 (Move `stable_mir` back to its own crate) - rust-lang/rust#143528 (interpret: rename StackPopCleanup) - rust-lang/rust#143551 (Dont resolve instance of root in `mir_callgraph_cyclic`) - rust-lang/rust#143558 (mbe: Refactors and function extractions in `compile_declarative_macro`) - rust-lang/rust#143563 (std: fix typo in `std::path`) - rust-lang/rust#143564 (compiler: Deduplicate `must_emit_unwind_tables()` comments) - rust-lang/rust#143577 (Disable download-rustc for library profile) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
12
Cargo.lock
12
Cargo.lock
@@ -4553,9 +4553,6 @@ dependencies = [
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5109,7 +5106,16 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
name = "stable_mir"
|
||||
version = "0.1.0-preview"
|
||||
dependencies = [
|
||||
"rustc_abi",
|
||||
"rustc_hir",
|
||||
"rustc_middle",
|
||||
"rustc_session",
|
||||
"rustc_smir",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"scoped-tls",
|
||||
"serde",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -370,22 +370,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
|
||||
};
|
||||
to_add.extend(inline_attr(cx, inline));
|
||||
|
||||
// The `uwtable` attribute according to LLVM is:
|
||||
//
|
||||
// This attribute indicates that the ABI being targeted requires that an
|
||||
// unwind table entry be produced for this function even if we can show
|
||||
// that no exceptions passes by it. This is normally the case for the
|
||||
// ELF x86-64 abi, but it can be disabled for some compilation units.
|
||||
//
|
||||
// Typically when we're compiling with `-C panic=abort` (which implies this
|
||||
// `no_landing_pads` check) we don't need `uwtable` because we can't
|
||||
// generate any exceptions! On Windows, however, exceptions include other
|
||||
// events such as illegal instructions, segfaults, etc. This means that on
|
||||
// Windows we end up still needing the `uwtable` attribute even if the `-C
|
||||
// panic=abort` flag is passed.
|
||||
//
|
||||
// You can also find more info on why Windows always requires uwtables here:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
|
||||
if cx.sess().must_emit_unwind_tables() {
|
||||
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
} else if arg.as_encoded_bytes().ends_with(b".rlib") {
|
||||
let rlib_path = Path::new(&arg);
|
||||
let dir = rlib_path.parent().unwrap();
|
||||
let filename = rlib_path.file_name().unwrap().to_owned();
|
||||
let filename = rlib_path.file_stem().unwrap().to_owned();
|
||||
if let Some(ArgGroup::Rlibs(parent, rlibs)) = args.last_mut() {
|
||||
if parent == dir {
|
||||
rlibs.push(filename);
|
||||
@@ -471,7 +471,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
args.push(ArgGroup::Regular(arg));
|
||||
}
|
||||
}
|
||||
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+\.rlib$").unwrap();
|
||||
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+").unwrap();
|
||||
self.command.args(args.into_iter().map(|arg_group| {
|
||||
match arg_group {
|
||||
// SAFETY: we are only matching on ASCII, not any surrogate pairs, so any replacements we do will still be valid.
|
||||
@@ -494,7 +494,11 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
Err(_) => false,
|
||||
};
|
||||
let mut arg = dir.into_os_string();
|
||||
arg.push("/{");
|
||||
arg.push("/");
|
||||
let needs_braces = rlibs.len() >= 2;
|
||||
if needs_braces {
|
||||
arg.push("{");
|
||||
}
|
||||
let mut first = true;
|
||||
for mut rlib in rlibs {
|
||||
if !first {
|
||||
@@ -513,7 +517,10 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
|
||||
}
|
||||
arg.push(rlib);
|
||||
}
|
||||
arg.push("}.rlib");
|
||||
if needs_braces {
|
||||
arg.push("}");
|
||||
}
|
||||
arg.push(".rlib");
|
||||
arg
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
|
||||
use crate::const_eval::CheckAlignment;
|
||||
use crate::interpret::{
|
||||
CtfeValidationMode, GlobalId, Immediate, InternKind, InternResult, InterpCx, InterpErrorKind,
|
||||
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup, create_static_alloc,
|
||||
InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, ReturnContinuation, create_static_alloc,
|
||||
intern_const_alloc_recursive, interp_ok, throw_exhaust,
|
||||
};
|
||||
use crate::{CTRL_C_RECEIVED, errors};
|
||||
@@ -76,7 +76,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
|
||||
cid.instance,
|
||||
body,
|
||||
&ret.clone().into(),
|
||||
StackPopCleanup::Root { cleanup: false },
|
||||
ReturnContinuation::Stop { cleanup: false },
|
||||
)?;
|
||||
ecx.storage_live_for_always_live_locals()?;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ use tracing::{info, instrument, trace};
|
||||
|
||||
use super::{
|
||||
CtfeProvenance, FnVal, ImmTy, InterpCx, InterpResult, MPlaceTy, Machine, OpTy, PlaceTy,
|
||||
Projectable, Provenance, ReturnAction, Scalar, StackPopCleanup, StackPopInfo, interp_ok,
|
||||
Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok,
|
||||
throw_ub, throw_ub_custom, throw_unsup_format,
|
||||
};
|
||||
use crate::fluent_generated as fluent;
|
||||
@@ -340,7 +340,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
args: &[FnArg<'tcx, M::Provenance>],
|
||||
with_caller_location: bool,
|
||||
destination: &PlaceTy<'tcx, M::Provenance>,
|
||||
mut stack_pop: StackPopCleanup,
|
||||
mut cont: ReturnContinuation,
|
||||
) -> InterpResult<'tcx> {
|
||||
// Compute callee information.
|
||||
// FIXME: for variadic support, do we have to somehow determine callee's extra_args?
|
||||
@@ -365,15 +365,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
|
||||
if !callee_fn_abi.can_unwind {
|
||||
// The callee cannot unwind, so force the `Unreachable` unwind handling.
|
||||
match &mut stack_pop {
|
||||
StackPopCleanup::Root { .. } => {}
|
||||
StackPopCleanup::Goto { unwind, .. } => {
|
||||
match &mut cont {
|
||||
ReturnContinuation::Stop { .. } => {}
|
||||
ReturnContinuation::Goto { unwind, .. } => {
|
||||
*unwind = mir::UnwindAction::Unreachable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.push_stack_frame_raw(instance, body, destination, stack_pop)?;
|
||||
self.push_stack_frame_raw(instance, body, destination, cont)?;
|
||||
|
||||
// If an error is raised here, pop the frame again to get an accurate backtrace.
|
||||
// To this end, we wrap it all in a `try` block.
|
||||
@@ -617,7 +617,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
&args,
|
||||
with_caller_location,
|
||||
destination,
|
||||
StackPopCleanup::Goto { ret: target, unwind },
|
||||
ReturnContinuation::Goto { ret: target, unwind },
|
||||
)
|
||||
}
|
||||
// `InstanceKind::Virtual` does not have callable MIR. Calls to `Virtual` instances must be
|
||||
@@ -755,8 +755,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
// Note that we are using `pop_stack_frame_raw` and not `return_from_current_stack_frame`,
|
||||
// as the latter "executes" the goto to the return block, but we don't want to,
|
||||
// only the tail called function should return to the current return block.
|
||||
let StackPopInfo { return_action, return_to_block, return_place } = self
|
||||
.pop_stack_frame_raw(false, |_this, _return_place| {
|
||||
let StackPopInfo { return_action, return_cont, return_place } =
|
||||
self.pop_stack_frame_raw(false, |_this, _return_place| {
|
||||
// This function's return value is just discarded, the tail-callee will fill in the return place instead.
|
||||
interp_ok(())
|
||||
})?;
|
||||
@@ -764,7 +764,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
assert_eq!(return_action, ReturnAction::Normal);
|
||||
|
||||
// Take the "stack pop cleanup" info, and use that to initiate the next call.
|
||||
let StackPopCleanup::Goto { ret, unwind } = return_to_block else {
|
||||
let ReturnContinuation::Goto { ret, unwind } = return_cont else {
|
||||
bug!("can't tailcall as root");
|
||||
};
|
||||
|
||||
@@ -896,23 +896,23 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
// Normal return, figure out where to jump.
|
||||
if unwinding {
|
||||
// Follow the unwind edge.
|
||||
match stack_pop_info.return_to_block {
|
||||
StackPopCleanup::Goto { unwind, .. } => {
|
||||
match stack_pop_info.return_cont {
|
||||
ReturnContinuation::Goto { unwind, .. } => {
|
||||
// This must be the very last thing that happens, since it can in fact push a new stack frame.
|
||||
self.unwind_to_block(unwind)
|
||||
}
|
||||
StackPopCleanup::Root { .. } => {
|
||||
panic!("encountered StackPopCleanup::Root when unwinding!")
|
||||
ReturnContinuation::Stop { .. } => {
|
||||
panic!("encountered ReturnContinuation::Stop when unwinding!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Follow the normal return edge.
|
||||
match stack_pop_info.return_to_block {
|
||||
StackPopCleanup::Goto { ret, .. } => self.return_to_block(ret),
|
||||
StackPopCleanup::Root { .. } => {
|
||||
match stack_pop_info.return_cont {
|
||||
ReturnContinuation::Goto { ret, .. } => self.return_to_block(ret),
|
||||
ReturnContinuation::Stop { .. } => {
|
||||
assert!(
|
||||
self.stack().is_empty(),
|
||||
"only the bottommost frame can have StackPopCleanup::Root"
|
||||
"only the bottommost frame can have ReturnContinuation::Stop"
|
||||
);
|
||||
interp_ok(())
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ pub use self::operand::{ImmTy, Immediate, OpTy};
|
||||
pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable};
|
||||
use self::place::{MemPlace, Place};
|
||||
pub use self::projection::{OffsetMode, Projectable};
|
||||
pub use self::stack::{Frame, FrameInfo, LocalState, StackPopCleanup, StackPopInfo};
|
||||
pub use self::stack::{Frame, FrameInfo, LocalState, ReturnContinuation, StackPopInfo};
|
||||
pub(crate) use self::util::create_static_alloc;
|
||||
pub use self::validity::{CtfeValidationMode, RangeSet, RefTracking};
|
||||
pub use self::visitor::ValueVisitor;
|
||||
|
||||
@@ -72,8 +72,8 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return place and locals
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Work to perform when returning from this function.
|
||||
return_to_block: StackPopCleanup,
|
||||
/// Where to continue when returning from this function.
|
||||
return_cont: ReturnContinuation,
|
||||
|
||||
/// The location where the result of the current stack frame should be written to,
|
||||
/// and its layout in the caller. This place is to be interpreted relative to the
|
||||
@@ -106,19 +106,19 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> {
|
||||
pub(super) loc: Either<mir::Location, Span>,
|
||||
}
|
||||
|
||||
/// Where and how to continue when returning/unwinding from the current function.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)] // Miri debug-prints these
|
||||
pub enum StackPopCleanup {
|
||||
pub enum ReturnContinuation {
|
||||
/// Jump to the next block in the caller, or cause UB if None (that's a function
|
||||
/// that may never return). Also store layout of return place so
|
||||
/// we can validate it at that layout.
|
||||
/// that may never return).
|
||||
/// `ret` stores the block we jump to on a normal return, while `unwind`
|
||||
/// stores the block used for cleanup during unwinding.
|
||||
Goto { ret: Option<mir::BasicBlock>, unwind: mir::UnwindAction },
|
||||
/// The root frame of the stack: nowhere else to jump to.
|
||||
/// The root frame of the stack: nowhere else to jump to, so we stop.
|
||||
/// `cleanup` says whether locals are deallocated. Static computation
|
||||
/// wants them leaked to intern what they need (and just throw away
|
||||
/// the entire `ecx` when it is done).
|
||||
Root { cleanup: bool },
|
||||
Stop { cleanup: bool },
|
||||
}
|
||||
|
||||
/// Return type of [`InterpCx::pop_stack_frame_raw`].
|
||||
@@ -127,8 +127,8 @@ pub struct StackPopInfo<'tcx, Prov: Provenance> {
|
||||
/// stack frame.
|
||||
pub return_action: ReturnAction,
|
||||
|
||||
/// [`return_to_block`](Frame::return_to_block) of the popped stack frame.
|
||||
pub return_to_block: StackPopCleanup,
|
||||
/// [`return_cont`](Frame::return_cont) of the popped stack frame.
|
||||
pub return_cont: ReturnContinuation,
|
||||
|
||||
/// [`return_place`](Frame::return_place) of the popped stack frame.
|
||||
pub return_place: PlaceTy<'tcx, Prov>,
|
||||
@@ -255,7 +255,7 @@ impl<'tcx, Prov: Provenance> Frame<'tcx, Prov> {
|
||||
Frame {
|
||||
body: self.body,
|
||||
instance: self.instance,
|
||||
return_to_block: self.return_to_block,
|
||||
return_cont: self.return_cont,
|
||||
return_place: self.return_place,
|
||||
locals: self.locals,
|
||||
loc: self.loc,
|
||||
@@ -350,20 +350,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
/// the arguments or local variables.
|
||||
///
|
||||
/// The high-level version of this is `init_stack_frame`.
|
||||
#[instrument(skip(self, body, return_place, return_to_block), level = "debug")]
|
||||
#[instrument(skip(self, body, return_place, return_cont), level = "debug")]
|
||||
pub(crate) fn push_stack_frame_raw(
|
||||
&mut self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
body: &'tcx mir::Body<'tcx>,
|
||||
return_place: &PlaceTy<'tcx, M::Provenance>,
|
||||
return_to_block: StackPopCleanup,
|
||||
return_cont: ReturnContinuation,
|
||||
) -> InterpResult<'tcx> {
|
||||
trace!("body: {:#?}", body);
|
||||
|
||||
// We can push a `Root` frame if and only if the stack is empty.
|
||||
debug_assert_eq!(
|
||||
self.stack().is_empty(),
|
||||
matches!(return_to_block, StackPopCleanup::Root { .. })
|
||||
matches!(return_cont, ReturnContinuation::Stop { .. })
|
||||
);
|
||||
|
||||
// First push a stack frame so we have access to `instantiate_from_current_frame` and other
|
||||
@@ -373,7 +373,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
let pre_frame = Frame {
|
||||
body,
|
||||
loc: Right(body.span), // Span used for errors caused during preamble.
|
||||
return_to_block,
|
||||
return_cont,
|
||||
return_place: return_place.clone(),
|
||||
locals,
|
||||
instance,
|
||||
@@ -429,15 +429,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
copy_ret_val(self, &frame.return_place)?;
|
||||
}
|
||||
|
||||
let return_to_block = frame.return_to_block;
|
||||
let return_cont = frame.return_cont;
|
||||
let return_place = frame.return_place.clone();
|
||||
|
||||
// Cleanup: deallocate locals.
|
||||
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
|
||||
// We do this while the frame is still on the stack, so errors point to the callee.
|
||||
let cleanup = match return_to_block {
|
||||
StackPopCleanup::Goto { .. } => true,
|
||||
StackPopCleanup::Root { cleanup, .. } => cleanup,
|
||||
let cleanup = match return_cont {
|
||||
ReturnContinuation::Goto { .. } => true,
|
||||
ReturnContinuation::Stop { cleanup, .. } => cleanup,
|
||||
};
|
||||
|
||||
let return_action = if cleanup {
|
||||
@@ -455,7 +455,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
ReturnAction::NoCleanup
|
||||
};
|
||||
|
||||
interp_ok(StackPopInfo { return_action, return_to_block, return_place })
|
||||
interp_ok(StackPopInfo { return_action, return_cont, return_place })
|
||||
}
|
||||
|
||||
/// In the current stack frame, mark all locals as live that are not arguments and don't have
|
||||
|
||||
@@ -373,17 +373,10 @@ pub fn compile_declarative_macro(
|
||||
node_id: NodeId,
|
||||
edition: Edition,
|
||||
) -> (SyntaxExtension, usize) {
|
||||
let is_local = node_id != DUMMY_NODE_ID;
|
||||
let mk_syn_ext = |expander| {
|
||||
SyntaxExtension::new(
|
||||
sess,
|
||||
SyntaxExtensionKind::LegacyBang(expander),
|
||||
span,
|
||||
Vec::new(),
|
||||
edition,
|
||||
ident.name,
|
||||
attrs,
|
||||
node_id != DUMMY_NODE_ID,
|
||||
)
|
||||
let kind = SyntaxExtensionKind::LegacyBang(expander);
|
||||
SyntaxExtension::new(sess, kind, span, Vec::new(), edition, ident.name, attrs, is_local)
|
||||
};
|
||||
let dummy_syn_ext = |guar| (mk_syn_ext(Arc::new(DummyExpander(guar))), 0);
|
||||
|
||||
@@ -393,7 +386,8 @@ pub fn compile_declarative_macro(
|
||||
let body = macro_def.body.tokens.clone();
|
||||
let mut p = Parser::new(&sess.psess, body, rustc_parse::MACRO_ARGUMENTS);
|
||||
|
||||
// Don't abort iteration early, so that multiple errors can be reported.
|
||||
// Don't abort iteration early, so that multiple errors can be reported. We only abort early on
|
||||
// parse failures we can't recover from.
|
||||
let mut guar = None;
|
||||
let mut check_emission = |ret: Result<(), ErrorGuaranteed>| guar = guar.or(ret.err());
|
||||
|
||||
@@ -402,20 +396,11 @@ pub fn compile_declarative_macro(
|
||||
while p.token != token::Eof {
|
||||
let lhs_tt = p.parse_token_tree();
|
||||
let lhs_tt = parse_one_tt(lhs_tt, RulePart::Pattern, sess, node_id, features, edition);
|
||||
// We don't handle errors here, the driver will abort after parsing/expansion. We can
|
||||
// report every error in every macro this way.
|
||||
check_emission(check_lhs_nt_follows(sess, node_id, &lhs_tt));
|
||||
check_emission(check_lhs_no_empty_seq(sess, slice::from_ref(&lhs_tt)));
|
||||
check_emission(check_lhs(sess, node_id, &lhs_tt));
|
||||
if let Err(e) = p.expect(exp!(FatArrow)) {
|
||||
return dummy_syn_ext(e.emit());
|
||||
}
|
||||
if p.token == token::Eof {
|
||||
let err_sp = p.token.span.shrink_to_hi();
|
||||
let guar = sess
|
||||
.dcx()
|
||||
.struct_span_err(err_sp, "macro definition ended unexpectedly")
|
||||
.with_span_label(err_sp, "expected right-hand side of macro rule")
|
||||
.emit();
|
||||
if let Some(guar) = check_no_eof(sess, &p, "expected right-hand side of macro rule") {
|
||||
return dummy_syn_ext(guar);
|
||||
}
|
||||
let rhs_tt = p.parse_token_tree();
|
||||
@@ -454,13 +439,32 @@ pub fn compile_declarative_macro(
|
||||
}
|
||||
|
||||
// Return the number of rules for unused rule linting, if this is a local macro.
|
||||
let nrules = if node_id != DUMMY_NODE_ID { rules.len() } else { 0 };
|
||||
let nrules = if is_local { rules.len() } else { 0 };
|
||||
|
||||
let expander =
|
||||
Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });
|
||||
(mk_syn_ext(expander), nrules)
|
||||
}
|
||||
|
||||
fn check_no_eof(sess: &Session, p: &Parser<'_>, msg: &'static str) -> Option<ErrorGuaranteed> {
|
||||
if p.token == token::Eof {
|
||||
let err_sp = p.token.span.shrink_to_hi();
|
||||
let guar = sess
|
||||
.dcx()
|
||||
.struct_span_err(err_sp, "macro definition ended unexpectedly")
|
||||
.with_span_label(err_sp, msg)
|
||||
.emit();
|
||||
return Some(guar);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn check_lhs(sess: &Session, node_id: NodeId, lhs: &mbe::TokenTree) -> Result<(), ErrorGuaranteed> {
|
||||
let e1 = check_lhs_nt_follows(sess, node_id, lhs);
|
||||
let e2 = check_lhs_no_empty_seq(sess, slice::from_ref(lhs));
|
||||
e1.and(e2)
|
||||
}
|
||||
|
||||
fn check_lhs_nt_follows(
|
||||
sess: &Session,
|
||||
node_id: NodeId,
|
||||
|
||||
@@ -155,15 +155,8 @@ pub(crate) fn mir_callgraph_cyclic<'tcx>(
|
||||
let recursion_limit = tcx.recursion_limit() / 2;
|
||||
let mut involved = FxHashSet::default();
|
||||
let typing_env = ty::TypingEnv::post_analysis(tcx, root);
|
||||
let Ok(Some(root_instance)) = ty::Instance::try_resolve(
|
||||
tcx,
|
||||
typing_env,
|
||||
root.to_def_id(),
|
||||
ty::GenericArgs::identity_for_item(tcx, root.to_def_id()),
|
||||
) else {
|
||||
trace!("cannot resolve, skipping");
|
||||
return involved.into();
|
||||
};
|
||||
let root_instance =
|
||||
ty::Instance::new_raw(root.to_def_id(), ty::GenericArgs::identity_for_item(tcx, root));
|
||||
if !should_recurse(tcx, root_instance) {
|
||||
trace!("cannot walk, skipping");
|
||||
return involved.into();
|
||||
|
||||
@@ -776,8 +776,15 @@ impl Session {
|
||||
|
||||
pub fn must_emit_unwind_tables(&self) -> bool {
|
||||
// This is used to control the emission of the `uwtable` attribute on
|
||||
// LLVM functions.
|
||||
// LLVM functions. The `uwtable` attribute according to LLVM is:
|
||||
//
|
||||
// This attribute indicates that the ABI being targeted requires that an
|
||||
// unwind table entry be produced for this function even if we can show
|
||||
// that no exceptions passes by it. This is normally the case for the
|
||||
// ELF x86-64 abi, but it can be disabled for some compilation units.
|
||||
//
|
||||
// Typically when we're compiling with `-C panic=abort` we don't need
|
||||
// `uwtable` because we can't generate any exceptions!
|
||||
// Unwind tables are needed when compiling with `-C panic=unwind`, but
|
||||
// LLVM won't omit unwind tables unless the function is also marked as
|
||||
// `nounwind`, so users are allowed to disable `uwtable` emission.
|
||||
|
||||
@@ -13,7 +13,4 @@ rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
scoped-tls = "1.0"
|
||||
serde = { version = "1.0.125", features = [ "derive" ] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
@@ -11,14 +11,14 @@ use rustc_middle::mir::interpret::{
|
||||
use rustc_middle::ty::{Ty, layout};
|
||||
|
||||
use super::{SmirCtxt, Tables};
|
||||
use crate::rustc_smir::bridge::Allocation as _;
|
||||
use crate::rustc_smir::{Bridge, SmirError};
|
||||
use crate::bridge::Allocation as _;
|
||||
use crate::{Bridge, SmirError};
|
||||
|
||||
pub fn create_ty_and_layout<'tcx, B: Bridge>(
|
||||
cx: &SmirCtxt<'tcx, B>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> Result<TyAndLayout<'tcx, Ty<'tcx>>, &'tcx layout::LayoutError<'tcx>> {
|
||||
use crate::rustc_smir::context::SmirTypingEnv;
|
||||
use crate::context::SmirTypingEnv;
|
||||
cx.tcx.layout_of(cx.fully_monomorphized().as_query_input(ty))
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ use rustc_span::{FileNameDisplayPreference, Span, Symbol};
|
||||
use rustc_target::callconv::FnAbi;
|
||||
|
||||
use super::{SmirAllocRange, SmirCtxt, SmirTy, SmirTypingEnv};
|
||||
use crate::rustc_smir::builder::BodyBuilder;
|
||||
use crate::rustc_smir::{Bridge, SmirError, Tables, filter_def_ids};
|
||||
use crate::builder::BodyBuilder;
|
||||
use crate::{Bridge, SmirError, Tables, filter_def_ids};
|
||||
|
||||
impl<'tcx, B: Bridge> SmirTy<'tcx> for SmirCtxt<'tcx, B> {
|
||||
fn new_foreign(&self, def_id: DefId) -> ty::Ty<'tcx> {
|
||||
@@ -426,7 +426,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
|
||||
|
||||
/// Evaluate constant as a target usize.
|
||||
pub fn eval_target_usize(&self, cnst: MirConst<'tcx>) -> Result<u64, B::Error> {
|
||||
use crate::rustc_smir::context::SmirTypingEnv;
|
||||
use crate::context::SmirTypingEnv;
|
||||
cnst.try_eval_target_usize(self.tcx, self.fully_monomorphized())
|
||||
.ok_or_else(|| B::Error::new(format!("Const `{cnst:?}` cannot be encoded as u64")))
|
||||
}
|
||||
@@ -436,10 +436,7 @@ impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> {
|
||||
.ok_or_else(|| B::Error::new(format!("Const `{cnst:?}` cannot be encoded as u64")))
|
||||
}
|
||||
|
||||
pub(crate) fn try_new_const_zst(
|
||||
&self,
|
||||
ty_internal: Ty<'tcx>,
|
||||
) -> Result<MirConst<'tcx>, B::Error> {
|
||||
pub fn try_new_const_zst(&self, ty_internal: Ty<'tcx>) -> Result<MirConst<'tcx>, B::Error> {
|
||||
let size = self
|
||||
.tcx
|
||||
.layout_of(self.fully_monomorphized().as_query_input(ty_internal))
|
||||
@@ -9,7 +9,7 @@ use rustc_middle::ty;
|
||||
use rustc_middle::ty::layout::{FnAbiOfHelpers, HasTyCtxt, HasTypingEnv, LayoutOfHelpers};
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
|
||||
use crate::rustc_smir::{Bridge, SmirError};
|
||||
use crate::{Bridge, SmirError};
|
||||
|
||||
mod impls;
|
||||
mod traits;
|
||||
@@ -18,7 +18,7 @@ pub use traits::*;
|
||||
|
||||
/// Provides direct access to rustc's internal queries.
|
||||
///
|
||||
/// The [`crate::stable_mir::compiler_interface::SmirInterface`] must go through
|
||||
/// `SmirInterface` must go through
|
||||
/// this context to obtain rustc-level information.
|
||||
pub struct SmirCtxt<'tcx, B: Bridge> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
@@ -8,31 +8,6 @@ use rustc_middle::ty;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_span::def_id::DefId;
|
||||
|
||||
pub trait SmirExistentialProjection<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
term: ty::Term<'tcx>,
|
||||
) -> ty::ExistentialProjection<'tcx>;
|
||||
}
|
||||
|
||||
pub trait SmirExistentialTraitRef<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::ExistentialTraitRef<'tcx>;
|
||||
}
|
||||
|
||||
pub trait SmirTraitRef<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx>;
|
||||
}
|
||||
|
||||
pub trait SmirTy<'tcx> {
|
||||
fn new_foreign(&self, def_id: DefId) -> Ty<'tcx>;
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
//! The WIP stable interface to rustc internals.
|
||||
//! Crate that implements what will become the rustc side of Stable MIR.
|
||||
//!
|
||||
//! This crate is responsible for building Stable MIR components from internal components.
|
||||
//!
|
||||
//! This crate is not intended to be invoked directly by users.
|
||||
//! This crate is the public API of rustc that will be invoked by the `stable_mir` crate.
|
||||
//!
|
||||
//! For more information see <https://github.com/rust-lang/project-stable-mir>
|
||||
//!
|
||||
@@ -18,8 +23,283 @@
|
||||
#![feature(sized_hierarchy)]
|
||||
// tidy-alphabetical-end
|
||||
|
||||
pub mod rustc_internal;
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::ops::Index;
|
||||
|
||||
pub mod rustc_smir;
|
||||
use bridge::*;
|
||||
use context::SmirCtxt;
|
||||
use rustc_data_structures::fx::{self, FxIndexMap};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::AllocId;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
|
||||
pub mod stable_mir;
|
||||
pub mod alloc;
|
||||
pub mod bridge;
|
||||
mod builder;
|
||||
pub mod context;
|
||||
|
||||
#[deprecated(note = "please use `stable_mir::rustc_internal` instead")]
|
||||
pub mod rustc_internal {}
|
||||
|
||||
/// A container which is used for TLS.
|
||||
pub struct SmirContainer<'tcx, B: Bridge> {
|
||||
pub tables: RefCell<Tables<'tcx, B>>,
|
||||
pub cx: RefCell<SmirCtxt<'tcx, B>>,
|
||||
}
|
||||
|
||||
pub struct Tables<'tcx, B: Bridge> {
|
||||
pub def_ids: IndexMap<DefId, B::DefId>,
|
||||
pub alloc_ids: IndexMap<AllocId, B::AllocId>,
|
||||
pub spans: IndexMap<rustc_span::Span, B::Span>,
|
||||
pub types: IndexMap<Ty<'tcx>, B::Ty>,
|
||||
pub instances: IndexMap<ty::Instance<'tcx>, B::InstanceDef>,
|
||||
pub ty_consts: IndexMap<ty::Const<'tcx>, B::TyConstId>,
|
||||
pub mir_consts: IndexMap<mir::Const<'tcx>, B::MirConstId>,
|
||||
pub layouts: IndexMap<rustc_abi::Layout<'tcx>, B::Layout>,
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Default for Tables<'tcx, B> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
def_ids: IndexMap::default(),
|
||||
alloc_ids: IndexMap::default(),
|
||||
spans: IndexMap::default(),
|
||||
types: IndexMap::default(),
|
||||
instances: IndexMap::default(),
|
||||
ty_consts: IndexMap::default(),
|
||||
mir_consts: IndexMap::default(),
|
||||
layouts: IndexMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Index<B::DefId> for Tables<'tcx, B> {
|
||||
type Output = DefId;
|
||||
|
||||
#[inline(always)]
|
||||
fn index(&self, index: B::DefId) -> &Self::Output {
|
||||
&self.def_ids[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Tables<'tcx, B> {
|
||||
pub fn intern_ty(&mut self, ty: Ty<'tcx>) -> B::Ty {
|
||||
self.types.create_or_fetch(ty)
|
||||
}
|
||||
|
||||
pub fn intern_ty_const(&mut self, ct: ty::Const<'tcx>) -> B::TyConstId {
|
||||
self.ty_consts.create_or_fetch(ct)
|
||||
}
|
||||
|
||||
pub fn intern_mir_const(&mut self, constant: mir::Const<'tcx>) -> B::MirConstId {
|
||||
self.mir_consts.create_or_fetch(constant)
|
||||
}
|
||||
|
||||
pub fn create_def_id(&mut self, did: DefId) -> B::DefId {
|
||||
self.def_ids.create_or_fetch(did)
|
||||
}
|
||||
|
||||
pub fn create_alloc_id(&mut self, aid: AllocId) -> B::AllocId {
|
||||
self.alloc_ids.create_or_fetch(aid)
|
||||
}
|
||||
|
||||
pub fn create_span(&mut self, span: Span) -> B::Span {
|
||||
self.spans.create_or_fetch(span)
|
||||
}
|
||||
|
||||
pub fn instance_def(&mut self, instance: ty::Instance<'tcx>) -> B::InstanceDef {
|
||||
self.instances.create_or_fetch(instance)
|
||||
}
|
||||
|
||||
pub fn layout_id(&mut self, layout: rustc_abi::Layout<'tcx>) -> B::Layout {
|
||||
self.layouts.create_or_fetch(layout)
|
||||
}
|
||||
|
||||
pub fn crate_item(&mut self, did: rustc_span::def_id::DefId) -> B::CrateItem {
|
||||
B::CrateItem::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn adt_def(&mut self, did: rustc_span::def_id::DefId) -> B::AdtDef {
|
||||
B::AdtDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn foreign_module_def(&mut self, did: rustc_span::def_id::DefId) -> B::ForeignModuleDef {
|
||||
B::ForeignModuleDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn foreign_def(&mut self, did: rustc_span::def_id::DefId) -> B::ForeignDef {
|
||||
B::ForeignDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn fn_def(&mut self, did: rustc_span::def_id::DefId) -> B::FnDef {
|
||||
B::FnDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn closure_def(&mut self, did: rustc_span::def_id::DefId) -> B::ClosureDef {
|
||||
B::ClosureDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_def(&mut self, did: rustc_span::def_id::DefId) -> B::CoroutineDef {
|
||||
B::CoroutineDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_closure_def(
|
||||
&mut self,
|
||||
did: rustc_span::def_id::DefId,
|
||||
) -> B::CoroutineClosureDef {
|
||||
B::CoroutineClosureDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn alias_def(&mut self, did: rustc_span::def_id::DefId) -> B::AliasDef {
|
||||
B::AliasDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn param_def(&mut self, did: rustc_span::def_id::DefId) -> B::ParamDef {
|
||||
B::ParamDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn br_named_def(&mut self, did: rustc_span::def_id::DefId) -> B::BrNamedDef {
|
||||
B::BrNamedDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn trait_def(&mut self, did: rustc_span::def_id::DefId) -> B::TraitDef {
|
||||
B::TraitDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn generic_def(&mut self, did: rustc_span::def_id::DefId) -> B::GenericDef {
|
||||
B::GenericDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn const_def(&mut self, did: rustc_span::def_id::DefId) -> B::ConstDef {
|
||||
B::ConstDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn impl_def(&mut self, did: rustc_span::def_id::DefId) -> B::ImplDef {
|
||||
B::ImplDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn region_def(&mut self, did: rustc_span::def_id::DefId) -> B::RegionDef {
|
||||
B::RegionDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_witness_def(
|
||||
&mut self,
|
||||
did: rustc_span::def_id::DefId,
|
||||
) -> B::CoroutineWitnessDef {
|
||||
B::CoroutineWitnessDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn assoc_def(&mut self, did: rustc_span::def_id::DefId) -> B::AssocDef {
|
||||
B::AssocDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn opaque_def(&mut self, did: rustc_span::def_id::DefId) -> B::OpaqueDef {
|
||||
B::OpaqueDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn prov(&mut self, aid: rustc_middle::mir::interpret::AllocId) -> B::Prov {
|
||||
B::Prov::new(self.create_alloc_id(aid))
|
||||
}
|
||||
|
||||
pub fn static_def(&mut self, did: rustc_span::def_id::DefId) -> B::StaticDef {
|
||||
B::StaticDef::new(self.create_def_id(did))
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait defining types that are used to emulate StableMIR components, which is really
|
||||
/// useful when programming in stable_mir-agnostic settings.
|
||||
pub trait Bridge: Sized {
|
||||
type DefId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type AllocId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Span: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Ty: Copy + Debug + PartialEq + IndexedVal;
|
||||
type InstanceDef: Copy + Debug + PartialEq + IndexedVal;
|
||||
type TyConstId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type MirConstId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Layout: Copy + Debug + PartialEq + IndexedVal;
|
||||
|
||||
type Error: SmirError;
|
||||
type CrateItem: CrateItem<Self>;
|
||||
type AdtDef: AdtDef<Self>;
|
||||
type ForeignModuleDef: ForeignModuleDef<Self>;
|
||||
type ForeignDef: ForeignDef<Self>;
|
||||
type FnDef: FnDef<Self>;
|
||||
type ClosureDef: ClosureDef<Self>;
|
||||
type CoroutineDef: CoroutineDef<Self>;
|
||||
type CoroutineClosureDef: CoroutineClosureDef<Self>;
|
||||
type AliasDef: AliasDef<Self>;
|
||||
type ParamDef: ParamDef<Self>;
|
||||
type BrNamedDef: BrNamedDef<Self>;
|
||||
type TraitDef: TraitDef<Self>;
|
||||
type GenericDef: GenericDef<Self>;
|
||||
type ConstDef: ConstDef<Self>;
|
||||
type ImplDef: ImplDef<Self>;
|
||||
type RegionDef: RegionDef<Self>;
|
||||
type CoroutineWitnessDef: CoroutineWitnessDef<Self>;
|
||||
type AssocDef: AssocDef<Self>;
|
||||
type OpaqueDef: OpaqueDef<Self>;
|
||||
type Prov: Prov<Self>;
|
||||
type StaticDef: StaticDef<Self>;
|
||||
|
||||
type Allocation: Allocation<Self>;
|
||||
}
|
||||
|
||||
pub trait IndexedVal {
|
||||
fn to_val(index: usize) -> Self;
|
||||
|
||||
fn to_index(&self) -> usize;
|
||||
}
|
||||
|
||||
/// Similar to rustc's `FxIndexMap`, `IndexMap` with extra
|
||||
/// safety features added.
|
||||
pub struct IndexMap<K, V> {
|
||||
index_map: fx::FxIndexMap<K, V>,
|
||||
}
|
||||
|
||||
impl<K, V> Default for IndexMap<K, V> {
|
||||
fn default() -> Self {
|
||||
Self { index_map: FxIndexMap::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> IndexMap<K, V> {
|
||||
pub fn create_or_fetch(&mut self, key: K) -> V {
|
||||
let len = self.index_map.len();
|
||||
let v = self.index_map.entry(key).or_insert(V::to_val(len));
|
||||
*v
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> Index<V>
|
||||
for IndexMap<K, V>
|
||||
{
|
||||
type Output = K;
|
||||
|
||||
fn index(&self, index: V) -> &Self::Output {
|
||||
let (k, v) = self.index_map.get_index(index.to_index()).unwrap();
|
||||
assert_eq!(*v, index, "Provided value doesn't match with indexed value");
|
||||
k
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate over the definitions of the given crate.
|
||||
pub(crate) fn filter_def_ids<F, T>(tcx: TyCtxt<'_>, krate: CrateNum, mut func: F) -> Vec<T>
|
||||
where
|
||||
F: FnMut(DefId) -> Option<T>,
|
||||
{
|
||||
if krate == LOCAL_CRATE {
|
||||
tcx.iter_local_def_id().filter_map(|did| func(did.to_def_id())).collect()
|
||||
} else {
|
||||
let num_definitions = tcx.num_extern_def_ids(krate);
|
||||
(0..num_definitions)
|
||||
.filter_map(move |i| {
|
||||
let def_id = DefId { krate, index: rustc_span::def_id::DefIndex::from_usize(i) };
|
||||
func(def_id)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,286 +0,0 @@
|
||||
//! Module that implements what will become the rustc side of Stable MIR.
|
||||
|
||||
//! This module is responsible for building Stable MIR components from internal components.
|
||||
//!
|
||||
//! This module is not intended to be invoked directly by users. It will eventually
|
||||
//! become the public API of rustc that will be invoked by the `stable_mir` crate.
|
||||
//!
|
||||
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::ops::Index;
|
||||
|
||||
use bridge::*;
|
||||
use context::SmirCtxt;
|
||||
use rustc_data_structures::fx::{self, FxIndexMap};
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::AllocId;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
|
||||
pub mod alloc;
|
||||
pub mod bridge;
|
||||
mod builder;
|
||||
pub mod context;
|
||||
|
||||
/// A container which is used for TLS.
|
||||
pub struct SmirContainer<'tcx, B: Bridge> {
|
||||
pub tables: RefCell<Tables<'tcx, B>>,
|
||||
pub cx: RefCell<SmirCtxt<'tcx, B>>,
|
||||
}
|
||||
|
||||
pub struct Tables<'tcx, B: Bridge> {
|
||||
pub def_ids: IndexMap<DefId, B::DefId>,
|
||||
pub alloc_ids: IndexMap<AllocId, B::AllocId>,
|
||||
pub spans: IndexMap<rustc_span::Span, B::Span>,
|
||||
pub types: IndexMap<Ty<'tcx>, B::Ty>,
|
||||
pub instances: IndexMap<ty::Instance<'tcx>, B::InstanceDef>,
|
||||
pub ty_consts: IndexMap<ty::Const<'tcx>, B::TyConstId>,
|
||||
pub mir_consts: IndexMap<mir::Const<'tcx>, B::MirConstId>,
|
||||
pub layouts: IndexMap<rustc_abi::Layout<'tcx>, B::Layout>,
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Default for Tables<'tcx, B> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
def_ids: IndexMap::default(),
|
||||
alloc_ids: IndexMap::default(),
|
||||
spans: IndexMap::default(),
|
||||
types: IndexMap::default(),
|
||||
instances: IndexMap::default(),
|
||||
ty_consts: IndexMap::default(),
|
||||
mir_consts: IndexMap::default(),
|
||||
layouts: IndexMap::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Index<B::DefId> for Tables<'tcx, B> {
|
||||
type Output = DefId;
|
||||
|
||||
#[inline(always)]
|
||||
fn index(&self, index: B::DefId) -> &Self::Output {
|
||||
&self.def_ids[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, B: Bridge> Tables<'tcx, B> {
|
||||
pub fn intern_ty(&mut self, ty: Ty<'tcx>) -> B::Ty {
|
||||
self.types.create_or_fetch(ty)
|
||||
}
|
||||
|
||||
pub fn intern_ty_const(&mut self, ct: ty::Const<'tcx>) -> B::TyConstId {
|
||||
self.ty_consts.create_or_fetch(ct)
|
||||
}
|
||||
|
||||
pub fn intern_mir_const(&mut self, constant: mir::Const<'tcx>) -> B::MirConstId {
|
||||
self.mir_consts.create_or_fetch(constant)
|
||||
}
|
||||
|
||||
pub fn create_def_id(&mut self, did: DefId) -> B::DefId {
|
||||
self.def_ids.create_or_fetch(did)
|
||||
}
|
||||
|
||||
pub fn create_alloc_id(&mut self, aid: AllocId) -> B::AllocId {
|
||||
self.alloc_ids.create_or_fetch(aid)
|
||||
}
|
||||
|
||||
pub fn create_span(&mut self, span: Span) -> B::Span {
|
||||
self.spans.create_or_fetch(span)
|
||||
}
|
||||
|
||||
pub fn instance_def(&mut self, instance: ty::Instance<'tcx>) -> B::InstanceDef {
|
||||
self.instances.create_or_fetch(instance)
|
||||
}
|
||||
|
||||
pub fn layout_id(&mut self, layout: rustc_abi::Layout<'tcx>) -> B::Layout {
|
||||
self.layouts.create_or_fetch(layout)
|
||||
}
|
||||
|
||||
pub fn crate_item(&mut self, did: rustc_span::def_id::DefId) -> B::CrateItem {
|
||||
B::CrateItem::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn adt_def(&mut self, did: rustc_span::def_id::DefId) -> B::AdtDef {
|
||||
B::AdtDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn foreign_module_def(&mut self, did: rustc_span::def_id::DefId) -> B::ForeignModuleDef {
|
||||
B::ForeignModuleDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn foreign_def(&mut self, did: rustc_span::def_id::DefId) -> B::ForeignDef {
|
||||
B::ForeignDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn fn_def(&mut self, did: rustc_span::def_id::DefId) -> B::FnDef {
|
||||
B::FnDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn closure_def(&mut self, did: rustc_span::def_id::DefId) -> B::ClosureDef {
|
||||
B::ClosureDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_def(&mut self, did: rustc_span::def_id::DefId) -> B::CoroutineDef {
|
||||
B::CoroutineDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_closure_def(
|
||||
&mut self,
|
||||
did: rustc_span::def_id::DefId,
|
||||
) -> B::CoroutineClosureDef {
|
||||
B::CoroutineClosureDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn alias_def(&mut self, did: rustc_span::def_id::DefId) -> B::AliasDef {
|
||||
B::AliasDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn param_def(&mut self, did: rustc_span::def_id::DefId) -> B::ParamDef {
|
||||
B::ParamDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn br_named_def(&mut self, did: rustc_span::def_id::DefId) -> B::BrNamedDef {
|
||||
B::BrNamedDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn trait_def(&mut self, did: rustc_span::def_id::DefId) -> B::TraitDef {
|
||||
B::TraitDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn generic_def(&mut self, did: rustc_span::def_id::DefId) -> B::GenericDef {
|
||||
B::GenericDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn const_def(&mut self, did: rustc_span::def_id::DefId) -> B::ConstDef {
|
||||
B::ConstDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn impl_def(&mut self, did: rustc_span::def_id::DefId) -> B::ImplDef {
|
||||
B::ImplDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn region_def(&mut self, did: rustc_span::def_id::DefId) -> B::RegionDef {
|
||||
B::RegionDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn coroutine_witness_def(
|
||||
&mut self,
|
||||
did: rustc_span::def_id::DefId,
|
||||
) -> B::CoroutineWitnessDef {
|
||||
B::CoroutineWitnessDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn assoc_def(&mut self, did: rustc_span::def_id::DefId) -> B::AssocDef {
|
||||
B::AssocDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn opaque_def(&mut self, did: rustc_span::def_id::DefId) -> B::OpaqueDef {
|
||||
B::OpaqueDef::new(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn prov(&mut self, aid: rustc_middle::mir::interpret::AllocId) -> B::Prov {
|
||||
B::Prov::new(self.create_alloc_id(aid))
|
||||
}
|
||||
|
||||
pub fn static_def(&mut self, did: rustc_span::def_id::DefId) -> B::StaticDef {
|
||||
B::StaticDef::new(self.create_def_id(did))
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait defining types that are used to emulate StableMIR components, which is really
|
||||
/// useful when programming in stable_mir-agnostic settings.
|
||||
pub trait Bridge: Sized {
|
||||
type DefId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type AllocId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Span: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Ty: Copy + Debug + PartialEq + IndexedVal;
|
||||
type InstanceDef: Copy + Debug + PartialEq + IndexedVal;
|
||||
type TyConstId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type MirConstId: Copy + Debug + PartialEq + IndexedVal;
|
||||
type Layout: Copy + Debug + PartialEq + IndexedVal;
|
||||
|
||||
type Error: SmirError;
|
||||
type CrateItem: CrateItem<Self>;
|
||||
type AdtDef: AdtDef<Self>;
|
||||
type ForeignModuleDef: ForeignModuleDef<Self>;
|
||||
type ForeignDef: ForeignDef<Self>;
|
||||
type FnDef: FnDef<Self>;
|
||||
type ClosureDef: ClosureDef<Self>;
|
||||
type CoroutineDef: CoroutineDef<Self>;
|
||||
type CoroutineClosureDef: CoroutineClosureDef<Self>;
|
||||
type AliasDef: AliasDef<Self>;
|
||||
type ParamDef: ParamDef<Self>;
|
||||
type BrNamedDef: BrNamedDef<Self>;
|
||||
type TraitDef: TraitDef<Self>;
|
||||
type GenericDef: GenericDef<Self>;
|
||||
type ConstDef: ConstDef<Self>;
|
||||
type ImplDef: ImplDef<Self>;
|
||||
type RegionDef: RegionDef<Self>;
|
||||
type CoroutineWitnessDef: CoroutineWitnessDef<Self>;
|
||||
type AssocDef: AssocDef<Self>;
|
||||
type OpaqueDef: OpaqueDef<Self>;
|
||||
type Prov: Prov<Self>;
|
||||
type StaticDef: StaticDef<Self>;
|
||||
|
||||
type Allocation: Allocation<Self>;
|
||||
}
|
||||
|
||||
pub trait IndexedVal {
|
||||
fn to_val(index: usize) -> Self;
|
||||
|
||||
fn to_index(&self) -> usize;
|
||||
}
|
||||
|
||||
/// Similar to rustc's `FxIndexMap`, `IndexMap` with extra
|
||||
/// safety features added.
|
||||
pub struct IndexMap<K, V> {
|
||||
index_map: fx::FxIndexMap<K, V>,
|
||||
}
|
||||
|
||||
impl<K, V> Default for IndexMap<K, V> {
|
||||
fn default() -> Self {
|
||||
Self { index_map: FxIndexMap::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> IndexMap<K, V> {
|
||||
pub fn create_or_fetch(&mut self, key: K) -> V {
|
||||
let len = self.index_map.len();
|
||||
let v = self.index_map.entry(key).or_insert(V::to_val(len));
|
||||
*v
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> Index<V>
|
||||
for IndexMap<K, V>
|
||||
{
|
||||
type Output = K;
|
||||
|
||||
fn index(&self, index: V) -> &Self::Output {
|
||||
let (k, v) = self.index_map.get_index(index.to_index()).unwrap();
|
||||
assert_eq!(*v, index, "Provided value doesn't match with indexed value");
|
||||
k
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate over the definitions of the given crate.
|
||||
pub(crate) fn filter_def_ids<F, T>(tcx: TyCtxt<'_>, krate: CrateNum, mut func: F) -> Vec<T>
|
||||
where
|
||||
F: FnMut(DefId) -> Option<T>,
|
||||
{
|
||||
if krate == LOCAL_CRATE {
|
||||
tcx.iter_local_def_id().filter_map(|did| func(did.to_def_id())).collect()
|
||||
} else {
|
||||
let num_definitions = tcx.num_extern_def_ids(krate);
|
||||
(0..num_definitions)
|
||||
.filter_map(move |i| {
|
||||
let def_id = DefId { krate, index: rustc_span::def_id::DefIndex::from_usize(i) };
|
||||
func(def_id)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -1,304 +0,0 @@
|
||||
//! Module that is temporarily parasitic on the `rustc_smir` crate,
|
||||
//!
|
||||
//! This module is designed to resolve circular dependency that would happen
|
||||
//! if we gradually invert the dependency order between `rustc_smir` and `stable_mir`.
|
||||
//!
|
||||
//! Once refactoring is complete, we will migrate it back to the `stable_mir` crate.
|
||||
|
||||
//! The WIP stable interface to rustc internals.
|
||||
//!
|
||||
//! For more information see <https://github.com/rust-lang/project-stable-mir>
|
||||
//!
|
||||
//! # Note
|
||||
//!
|
||||
//! This API is still completely unstable and subject to change.
|
||||
|
||||
// #![doc(
|
||||
// html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
// test(attr(allow(unused_variables), deny(warnings)))
|
||||
// )]
|
||||
//!
|
||||
//! This crate shall contain all type definitions and APIs that we expect third-party tools to invoke to
|
||||
//! interact with the compiler.
|
||||
//!
|
||||
//! The goal is to eventually be published on
|
||||
//! [crates.io](https://crates.io).
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::{fmt, io};
|
||||
|
||||
pub(crate) use rustc_smir::IndexedVal;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use serde::Serialize;
|
||||
use stable_mir::compiler_interface::with;
|
||||
pub use stable_mir::crate_def::{CrateDef, CrateDefItems, CrateDefType, DefId};
|
||||
pub use stable_mir::error::*;
|
||||
use stable_mir::mir::mono::StaticDef;
|
||||
use stable_mir::mir::{Body, Mutability};
|
||||
use stable_mir::ty::{
|
||||
AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty,
|
||||
};
|
||||
use stable_mir::unstable::Stable;
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
|
||||
pub mod abi;
|
||||
mod alloc;
|
||||
pub(crate) mod unstable;
|
||||
#[macro_use]
|
||||
pub mod crate_def;
|
||||
pub mod compiler_interface;
|
||||
#[macro_use]
|
||||
pub mod error;
|
||||
pub mod mir;
|
||||
pub mod target;
|
||||
pub mod ty;
|
||||
pub mod visitor;
|
||||
|
||||
/// Use String for now but we should replace it.
|
||||
pub type Symbol = String;
|
||||
|
||||
/// The number that identifies a crate.
|
||||
pub type CrateNum = usize;
|
||||
|
||||
impl Debug for DefId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexedVal for DefId {
|
||||
fn to_val(index: usize) -> Self {
|
||||
DefId(index)
|
||||
}
|
||||
|
||||
fn to_index(&self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// A list of crate items.
|
||||
pub type CrateItems = Vec<CrateItem>;
|
||||
|
||||
/// A list of trait decls.
|
||||
pub type TraitDecls = Vec<TraitDef>;
|
||||
|
||||
/// A list of impl trait decls.
|
||||
pub type ImplTraitDecls = Vec<ImplDef>;
|
||||
|
||||
/// A list of associated items.
|
||||
pub type AssocItems = Vec<AssocItem>;
|
||||
|
||||
/// Holds information about a crate.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize)]
|
||||
pub struct Crate {
|
||||
pub id: CrateNum,
|
||||
pub name: Symbol,
|
||||
pub is_local: bool,
|
||||
}
|
||||
|
||||
impl Crate {
|
||||
/// The list of foreign modules in this crate.
|
||||
pub fn foreign_modules(&self) -> Vec<ForeignModuleDef> {
|
||||
with(|cx| cx.foreign_modules(self.id))
|
||||
}
|
||||
|
||||
/// The list of traits declared in this crate.
|
||||
pub fn trait_decls(&self) -> TraitDecls {
|
||||
with(|cx| cx.trait_decls(self.id))
|
||||
}
|
||||
|
||||
/// The list of trait implementations in this crate.
|
||||
pub fn trait_impls(&self) -> ImplTraitDecls {
|
||||
with(|cx| cx.trait_impls(self.id))
|
||||
}
|
||||
|
||||
/// Return a list of function definitions from this crate independent on their visibility.
|
||||
pub fn fn_defs(&self) -> Vec<FnDef> {
|
||||
with(|cx| cx.crate_functions(self.id))
|
||||
}
|
||||
|
||||
/// Return a list of static items defined in this crate independent on their visibility.
|
||||
pub fn statics(&self) -> Vec<StaticDef> {
|
||||
with(|cx| cx.crate_statics(self.id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Serialize)]
|
||||
pub enum ItemKind {
|
||||
Fn,
|
||||
Static,
|
||||
Const,
|
||||
Ctor(CtorKind),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Serialize)]
|
||||
pub enum CtorKind {
|
||||
Const,
|
||||
Fn,
|
||||
}
|
||||
|
||||
pub type Filename = String;
|
||||
|
||||
crate_def_with_ty! {
|
||||
/// Holds information about an item in a crate.
|
||||
#[derive(Serialize)]
|
||||
pub CrateItem;
|
||||
}
|
||||
|
||||
impl CrateItem {
|
||||
/// This will return the body of an item or panic if it's not available.
|
||||
pub fn expect_body(&self) -> mir::Body {
|
||||
with(|cx| cx.mir_body(self.0))
|
||||
}
|
||||
|
||||
/// Return the body of an item if available.
|
||||
pub fn body(&self) -> Option<mir::Body> {
|
||||
with(|cx| cx.has_body(self.0).then(|| cx.mir_body(self.0)))
|
||||
}
|
||||
|
||||
/// Check if a body is available for this item.
|
||||
pub fn has_body(&self) -> bool {
|
||||
with(|cx| cx.has_body(self.0))
|
||||
}
|
||||
|
||||
pub fn span(&self) -> Span {
|
||||
with(|cx| cx.span_of_an_item(self.0))
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> ItemKind {
|
||||
with(|cx| cx.item_kind(*self))
|
||||
}
|
||||
|
||||
pub fn requires_monomorphization(&self) -> bool {
|
||||
with(|cx| cx.requires_monomorphization(self.0))
|
||||
}
|
||||
|
||||
pub fn ty(&self) -> Ty {
|
||||
with(|cx| cx.def_ty(self.0))
|
||||
}
|
||||
|
||||
pub fn is_foreign_item(&self) -> bool {
|
||||
with(|cx| cx.is_foreign_item(self.0))
|
||||
}
|
||||
|
||||
/// Emit MIR for this item body.
|
||||
pub fn emit_mir<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
self.body()
|
||||
.ok_or_else(|| io::Error::other(format!("No body found for `{}`", self.name())))?
|
||||
.dump(w, &self.name())
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the function where execution starts if the current
|
||||
/// crate defines that. This is usually `main`, but could be
|
||||
/// `start` if the crate is a no-std crate.
|
||||
pub fn entry_fn() -> Option<CrateItem> {
|
||||
with(|cx| cx.entry_fn())
|
||||
}
|
||||
|
||||
/// Access to the local crate.
|
||||
pub fn local_crate() -> Crate {
|
||||
with(|cx| cx.local_crate())
|
||||
}
|
||||
|
||||
/// Try to find a crate or crates if multiple crates exist from given name.
|
||||
pub fn find_crates(name: &str) -> Vec<Crate> {
|
||||
with(|cx| cx.find_crates(name))
|
||||
}
|
||||
|
||||
/// Try to find a crate with the given name.
|
||||
pub fn external_crates() -> Vec<Crate> {
|
||||
with(|cx| cx.external_crates())
|
||||
}
|
||||
|
||||
/// Retrieve all items in the local crate that have a MIR associated with them.
|
||||
pub fn all_local_items() -> CrateItems {
|
||||
with(|cx| cx.all_local_items())
|
||||
}
|
||||
|
||||
pub fn all_trait_decls() -> TraitDecls {
|
||||
with(|cx| cx.all_trait_decls())
|
||||
}
|
||||
|
||||
pub fn all_trait_impls() -> ImplTraitDecls {
|
||||
with(|cx| cx.all_trait_impls())
|
||||
}
|
||||
|
||||
/// A type that provides internal information but that can still be used for debug purpose.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Serialize)]
|
||||
pub struct Opaque(String);
|
||||
|
||||
impl std::fmt::Display for Opaque {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Opaque {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn opaque<T: Debug>(value: &T) -> Opaque {
|
||||
Opaque(format!("{value:?}"))
|
||||
}
|
||||
|
||||
macro_rules! bridge_impl {
|
||||
($name: ident, $ty: ty) => {
|
||||
impl rustc_smir::bridge::$name<compiler_interface::BridgeTys> for $ty {
|
||||
fn new(def: stable_mir::DefId) -> Self {
|
||||
Self(def)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bridge_impl!(CrateItem, stable_mir::CrateItem);
|
||||
bridge_impl!(AdtDef, stable_mir::ty::AdtDef);
|
||||
bridge_impl!(ForeignModuleDef, stable_mir::ty::ForeignModuleDef);
|
||||
bridge_impl!(ForeignDef, stable_mir::ty::ForeignDef);
|
||||
bridge_impl!(FnDef, stable_mir::ty::FnDef);
|
||||
bridge_impl!(ClosureDef, stable_mir::ty::ClosureDef);
|
||||
bridge_impl!(CoroutineDef, stable_mir::ty::CoroutineDef);
|
||||
bridge_impl!(CoroutineClosureDef, stable_mir::ty::CoroutineClosureDef);
|
||||
bridge_impl!(AliasDef, stable_mir::ty::AliasDef);
|
||||
bridge_impl!(ParamDef, stable_mir::ty::ParamDef);
|
||||
bridge_impl!(BrNamedDef, stable_mir::ty::BrNamedDef);
|
||||
bridge_impl!(TraitDef, stable_mir::ty::TraitDef);
|
||||
bridge_impl!(GenericDef, stable_mir::ty::GenericDef);
|
||||
bridge_impl!(ConstDef, stable_mir::ty::ConstDef);
|
||||
bridge_impl!(ImplDef, stable_mir::ty::ImplDef);
|
||||
bridge_impl!(RegionDef, stable_mir::ty::RegionDef);
|
||||
bridge_impl!(CoroutineWitnessDef, stable_mir::ty::CoroutineWitnessDef);
|
||||
bridge_impl!(AssocDef, stable_mir::ty::AssocDef);
|
||||
bridge_impl!(OpaqueDef, stable_mir::ty::OpaqueDef);
|
||||
bridge_impl!(StaticDef, stable_mir::mir::mono::StaticDef);
|
||||
|
||||
impl rustc_smir::bridge::Prov<compiler_interface::BridgeTys> for stable_mir::ty::Prov {
|
||||
fn new(aid: stable_mir::mir::alloc::AllocId) -> Self {
|
||||
Self(aid)
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_smir::bridge::Allocation<compiler_interface::BridgeTys> for stable_mir::ty::Allocation {
|
||||
fn new<'tcx>(
|
||||
bytes: Vec<Option<u8>>,
|
||||
ptrs: Vec<(usize, rustc_middle::mir::interpret::AllocId)>,
|
||||
align: u64,
|
||||
mutability: rustc_middle::mir::Mutability,
|
||||
tables: &mut Tables<'tcx, compiler_interface::BridgeTys>,
|
||||
cx: &SmirCtxt<'tcx, compiler_interface::BridgeTys>,
|
||||
) -> Self {
|
||||
Self {
|
||||
bytes,
|
||||
provenance: ProvenanceMap {
|
||||
ptrs: ptrs.iter().map(|(i, aid)| (*i, tables.prov(*aid))).collect(),
|
||||
},
|
||||
align,
|
||||
mutability: mutability.stable(tables, cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,18 @@ version = "0.1.0-preview"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
rustc_abi = { path = "../rustc_abi" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_smir = { path = "../rustc_smir" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
scoped-tls = "1.0"
|
||||
serde = { version = "1.0.125", features = [ "derive" ] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[features]
|
||||
# Provides access to APIs that expose internals of the rust compiler.
|
||||
|
||||
@@ -3,13 +3,12 @@ use std::num::NonZero;
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::compiler_interface::with;
|
||||
use stable_mir::mir::FieldIdx;
|
||||
use stable_mir::target::{MachineInfo, MachineSize as Size};
|
||||
use stable_mir::ty::{Align, Ty, VariantIdx};
|
||||
use stable_mir::{Error, Opaque, error};
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::compiler_interface::with;
|
||||
use crate::mir::FieldIdx;
|
||||
use crate::target::{MachineInfo, MachineSize as Size};
|
||||
use crate::ty::{Align, Ty, VariantIdx};
|
||||
use crate::{Error, Opaque, error};
|
||||
|
||||
/// A function ABI definition.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
|
||||
@@ -119,7 +118,7 @@ impl Layout {
|
||||
}
|
||||
}
|
||||
|
||||
impl stable_mir::IndexedVal for Layout {
|
||||
impl crate::IndexedVal for Layout {
|
||||
fn to_val(index: usize) -> Self {
|
||||
Layout(index)
|
||||
}
|
||||
@@ -16,7 +16,6 @@ use super::compiler_interface::BridgeTys;
|
||||
use super::mir::Mutability;
|
||||
use super::ty::{Allocation, ProvenanceMap};
|
||||
use super::unstable::Stable;
|
||||
use crate::rustc_smir;
|
||||
|
||||
/// Creates new empty `Allocation` from given `Align`.
|
||||
fn new_empty_allocation(align: Align) -> Allocation {
|
||||
@@ -8,68 +8,67 @@ use std::cell::Cell;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_smir::{Bridge, SmirContainer};
|
||||
use stable_mir::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
|
||||
use stable_mir::crate_def::Attribute;
|
||||
use stable_mir::mir::alloc::{AllocId, GlobalAlloc};
|
||||
use stable_mir::mir::mono::{Instance, InstanceDef, StaticDef};
|
||||
use stable_mir::mir::{BinOp, Body, Place, UnOp};
|
||||
use stable_mir::target::{MachineInfo, MachineSize};
|
||||
use stable_mir::ty::{
|
||||
use tracing::debug;
|
||||
|
||||
use crate::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
|
||||
use crate::crate_def::Attribute;
|
||||
use crate::mir::alloc::{AllocId, GlobalAlloc};
|
||||
use crate::mir::mono::{Instance, InstanceDef, StaticDef};
|
||||
use crate::mir::{BinOp, Body, Place, UnOp};
|
||||
use crate::target::{MachineInfo, MachineSize};
|
||||
use crate::ty::{
|
||||
AdtDef, AdtKind, Allocation, ClosureDef, ClosureKind, CoroutineDef, Discr, FieldDef, FnDef,
|
||||
ForeignDef, ForeignItemKind, ForeignModule, ForeignModuleDef, GenericArgs, GenericPredicates,
|
||||
Generics, ImplDef, ImplTrait, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span,
|
||||
TraitDecl, TraitDef, Ty, TyConst, TyConstId, TyKind, UintTy, VariantDef, VariantIdx,
|
||||
};
|
||||
use stable_mir::unstable::{RustcInternal, Stable, new_item_kind};
|
||||
use stable_mir::{
|
||||
use crate::unstable::{RustcInternal, Stable, new_item_kind};
|
||||
use crate::{
|
||||
AssocItems, Crate, CrateDef, CrateItem, CrateItems, CrateNum, DefId, Error, Filename,
|
||||
ImplTraitDecls, ItemKind, Symbol, TraitDecls, alloc, mir,
|
||||
};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
|
||||
pub struct BridgeTys;
|
||||
|
||||
impl Bridge for BridgeTys {
|
||||
type DefId = stable_mir::DefId;
|
||||
type AllocId = stable_mir::mir::alloc::AllocId;
|
||||
type Span = stable_mir::ty::Span;
|
||||
type Ty = stable_mir::ty::Ty;
|
||||
type InstanceDef = stable_mir::mir::mono::InstanceDef;
|
||||
type TyConstId = stable_mir::ty::TyConstId;
|
||||
type MirConstId = stable_mir::ty::MirConstId;
|
||||
type Layout = stable_mir::abi::Layout;
|
||||
type DefId = crate::DefId;
|
||||
type AllocId = crate::mir::alloc::AllocId;
|
||||
type Span = crate::ty::Span;
|
||||
type Ty = crate::ty::Ty;
|
||||
type InstanceDef = crate::mir::mono::InstanceDef;
|
||||
type TyConstId = crate::ty::TyConstId;
|
||||
type MirConstId = crate::ty::MirConstId;
|
||||
type Layout = crate::abi::Layout;
|
||||
|
||||
type Error = stable_mir::Error;
|
||||
type CrateItem = stable_mir::CrateItem;
|
||||
type AdtDef = stable_mir::ty::AdtDef;
|
||||
type ForeignModuleDef = stable_mir::ty::ForeignModuleDef;
|
||||
type ForeignDef = stable_mir::ty::ForeignDef;
|
||||
type FnDef = stable_mir::ty::FnDef;
|
||||
type ClosureDef = stable_mir::ty::ClosureDef;
|
||||
type CoroutineDef = stable_mir::ty::CoroutineDef;
|
||||
type CoroutineClosureDef = stable_mir::ty::CoroutineClosureDef;
|
||||
type AliasDef = stable_mir::ty::AliasDef;
|
||||
type ParamDef = stable_mir::ty::ParamDef;
|
||||
type BrNamedDef = stable_mir::ty::BrNamedDef;
|
||||
type TraitDef = stable_mir::ty::TraitDef;
|
||||
type GenericDef = stable_mir::ty::GenericDef;
|
||||
type ConstDef = stable_mir::ty::ConstDef;
|
||||
type ImplDef = stable_mir::ty::ImplDef;
|
||||
type RegionDef = stable_mir::ty::RegionDef;
|
||||
type CoroutineWitnessDef = stable_mir::ty::CoroutineWitnessDef;
|
||||
type AssocDef = stable_mir::ty::AssocDef;
|
||||
type OpaqueDef = stable_mir::ty::OpaqueDef;
|
||||
type Prov = stable_mir::ty::Prov;
|
||||
type StaticDef = stable_mir::mir::mono::StaticDef;
|
||||
type Error = crate::Error;
|
||||
type CrateItem = crate::CrateItem;
|
||||
type AdtDef = crate::ty::AdtDef;
|
||||
type ForeignModuleDef = crate::ty::ForeignModuleDef;
|
||||
type ForeignDef = crate::ty::ForeignDef;
|
||||
type FnDef = crate::ty::FnDef;
|
||||
type ClosureDef = crate::ty::ClosureDef;
|
||||
type CoroutineDef = crate::ty::CoroutineDef;
|
||||
type CoroutineClosureDef = crate::ty::CoroutineClosureDef;
|
||||
type AliasDef = crate::ty::AliasDef;
|
||||
type ParamDef = crate::ty::ParamDef;
|
||||
type BrNamedDef = crate::ty::BrNamedDef;
|
||||
type TraitDef = crate::ty::TraitDef;
|
||||
type GenericDef = crate::ty::GenericDef;
|
||||
type ConstDef = crate::ty::ConstDef;
|
||||
type ImplDef = crate::ty::ImplDef;
|
||||
type RegionDef = crate::ty::RegionDef;
|
||||
type CoroutineWitnessDef = crate::ty::CoroutineWitnessDef;
|
||||
type AssocDef = crate::ty::AssocDef;
|
||||
type OpaqueDef = crate::ty::OpaqueDef;
|
||||
type Prov = crate::ty::Prov;
|
||||
type StaticDef = crate::mir::mono::StaticDef;
|
||||
|
||||
type Allocation = stable_mir::ty::Allocation;
|
||||
type Allocation = crate::ty::Allocation;
|
||||
}
|
||||
|
||||
/// Stable public API for querying compiler information.
|
||||
///
|
||||
/// All queries are delegated to [`crate::rustc_smir::context::SmirCtxt`] that provides
|
||||
/// All queries are delegated to [`rustc_smir::context::SmirCtxt`] that provides
|
||||
/// similar APIs but based on internal rustc constructs.
|
||||
///
|
||||
/// Do not use this directly. This is currently used in the macro expansion.
|
||||
@@ -440,7 +439,7 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
|
||||
let cx = &*self.cx.borrow();
|
||||
let did = tables[def_id];
|
||||
let (parent, kinds) = cx.predicates_of(did);
|
||||
stable_mir::ty::GenericPredicates {
|
||||
crate::ty::GenericPredicates {
|
||||
parent: parent.map(|did| tables.trait_def(did)),
|
||||
predicates: kinds
|
||||
.iter()
|
||||
@@ -454,7 +453,7 @@ impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> {
|
||||
let cx = &*self.cx.borrow();
|
||||
let did = tables[def_id];
|
||||
let (parent, kinds) = cx.explicit_predicates_of(did);
|
||||
stable_mir::ty::GenericPredicates {
|
||||
crate::ty::GenericPredicates {
|
||||
parent: parent.map(|did| tables.trait_def(did)),
|
||||
predicates: kinds
|
||||
.iter()
|
||||
@@ -2,10 +2,9 @@
|
||||
//! such as, a function, a trait, an enum, and any other definitions.
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::ty::{GenericArgs, Span, Ty};
|
||||
use stable_mir::{AssocItems, Crate, Symbol, with};
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::ty::{GenericArgs, Span, Ty};
|
||||
use crate::{AssocItems, Crate, Symbol, with};
|
||||
|
||||
/// A unique identification number for each item accessible for the current compilation unit.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)]
|
||||
@@ -9,8 +9,6 @@ use std::{fmt, io};
|
||||
|
||||
use rustc_smir::bridge::SmirError;
|
||||
|
||||
use crate::rustc_smir;
|
||||
|
||||
macro_rules! error {
|
||||
($fmt: literal $(,)?) => { Error(format!($fmt)) };
|
||||
($fmt: literal, $($arg:tt)*) => { Error(format!($fmt, $($arg)*)) };
|
||||
@@ -1,11 +1,300 @@
|
||||
//! We've temporarily moved the `stable_mir` implementation to [`rustc_smir::stable_mir`],
|
||||
//! during refactoring to break the circular dependency between `rustc_smir` and `stable_mir`,
|
||||
//! The WIP stable interface to rustc internals.
|
||||
//!
|
||||
//! This is a transitional measure as described in [PR #139319](https://github.com/rust-lang/rust/pull/139319).
|
||||
//! Once the refactoring is complete, the `stable_mir` implementation will be moved back here.
|
||||
//! For more information see <https://github.com/rust-lang/project-stable-mir>
|
||||
//!
|
||||
//! # Note
|
||||
//!
|
||||
//! This API is still completely unstable and subject to change.
|
||||
|
||||
#![allow(rustc::usage_of_ty_tykind)]
|
||||
#![doc(
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||
test(attr(allow(unused_variables), deny(warnings)))
|
||||
)]
|
||||
#![feature(sized_hierarchy)]
|
||||
//!
|
||||
//! This crate shall contain all type definitions and APIs that we expect third-party tools to invoke to
|
||||
//! interact with the compiler.
|
||||
//!
|
||||
//! The goal is to eventually be published on
|
||||
//! [crates.io](https://crates.io).
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::{fmt, io};
|
||||
|
||||
pub(crate) use rustc_smir::IndexedVal;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
/// Export the rustc_internal APIs. Note that this module has no stability
|
||||
/// guarantees and it is not taken into account for semver.
|
||||
#[cfg(feature = "rustc_internal")]
|
||||
pub use rustc_smir::rustc_internal;
|
||||
pub use rustc_smir::stable_mir::*;
|
||||
pub mod rustc_internal;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::compiler_interface::with;
|
||||
pub use crate::crate_def::{CrateDef, CrateDefItems, CrateDefType, DefId};
|
||||
pub use crate::error::*;
|
||||
use crate::mir::mono::StaticDef;
|
||||
use crate::mir::{Body, Mutability};
|
||||
use crate::ty::{AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty};
|
||||
use crate::unstable::Stable;
|
||||
|
||||
pub mod abi;
|
||||
mod alloc;
|
||||
pub(crate) mod unstable;
|
||||
#[macro_use]
|
||||
pub mod crate_def;
|
||||
pub mod compiler_interface;
|
||||
#[macro_use]
|
||||
pub mod error;
|
||||
pub mod mir;
|
||||
pub mod target;
|
||||
pub mod ty;
|
||||
pub mod visitor;
|
||||
|
||||
/// Use String for now but we should replace it.
|
||||
pub type Symbol = String;
|
||||
|
||||
/// The number that identifies a crate.
|
||||
pub type CrateNum = usize;
|
||||
|
||||
impl Debug for DefId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexedVal for DefId {
|
||||
fn to_val(index: usize) -> Self {
|
||||
DefId(index)
|
||||
}
|
||||
|
||||
fn to_index(&self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// A list of crate items.
|
||||
pub type CrateItems = Vec<CrateItem>;
|
||||
|
||||
/// A list of trait decls.
|
||||
pub type TraitDecls = Vec<TraitDef>;
|
||||
|
||||
/// A list of impl trait decls.
|
||||
pub type ImplTraitDecls = Vec<ImplDef>;
|
||||
|
||||
/// A list of associated items.
|
||||
pub type AssocItems = Vec<AssocItem>;
|
||||
|
||||
/// Holds information about a crate.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Serialize)]
|
||||
pub struct Crate {
|
||||
pub id: CrateNum,
|
||||
pub name: Symbol,
|
||||
pub is_local: bool,
|
||||
}
|
||||
|
||||
impl Crate {
|
||||
/// The list of foreign modules in this crate.
|
||||
pub fn foreign_modules(&self) -> Vec<ForeignModuleDef> {
|
||||
with(|cx| cx.foreign_modules(self.id))
|
||||
}
|
||||
|
||||
/// The list of traits declared in this crate.
|
||||
pub fn trait_decls(&self) -> TraitDecls {
|
||||
with(|cx| cx.trait_decls(self.id))
|
||||
}
|
||||
|
||||
/// The list of trait implementations in this crate.
|
||||
pub fn trait_impls(&self) -> ImplTraitDecls {
|
||||
with(|cx| cx.trait_impls(self.id))
|
||||
}
|
||||
|
||||
/// Return a list of function definitions from this crate independent on their visibility.
|
||||
pub fn fn_defs(&self) -> Vec<FnDef> {
|
||||
with(|cx| cx.crate_functions(self.id))
|
||||
}
|
||||
|
||||
/// Return a list of static items defined in this crate independent on their visibility.
|
||||
pub fn statics(&self) -> Vec<StaticDef> {
|
||||
with(|cx| cx.crate_statics(self.id))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Serialize)]
|
||||
pub enum ItemKind {
|
||||
Fn,
|
||||
Static,
|
||||
Const,
|
||||
Ctor(CtorKind),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, Serialize)]
|
||||
pub enum CtorKind {
|
||||
Const,
|
||||
Fn,
|
||||
}
|
||||
|
||||
pub type Filename = String;
|
||||
|
||||
crate_def_with_ty! {
|
||||
/// Holds information about an item in a crate.
|
||||
#[derive(Serialize)]
|
||||
pub CrateItem;
|
||||
}
|
||||
|
||||
impl CrateItem {
|
||||
/// This will return the body of an item or panic if it's not available.
|
||||
pub fn expect_body(&self) -> mir::Body {
|
||||
with(|cx| cx.mir_body(self.0))
|
||||
}
|
||||
|
||||
/// Return the body of an item if available.
|
||||
pub fn body(&self) -> Option<mir::Body> {
|
||||
with(|cx| cx.has_body(self.0).then(|| cx.mir_body(self.0)))
|
||||
}
|
||||
|
||||
/// Check if a body is available for this item.
|
||||
pub fn has_body(&self) -> bool {
|
||||
with(|cx| cx.has_body(self.0))
|
||||
}
|
||||
|
||||
pub fn span(&self) -> Span {
|
||||
with(|cx| cx.span_of_an_item(self.0))
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> ItemKind {
|
||||
with(|cx| cx.item_kind(*self))
|
||||
}
|
||||
|
||||
pub fn requires_monomorphization(&self) -> bool {
|
||||
with(|cx| cx.requires_monomorphization(self.0))
|
||||
}
|
||||
|
||||
pub fn ty(&self) -> Ty {
|
||||
with(|cx| cx.def_ty(self.0))
|
||||
}
|
||||
|
||||
pub fn is_foreign_item(&self) -> bool {
|
||||
with(|cx| cx.is_foreign_item(self.0))
|
||||
}
|
||||
|
||||
/// Emit MIR for this item body.
|
||||
pub fn emit_mir<W: io::Write>(&self, w: &mut W) -> io::Result<()> {
|
||||
self.body()
|
||||
.ok_or_else(|| io::Error::other(format!("No body found for `{}`", self.name())))?
|
||||
.dump(w, &self.name())
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the function where execution starts if the current
|
||||
/// crate defines that. This is usually `main`, but could be
|
||||
/// `start` if the crate is a no-std crate.
|
||||
pub fn entry_fn() -> Option<CrateItem> {
|
||||
with(|cx| cx.entry_fn())
|
||||
}
|
||||
|
||||
/// Access to the local crate.
|
||||
pub fn local_crate() -> Crate {
|
||||
with(|cx| cx.local_crate())
|
||||
}
|
||||
|
||||
/// Try to find a crate or crates if multiple crates exist from given name.
|
||||
pub fn find_crates(name: &str) -> Vec<Crate> {
|
||||
with(|cx| cx.find_crates(name))
|
||||
}
|
||||
|
||||
/// Try to find a crate with the given name.
|
||||
pub fn external_crates() -> Vec<Crate> {
|
||||
with(|cx| cx.external_crates())
|
||||
}
|
||||
|
||||
/// Retrieve all items in the local crate that have a MIR associated with them.
|
||||
pub fn all_local_items() -> CrateItems {
|
||||
with(|cx| cx.all_local_items())
|
||||
}
|
||||
|
||||
pub fn all_trait_decls() -> TraitDecls {
|
||||
with(|cx| cx.all_trait_decls())
|
||||
}
|
||||
|
||||
pub fn all_trait_impls() -> ImplTraitDecls {
|
||||
with(|cx| cx.all_trait_impls())
|
||||
}
|
||||
|
||||
/// A type that provides internal information but that can still be used for debug purpose.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Serialize)]
|
||||
pub struct Opaque(String);
|
||||
|
||||
impl std::fmt::Display for Opaque {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Opaque {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn opaque<T: Debug>(value: &T) -> Opaque {
|
||||
Opaque(format!("{value:?}"))
|
||||
}
|
||||
|
||||
macro_rules! bridge_impl {
|
||||
($name: ident, $ty: ty) => {
|
||||
impl rustc_smir::bridge::$name<compiler_interface::BridgeTys> for $ty {
|
||||
fn new(def: crate::DefId) -> Self {
|
||||
Self(def)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
bridge_impl!(CrateItem, crate::CrateItem);
|
||||
bridge_impl!(AdtDef, crate::ty::AdtDef);
|
||||
bridge_impl!(ForeignModuleDef, crate::ty::ForeignModuleDef);
|
||||
bridge_impl!(ForeignDef, crate::ty::ForeignDef);
|
||||
bridge_impl!(FnDef, crate::ty::FnDef);
|
||||
bridge_impl!(ClosureDef, crate::ty::ClosureDef);
|
||||
bridge_impl!(CoroutineDef, crate::ty::CoroutineDef);
|
||||
bridge_impl!(CoroutineClosureDef, crate::ty::CoroutineClosureDef);
|
||||
bridge_impl!(AliasDef, crate::ty::AliasDef);
|
||||
bridge_impl!(ParamDef, crate::ty::ParamDef);
|
||||
bridge_impl!(BrNamedDef, crate::ty::BrNamedDef);
|
||||
bridge_impl!(TraitDef, crate::ty::TraitDef);
|
||||
bridge_impl!(GenericDef, crate::ty::GenericDef);
|
||||
bridge_impl!(ConstDef, crate::ty::ConstDef);
|
||||
bridge_impl!(ImplDef, crate::ty::ImplDef);
|
||||
bridge_impl!(RegionDef, crate::ty::RegionDef);
|
||||
bridge_impl!(CoroutineWitnessDef, crate::ty::CoroutineWitnessDef);
|
||||
bridge_impl!(AssocDef, crate::ty::AssocDef);
|
||||
bridge_impl!(OpaqueDef, crate::ty::OpaqueDef);
|
||||
bridge_impl!(StaticDef, crate::mir::mono::StaticDef);
|
||||
|
||||
impl rustc_smir::bridge::Prov<compiler_interface::BridgeTys> for crate::ty::Prov {
|
||||
fn new(aid: crate::mir::alloc::AllocId) -> Self {
|
||||
Self(aid)
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_smir::bridge::Allocation<compiler_interface::BridgeTys> for crate::ty::Allocation {
|
||||
fn new<'tcx>(
|
||||
bytes: Vec<Option<u8>>,
|
||||
ptrs: Vec<(usize, rustc_middle::mir::interpret::AllocId)>,
|
||||
align: u64,
|
||||
mutability: rustc_middle::mir::Mutability,
|
||||
tables: &mut Tables<'tcx, compiler_interface::BridgeTys>,
|
||||
cx: &SmirCtxt<'tcx, compiler_interface::BridgeTys>,
|
||||
) -> Self {
|
||||
Self {
|
||||
bytes,
|
||||
provenance: ProvenanceMap {
|
||||
ptrs: ptrs.iter().map(|(i, aid)| (*i, tables.prov(*aid))).collect(),
|
||||
},
|
||||
align,
|
||||
mutability: mutability.stable(tables, cx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
use std::io::Read;
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::mir::mono::{Instance, StaticDef};
|
||||
use stable_mir::target::{Endian, MachineInfo};
|
||||
use stable_mir::ty::{Allocation, Binder, ExistentialTraitRef, Ty};
|
||||
use stable_mir::{Error, IndexedVal, with};
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::mir::mono::{Instance, StaticDef};
|
||||
use crate::target::{Endian, MachineInfo};
|
||||
use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty};
|
||||
use crate::{Error, IndexedVal, with};
|
||||
|
||||
/// An allocation in the SMIR global memory can be either a function pointer,
|
||||
/// a static, or a "real" allocation with some data in it.
|
||||
@@ -1,15 +1,14 @@
|
||||
use std::io;
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::compiler_interface::with;
|
||||
use stable_mir::mir::pretty::function_body;
|
||||
use stable_mir::ty::{
|
||||
|
||||
use crate::compiler_interface::with;
|
||||
use crate::mir::pretty::function_body;
|
||||
use crate::ty::{
|
||||
AdtDef, ClosureDef, CoroutineClosureDef, CoroutineDef, GenericArgs, MirConst, Movability,
|
||||
Region, RigidTy, Ty, TyConst, TyKind, VariantIdx,
|
||||
};
|
||||
use stable_mir::{Error, Opaque, Span, Symbol};
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::{Error, Opaque, Span, Symbol};
|
||||
|
||||
/// The SMIR representation of a single function.
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -587,7 +586,7 @@ pub enum Rvalue {
|
||||
///
|
||||
/// **Needs clarification**: Are there weird additional semantics here related to the runtime
|
||||
/// nature of this operation?
|
||||
ThreadLocalRef(stable_mir::CrateItem),
|
||||
ThreadLocalRef(crate::CrateItem),
|
||||
|
||||
/// Computes a value as described by the operation.
|
||||
NullaryOp(NullOp, Ty),
|
||||
@@ -3,13 +3,12 @@ use std::io;
|
||||
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use serde::Serialize;
|
||||
use stable_mir::abi::FnAbi;
|
||||
use stable_mir::crate_def::CrateDef;
|
||||
use stable_mir::mir::Body;
|
||||
use stable_mir::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty};
|
||||
use stable_mir::{CrateItem, DefId, Error, IndexedVal, ItemKind, Opaque, Symbol, with};
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::abi::FnAbi;
|
||||
use crate::crate_def::CrateDef;
|
||||
use crate::mir::Body;
|
||||
use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty};
|
||||
use crate::{CrateItem, DefId, Error, IndexedVal, ItemKind, Opaque, Symbol, with};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
|
||||
pub enum MonoItem {
|
||||
@@ -194,7 +193,7 @@ impl Debug for Instance {
|
||||
/// Try to convert a crate item into an instance.
|
||||
/// The item cannot be generic in order to be converted into an instance.
|
||||
impl TryFrom<CrateItem> for Instance {
|
||||
type Error = stable_mir::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(item: CrateItem) -> Result<Self, Self::Error> {
|
||||
with(|context| {
|
||||
@@ -211,7 +210,7 @@ impl TryFrom<CrateItem> for Instance {
|
||||
/// Try to convert an instance into a crate item.
|
||||
/// Only user defined instances can be converted.
|
||||
impl TryFrom<Instance> for CrateItem {
|
||||
type Error = stable_mir::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(value: Instance) -> Result<Self, Self::Error> {
|
||||
with(|context| {
|
||||
@@ -258,7 +257,7 @@ crate_def! {
|
||||
}
|
||||
|
||||
impl TryFrom<CrateItem> for StaticDef {
|
||||
type Error = stable_mir::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(value: CrateItem) -> Result<Self, Self::Error> {
|
||||
if matches!(value.kind(), ItemKind::Static) {
|
||||
@@ -270,7 +269,7 @@ impl TryFrom<CrateItem> for StaticDef {
|
||||
}
|
||||
|
||||
impl TryFrom<Instance> for StaticDef {
|
||||
type Error = stable_mir::Error;
|
||||
type Error = crate::Error;
|
||||
|
||||
fn try_from(value: Instance) -> Result<Self, Self::Error> {
|
||||
StaticDef::try_from(CrateItem::try_from(value)?)
|
||||
@@ -4,14 +4,13 @@ use std::io::Write;
|
||||
use std::{fmt, io, iter};
|
||||
|
||||
use fmt::{Display, Formatter};
|
||||
use stable_mir::mir::{
|
||||
Operand, Place, RawPtrKind, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents,
|
||||
};
|
||||
use stable_mir::ty::{AdtKind, AssocKind, MirConst, Ty, TyConst};
|
||||
use stable_mir::{Body, CrateDef, IndexedVal, Mutability, with};
|
||||
|
||||
use super::{AggregateKind, AssertMessage, BinOp, BorrowKind, FakeBorrowKind, TerminatorKind};
|
||||
use crate::stable_mir;
|
||||
use crate::mir::{
|
||||
Operand, Place, RawPtrKind, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents,
|
||||
};
|
||||
use crate::ty::{AdtKind, AssocKind, MirConst, Ty, TyConst};
|
||||
use crate::{Body, CrateDef, IndexedVal, Mutability, with};
|
||||
|
||||
impl Display for Ty {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
@@ -35,11 +35,9 @@
|
||||
//! The only place that `_` is acceptable is to match a field (or
|
||||
//! variant argument) that does not require visiting.
|
||||
|
||||
use stable_mir::mir::*;
|
||||
use stable_mir::ty::{GenericArgs, MirConst, Region, Ty, TyConst};
|
||||
use stable_mir::{Error, Opaque, Span};
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::mir::*;
|
||||
use crate::ty::{GenericArgs, MirConst, Region, Ty, TyConst};
|
||||
use crate::{Error, Opaque, Span};
|
||||
|
||||
macro_rules! make_mir_visitor {
|
||||
($visitor_trait_name:ident, $($mutability:ident)?) => {
|
||||
@@ -6,14 +6,13 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_smir::{Bridge, SmirContainer, Tables};
|
||||
use rustc_span::def_id::CrateNum;
|
||||
use scoped_tls::scoped_thread_local;
|
||||
use stable_mir::Error;
|
||||
use stable_mir::unstable::{RustcInternal, Stable};
|
||||
|
||||
use crate::rustc_smir::context::SmirCtxt;
|
||||
use crate::rustc_smir::{Bridge, SmirContainer, Tables};
|
||||
use crate::stable_mir;
|
||||
use crate::Error;
|
||||
use crate::unstable::{RustcInternal, Stable};
|
||||
|
||||
pub mod pretty;
|
||||
|
||||
@@ -53,7 +52,7 @@ where
|
||||
with_container(|tables, _| item.internal(tables, tcx))
|
||||
}
|
||||
|
||||
pub fn crate_num(item: &stable_mir::Crate) -> CrateNum {
|
||||
pub fn crate_num(item: &crate::Crate) -> CrateNum {
|
||||
item.id.into()
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ where
|
||||
let smir_cx = RefCell::new(SmirCtxt::new(tcx));
|
||||
let container = SmirContainer { tables: RefCell::new(Tables::default()), cx: smir_cx };
|
||||
|
||||
stable_mir::compiler_interface::run(&container, || init(&container, f))
|
||||
crate::compiler_interface::run(&container, || init(&container, f))
|
||||
}
|
||||
|
||||
/// Instantiate and run the compiler with the provided arguments and callback.
|
||||
@@ -106,7 +105,6 @@ where
|
||||
/// # extern crate rustc_interface;
|
||||
/// # extern crate rustc_middle;
|
||||
/// # #[macro_use]
|
||||
/// # extern crate rustc_smir;
|
||||
/// # extern crate stable_mir;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
@@ -127,7 +125,6 @@ where
|
||||
/// # extern crate rustc_interface;
|
||||
/// # extern crate rustc_middle;
|
||||
/// # #[macro_use]
|
||||
/// # extern crate rustc_smir;
|
||||
/// # extern crate stable_mir;
|
||||
/// #
|
||||
/// # fn main() {
|
||||
@@ -190,7 +187,7 @@ macro_rules! run_driver {
|
||||
use rustc_driver::{Callbacks, Compilation, run_compiler};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_interface::interface;
|
||||
use rustc_smir::rustc_internal;
|
||||
use stable_mir::rustc_internal;
|
||||
use stable_mir::CompilerError;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
@@ -3,7 +3,6 @@ use std::io;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use super::run;
|
||||
use crate::stable_mir;
|
||||
|
||||
pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> {
|
||||
writeln!(
|
||||
@@ -15,7 +14,7 @@ pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io
|
||||
"// If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir."
|
||||
)?;
|
||||
let _ = run(tcx, || {
|
||||
let items = stable_mir::all_local_items();
|
||||
let items = crate::all_local_items();
|
||||
let _ = items.iter().map(|item| -> io::Result<()> { item.emit_mir(w) }).collect::<Vec<_>>();
|
||||
});
|
||||
Ok(())
|
||||
@@ -1,9 +1,8 @@
|
||||
//! Provide information about the machine that this is being compiled into.
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::compiler_interface::with;
|
||||
|
||||
use crate::stable_mir;
|
||||
use crate::compiler_interface::with;
|
||||
|
||||
/// The properties of the target machine being compiled into.
|
||||
#[derive(Clone, PartialEq, Eq, Serialize)]
|
||||
@@ -2,17 +2,16 @@ use std::fmt::{self, Debug, Display, Formatter};
|
||||
use std::ops::Range;
|
||||
|
||||
use serde::Serialize;
|
||||
use stable_mir::abi::{FnAbi, Layout};
|
||||
use stable_mir::crate_def::{CrateDef, CrateDefItems, CrateDefType};
|
||||
use stable_mir::mir::alloc::{AllocId, read_target_int, read_target_uint};
|
||||
use stable_mir::mir::mono::StaticDef;
|
||||
use stable_mir::target::MachineInfo;
|
||||
use stable_mir::{Filename, IndexedVal, Opaque};
|
||||
|
||||
use super::abi::ReprOptions;
|
||||
use super::mir::{Body, Mutability, Safety};
|
||||
use super::{DefId, Error, Symbol, with};
|
||||
use crate::stable_mir;
|
||||
use crate::abi::{FnAbi, Layout};
|
||||
use crate::crate_def::{CrateDef, CrateDefItems, CrateDefType};
|
||||
use crate::mir::alloc::{AllocId, read_target_int, read_target_uint};
|
||||
use crate::mir::mono::StaticDef;
|
||||
use crate::target::MachineInfo;
|
||||
use crate::{Filename, IndexedVal, Opaque};
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize)]
|
||||
pub struct Ty(usize);
|
||||
@@ -1565,7 +1564,7 @@ pub enum PredicatePolarity {
|
||||
|
||||
macro_rules! index_impl {
|
||||
($name:ident) => {
|
||||
impl stable_mir::IndexedVal for $name {
|
||||
impl crate::IndexedVal for $name {
|
||||
fn to_val(index: usize) -> Self {
|
||||
$name(index)
|
||||
}
|
||||
@@ -7,21 +7,20 @@
|
||||
|
||||
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy};
|
||||
use rustc_smir::Tables;
|
||||
use stable_mir::abi::Layout;
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
use stable_mir::mir::alloc::AllocId;
|
||||
use stable_mir::mir::mono::{Instance, MonoItem, StaticDef};
|
||||
use stable_mir::mir::{BinOp, Mutability, Place, ProjectionElem, RawPtrKind, Safety, UnOp};
|
||||
use stable_mir::ty::{
|
||||
|
||||
use crate::abi::Layout;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
use crate::mir::alloc::AllocId;
|
||||
use crate::mir::mono::{Instance, MonoItem, StaticDef};
|
||||
use crate::mir::{BinOp, Mutability, Place, ProjectionElem, RawPtrKind, Safety, UnOp};
|
||||
use crate::ty::{
|
||||
Abi, AdtDef, Binder, BoundRegionKind, BoundTyKind, BoundVariableKind, ClosureKind, DynKind,
|
||||
ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FloatTy, FnSig,
|
||||
GenericArgKind, GenericArgs, IntTy, MirConst, Movability, Pattern, Region, RigidTy, Span,
|
||||
TermKind, TraitRef, Ty, TyConst, UintTy, VariantDef, VariantIdx,
|
||||
};
|
||||
use stable_mir::unstable::{InternalCx, RustcInternal};
|
||||
use stable_mir::{CrateItem, CrateNum, DefId, IndexedVal};
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::unstable::{InternalCx, RustcInternal};
|
||||
use crate::{CrateItem, CrateNum, DefId, IndexedVal};
|
||||
|
||||
impl RustcInternal for CrateItem {
|
||||
type T<'tcx> = rustc_span::def_id::DefId;
|
||||
@@ -505,7 +504,7 @@ impl RustcInternal for ExistentialProjection {
|
||||
tables: &mut Tables<'_, BridgeTys>,
|
||||
tcx: impl InternalCx<'tcx>,
|
||||
) -> Self::T<'tcx> {
|
||||
use rustc_smir::context::SmirExistentialProjection;
|
||||
use crate::unstable::internal_cx::SmirExistentialProjection;
|
||||
tcx.new_from_args(
|
||||
self.def_id.0.internal(tables, tcx),
|
||||
self.generic_args.internal(tables, tcx),
|
||||
@@ -537,7 +536,7 @@ impl RustcInternal for ExistentialTraitRef {
|
||||
tables: &mut Tables<'_, BridgeTys>,
|
||||
tcx: impl InternalCx<'tcx>,
|
||||
) -> Self::T<'tcx> {
|
||||
use rustc_smir::context::SmirExistentialTraitRef;
|
||||
use crate::unstable::internal_cx::SmirExistentialTraitRef;
|
||||
tcx.new_from_args(
|
||||
self.def_id.0.internal(tables, tcx),
|
||||
self.generic_args.internal(tables, tcx),
|
||||
@@ -553,7 +552,7 @@ impl RustcInternal for TraitRef {
|
||||
tables: &mut Tables<'_, BridgeTys>,
|
||||
tcx: impl InternalCx<'tcx>,
|
||||
) -> Self::T<'tcx> {
|
||||
use rustc_smir::context::SmirTraitRef;
|
||||
use crate::unstable::internal_cx::SmirTraitRef;
|
||||
tcx.new_from_args(self.def_id.0.internal(tables, tcx), self.args().internal(tables, tcx))
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,9 @@ use std::ops::RangeInclusive;
|
||||
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
|
||||
use super::Stable;
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
||||
mod internal;
|
||||
mod stable;
|
||||
@@ -7,18 +7,17 @@ use rustc_middle::ty;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use rustc_target::callconv;
|
||||
use stable_mir::abi::{
|
||||
|
||||
use crate::abi::{
|
||||
AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength,
|
||||
IntegerType, Layout, LayoutShape, PassMode, Primitive, ReprFlags, ReprOptions, Scalar,
|
||||
TagEncoding, TyAndLayout, ValueAbi, VariantsShape, WrappingRange,
|
||||
};
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
use stable_mir::target::MachineSize as Size;
|
||||
use stable_mir::ty::{Align, VariantIdx};
|
||||
use stable_mir::unstable::Stable;
|
||||
use stable_mir::{IndexedVal, opaque};
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
use crate::target::MachineSize as Size;
|
||||
use crate::ty::{Align, VariantIdx};
|
||||
use crate::unstable::Stable;
|
||||
use crate::{IndexedVal, opaque};
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx {
|
||||
type T = VariantIdx;
|
||||
@@ -28,12 +27,12 @@ impl<'tcx> Stable<'tcx> for rustc_abi::VariantIdx {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_abi::Endian {
|
||||
type T = stable_mir::target::Endian;
|
||||
type T = crate::target::Endian;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
rustc_abi::Endian::Little => stable_mir::target::Endian::Little,
|
||||
rustc_abi::Endian::Big => stable_mir::target::Endian::Big,
|
||||
rustc_abi::Endian::Little => crate::target::Endian::Little,
|
||||
rustc_abi::Endian::Big => crate::target::Endian::Big,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,26 @@ use rustc_middle::{bug, mir};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::bridge::SmirError;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
use stable_mir::mir::alloc::GlobalAlloc;
|
||||
use stable_mir::mir::{ConstOperand, Statement, UserTypeProjection, VarDebugInfoFragment};
|
||||
use stable_mir::ty::{Allocation, ConstantKind, MirConst};
|
||||
use stable_mir::unstable::Stable;
|
||||
use stable_mir::{Error, alloc, opaque};
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
use crate::mir::alloc::GlobalAlloc;
|
||||
use crate::mir::{ConstOperand, Statement, UserTypeProjection, VarDebugInfoFragment};
|
||||
use crate::ty::{Allocation, ConstantKind, MirConst};
|
||||
use crate::unstable::Stable;
|
||||
use crate::{Error, alloc, opaque};
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
|
||||
type T = stable_mir::mir::Body;
|
||||
type T = crate::mir::Body;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::mir::Body::new(
|
||||
crate::mir::Body::new(
|
||||
self.basic_blocks
|
||||
.iter()
|
||||
.map(|block| stable_mir::mir::BasicBlock {
|
||||
.map(|block| crate::mir::BasicBlock {
|
||||
terminator: block.terminator().stable(tables, cx),
|
||||
statements: block
|
||||
.statements
|
||||
@@ -36,7 +35,7 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
|
||||
.collect(),
|
||||
self.local_decls
|
||||
.iter()
|
||||
.map(|decl| stable_mir::mir::LocalDecl {
|
||||
.map(|decl| crate::mir::LocalDecl {
|
||||
ty: decl.ty.stable(tables, cx),
|
||||
span: decl.source_info.span.stable(tables, cx),
|
||||
mutability: decl.mutability.stable(tables, cx),
|
||||
@@ -51,13 +50,13 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::VarDebugInfo<'tcx> {
|
||||
type T = stable_mir::mir::VarDebugInfo;
|
||||
type T = crate::mir::VarDebugInfo;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::mir::VarDebugInfo {
|
||||
crate::mir::VarDebugInfo {
|
||||
name: self.name.to_string(),
|
||||
source_info: self.source_info.stable(tables, cx),
|
||||
composite: self.composite.as_ref().map(|composite| composite.stable(tables, cx)),
|
||||
@@ -68,7 +67,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfo<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
|
||||
type T = stable_mir::mir::Statement;
|
||||
type T = crate::mir::Statement;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -82,18 +81,18 @@ impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::SourceInfo {
|
||||
type T = stable_mir::mir::SourceInfo;
|
||||
type T = crate::mir::SourceInfo;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::mir::SourceInfo { span: self.span.stable(tables, cx), scope: self.scope.into() }
|
||||
crate::mir::SourceInfo { span: self.span.stable(tables, cx), scope: self.scope.into() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::VarDebugInfoFragment<'tcx> {
|
||||
type T = stable_mir::mir::VarDebugInfoFragment;
|
||||
type T = crate::mir::VarDebugInfoFragment;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -107,7 +106,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfoFragment<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::VarDebugInfoContents<'tcx> {
|
||||
type T = stable_mir::mir::VarDebugInfoContents;
|
||||
type T = crate::mir::VarDebugInfoContents;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -115,7 +114,7 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfoContents<'tcx> {
|
||||
) -> Self::T {
|
||||
match self {
|
||||
mir::VarDebugInfoContents::Place(place) => {
|
||||
stable_mir::mir::VarDebugInfoContents::Place(place.stable(tables, cx))
|
||||
crate::mir::VarDebugInfoContents::Place(place.stable(tables, cx))
|
||||
}
|
||||
mir::VarDebugInfoContents::Const(const_operand) => {
|
||||
let op = ConstOperand {
|
||||
@@ -123,81 +122,76 @@ impl<'tcx> Stable<'tcx> for mir::VarDebugInfoContents<'tcx> {
|
||||
user_ty: const_operand.user_ty.map(|index| index.as_usize()),
|
||||
const_: const_operand.const_.stable(tables, cx),
|
||||
};
|
||||
stable_mir::mir::VarDebugInfoContents::Const(op)
|
||||
crate::mir::VarDebugInfoContents::Const(op)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::StatementKind<'tcx> {
|
||||
type T = stable_mir::mir::StatementKind;
|
||||
type T = crate::mir::StatementKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
match self {
|
||||
mir::StatementKind::Assign(assign) => stable_mir::mir::StatementKind::Assign(
|
||||
mir::StatementKind::Assign(assign) => crate::mir::StatementKind::Assign(
|
||||
assign.0.stable(tables, cx),
|
||||
assign.1.stable(tables, cx),
|
||||
),
|
||||
mir::StatementKind::FakeRead(fake_read_place) => {
|
||||
stable_mir::mir::StatementKind::FakeRead(
|
||||
fake_read_place.0.stable(tables, cx),
|
||||
fake_read_place.1.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
mir::StatementKind::FakeRead(fake_read_place) => crate::mir::StatementKind::FakeRead(
|
||||
fake_read_place.0.stable(tables, cx),
|
||||
fake_read_place.1.stable(tables, cx),
|
||||
),
|
||||
mir::StatementKind::SetDiscriminant { place, variant_index } => {
|
||||
stable_mir::mir::StatementKind::SetDiscriminant {
|
||||
crate::mir::StatementKind::SetDiscriminant {
|
||||
place: place.as_ref().stable(tables, cx),
|
||||
variant_index: variant_index.stable(tables, cx),
|
||||
}
|
||||
}
|
||||
mir::StatementKind::Deinit(place) => {
|
||||
stable_mir::mir::StatementKind::Deinit(place.stable(tables, cx))
|
||||
crate::mir::StatementKind::Deinit(place.stable(tables, cx))
|
||||
}
|
||||
|
||||
mir::StatementKind::StorageLive(place) => {
|
||||
stable_mir::mir::StatementKind::StorageLive(place.stable(tables, cx))
|
||||
crate::mir::StatementKind::StorageLive(place.stable(tables, cx))
|
||||
}
|
||||
|
||||
mir::StatementKind::StorageDead(place) => {
|
||||
stable_mir::mir::StatementKind::StorageDead(place.stable(tables, cx))
|
||||
crate::mir::StatementKind::StorageDead(place.stable(tables, cx))
|
||||
}
|
||||
mir::StatementKind::Retag(retag, place) => {
|
||||
crate::mir::StatementKind::Retag(retag.stable(tables, cx), place.stable(tables, cx))
|
||||
}
|
||||
mir::StatementKind::Retag(retag, place) => stable_mir::mir::StatementKind::Retag(
|
||||
retag.stable(tables, cx),
|
||||
place.stable(tables, cx),
|
||||
),
|
||||
mir::StatementKind::PlaceMention(place) => {
|
||||
stable_mir::mir::StatementKind::PlaceMention(place.stable(tables, cx))
|
||||
crate::mir::StatementKind::PlaceMention(place.stable(tables, cx))
|
||||
}
|
||||
mir::StatementKind::AscribeUserType(place_projection, variance) => {
|
||||
stable_mir::mir::StatementKind::AscribeUserType {
|
||||
crate::mir::StatementKind::AscribeUserType {
|
||||
place: place_projection.as_ref().0.stable(tables, cx),
|
||||
projections: place_projection.as_ref().1.stable(tables, cx),
|
||||
variance: variance.stable(tables, cx),
|
||||
}
|
||||
}
|
||||
mir::StatementKind::Coverage(coverage) => {
|
||||
stable_mir::mir::StatementKind::Coverage(opaque(coverage))
|
||||
crate::mir::StatementKind::Coverage(opaque(coverage))
|
||||
}
|
||||
mir::StatementKind::Intrinsic(intrinstic) => {
|
||||
stable_mir::mir::StatementKind::Intrinsic(intrinstic.stable(tables, cx))
|
||||
}
|
||||
mir::StatementKind::ConstEvalCounter => {
|
||||
stable_mir::mir::StatementKind::ConstEvalCounter
|
||||
crate::mir::StatementKind::Intrinsic(intrinstic.stable(tables, cx))
|
||||
}
|
||||
mir::StatementKind::ConstEvalCounter => crate::mir::StatementKind::ConstEvalCounter,
|
||||
// BackwardIncompatibleDropHint has no semantics, so it is translated to Nop.
|
||||
mir::StatementKind::BackwardIncompatibleDropHint { .. } => {
|
||||
stable_mir::mir::StatementKind::Nop
|
||||
crate::mir::StatementKind::Nop
|
||||
}
|
||||
mir::StatementKind::Nop => stable_mir::mir::StatementKind::Nop,
|
||||
mir::StatementKind::Nop => crate::mir::StatementKind::Nop,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
|
||||
type T = stable_mir::mir::Rvalue;
|
||||
type T = crate::mir::Rvalue;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -205,91 +199,89 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::Rvalue::*;
|
||||
match self {
|
||||
Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables, cx)),
|
||||
Use(op) => crate::mir::Rvalue::Use(op.stable(tables, cx)),
|
||||
Repeat(op, len) => {
|
||||
let len = len.stable(tables, cx);
|
||||
stable_mir::mir::Rvalue::Repeat(op.stable(tables, cx), len)
|
||||
crate::mir::Rvalue::Repeat(op.stable(tables, cx), len)
|
||||
}
|
||||
Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
|
||||
Ref(region, kind, place) => crate::mir::Rvalue::Ref(
|
||||
region.stable(tables, cx),
|
||||
kind.stable(tables, cx),
|
||||
place.stable(tables, cx),
|
||||
),
|
||||
ThreadLocalRef(def_id) => {
|
||||
stable_mir::mir::Rvalue::ThreadLocalRef(tables.crate_item(*def_id))
|
||||
crate::mir::Rvalue::ThreadLocalRef(tables.crate_item(*def_id))
|
||||
}
|
||||
RawPtr(mutability, place) => stable_mir::mir::Rvalue::AddressOf(
|
||||
RawPtr(mutability, place) => crate::mir::Rvalue::AddressOf(
|
||||
mutability.stable(tables, cx),
|
||||
place.stable(tables, cx),
|
||||
),
|
||||
Len(place) => stable_mir::mir::Rvalue::Len(place.stable(tables, cx)),
|
||||
Cast(cast_kind, op, ty) => stable_mir::mir::Rvalue::Cast(
|
||||
Len(place) => crate::mir::Rvalue::Len(place.stable(tables, cx)),
|
||||
Cast(cast_kind, op, ty) => crate::mir::Rvalue::Cast(
|
||||
cast_kind.stable(tables, cx),
|
||||
op.stable(tables, cx),
|
||||
ty.stable(tables, cx),
|
||||
),
|
||||
BinaryOp(bin_op, ops) => {
|
||||
if let Some(bin_op) = bin_op.overflowing_to_wrapping() {
|
||||
stable_mir::mir::Rvalue::CheckedBinaryOp(
|
||||
crate::mir::Rvalue::CheckedBinaryOp(
|
||||
bin_op.stable(tables, cx),
|
||||
ops.0.stable(tables, cx),
|
||||
ops.1.stable(tables, cx),
|
||||
)
|
||||
} else {
|
||||
stable_mir::mir::Rvalue::BinaryOp(
|
||||
crate::mir::Rvalue::BinaryOp(
|
||||
bin_op.stable(tables, cx),
|
||||
ops.0.stable(tables, cx),
|
||||
ops.1.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
}
|
||||
NullaryOp(null_op, ty) => stable_mir::mir::Rvalue::NullaryOp(
|
||||
null_op.stable(tables, cx),
|
||||
ty.stable(tables, cx),
|
||||
),
|
||||
UnaryOp(un_op, op) => {
|
||||
stable_mir::mir::Rvalue::UnaryOp(un_op.stable(tables, cx), op.stable(tables, cx))
|
||||
NullaryOp(null_op, ty) => {
|
||||
crate::mir::Rvalue::NullaryOp(null_op.stable(tables, cx), ty.stable(tables, cx))
|
||||
}
|
||||
Discriminant(place) => stable_mir::mir::Rvalue::Discriminant(place.stable(tables, cx)),
|
||||
UnaryOp(un_op, op) => {
|
||||
crate::mir::Rvalue::UnaryOp(un_op.stable(tables, cx), op.stable(tables, cx))
|
||||
}
|
||||
Discriminant(place) => crate::mir::Rvalue::Discriminant(place.stable(tables, cx)),
|
||||
Aggregate(agg_kind, operands) => {
|
||||
let operands = operands.iter().map(|op| op.stable(tables, cx)).collect();
|
||||
stable_mir::mir::Rvalue::Aggregate(agg_kind.stable(tables, cx), operands)
|
||||
crate::mir::Rvalue::Aggregate(agg_kind.stable(tables, cx), operands)
|
||||
}
|
||||
ShallowInitBox(op, ty) => stable_mir::mir::Rvalue::ShallowInitBox(
|
||||
op.stable(tables, cx),
|
||||
ty.stable(tables, cx),
|
||||
),
|
||||
CopyForDeref(place) => stable_mir::mir::Rvalue::CopyForDeref(place.stable(tables, cx)),
|
||||
ShallowInitBox(op, ty) => {
|
||||
crate::mir::Rvalue::ShallowInitBox(op.stable(tables, cx), ty.stable(tables, cx))
|
||||
}
|
||||
CopyForDeref(place) => crate::mir::Rvalue::CopyForDeref(place.stable(tables, cx)),
|
||||
WrapUnsafeBinder(..) => todo!("FIXME(unsafe_binders):"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Mutability {
|
||||
type T = stable_mir::mir::Mutability;
|
||||
type T = crate::mir::Mutability;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_hir::Mutability::*;
|
||||
match *self {
|
||||
Not => stable_mir::mir::Mutability::Not,
|
||||
Mut => stable_mir::mir::Mutability::Mut,
|
||||
Not => crate::mir::Mutability::Not,
|
||||
Mut => crate::mir::Mutability::Mut,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::RawPtrKind {
|
||||
type T = stable_mir::mir::RawPtrKind;
|
||||
type T = crate::mir::RawPtrKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use mir::RawPtrKind::*;
|
||||
match *self {
|
||||
Const => stable_mir::mir::RawPtrKind::Const,
|
||||
Mut => stable_mir::mir::RawPtrKind::Mut,
|
||||
FakeForPtrMetadata => stable_mir::mir::RawPtrKind::FakeForPtrMetadata,
|
||||
Const => crate::mir::RawPtrKind::Const,
|
||||
Mut => crate::mir::RawPtrKind::Mut,
|
||||
FakeForPtrMetadata => crate::mir::RawPtrKind::FakeForPtrMetadata,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::BorrowKind {
|
||||
type T = stable_mir::mir::BorrowKind;
|
||||
type T = crate::mir::BorrowKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -297,38 +289,38 @@ impl<'tcx> Stable<'tcx> for mir::BorrowKind {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::BorrowKind::*;
|
||||
match *self {
|
||||
Shared => stable_mir::mir::BorrowKind::Shared,
|
||||
Fake(kind) => stable_mir::mir::BorrowKind::Fake(kind.stable(tables, cx)),
|
||||
Mut { kind } => stable_mir::mir::BorrowKind::Mut { kind: kind.stable(tables, cx) },
|
||||
Shared => crate::mir::BorrowKind::Shared,
|
||||
Fake(kind) => crate::mir::BorrowKind::Fake(kind.stable(tables, cx)),
|
||||
Mut { kind } => crate::mir::BorrowKind::Mut { kind: kind.stable(tables, cx) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::MutBorrowKind {
|
||||
type T = stable_mir::mir::MutBorrowKind;
|
||||
type T = crate::mir::MutBorrowKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::MutBorrowKind::*;
|
||||
match *self {
|
||||
Default => stable_mir::mir::MutBorrowKind::Default,
|
||||
TwoPhaseBorrow => stable_mir::mir::MutBorrowKind::TwoPhaseBorrow,
|
||||
ClosureCapture => stable_mir::mir::MutBorrowKind::ClosureCapture,
|
||||
Default => crate::mir::MutBorrowKind::Default,
|
||||
TwoPhaseBorrow => crate::mir::MutBorrowKind::TwoPhaseBorrow,
|
||||
ClosureCapture => crate::mir::MutBorrowKind::ClosureCapture,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::FakeBorrowKind {
|
||||
type T = stable_mir::mir::FakeBorrowKind;
|
||||
type T = crate::mir::FakeBorrowKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::FakeBorrowKind::*;
|
||||
match *self {
|
||||
Deep => stable_mir::mir::FakeBorrowKind::Deep,
|
||||
Shallow => stable_mir::mir::FakeBorrowKind::Shallow,
|
||||
Deep => crate::mir::FakeBorrowKind::Deep,
|
||||
Shallow => crate::mir::FakeBorrowKind::Shallow,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::NullOp<'tcx> {
|
||||
type T = stable_mir::mir::NullOp;
|
||||
type T = crate::mir::NullOp;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -336,19 +328,19 @@ impl<'tcx> Stable<'tcx> for mir::NullOp<'tcx> {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::NullOp::*;
|
||||
match self {
|
||||
SizeOf => stable_mir::mir::NullOp::SizeOf,
|
||||
AlignOf => stable_mir::mir::NullOp::AlignOf,
|
||||
OffsetOf(indices) => stable_mir::mir::NullOp::OffsetOf(
|
||||
SizeOf => crate::mir::NullOp::SizeOf,
|
||||
AlignOf => crate::mir::NullOp::AlignOf,
|
||||
OffsetOf(indices) => crate::mir::NullOp::OffsetOf(
|
||||
indices.iter().map(|idx| idx.stable(tables, cx)).collect(),
|
||||
),
|
||||
UbChecks => stable_mir::mir::NullOp::UbChecks,
|
||||
ContractChecks => stable_mir::mir::NullOp::ContractChecks,
|
||||
UbChecks => crate::mir::NullOp::UbChecks,
|
||||
ContractChecks => crate::mir::NullOp::ContractChecks,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::CastKind {
|
||||
type T = stable_mir::mir::CastKind;
|
||||
type T = crate::mir::CastKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -356,40 +348,38 @@ impl<'tcx> Stable<'tcx> for mir::CastKind {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::CastKind::*;
|
||||
match self {
|
||||
PointerExposeProvenance => stable_mir::mir::CastKind::PointerExposeAddress,
|
||||
PointerWithExposedProvenance => stable_mir::mir::CastKind::PointerWithExposedProvenance,
|
||||
PointerCoercion(c, _) => {
|
||||
stable_mir::mir::CastKind::PointerCoercion(c.stable(tables, cx))
|
||||
}
|
||||
IntToInt => stable_mir::mir::CastKind::IntToInt,
|
||||
FloatToInt => stable_mir::mir::CastKind::FloatToInt,
|
||||
FloatToFloat => stable_mir::mir::CastKind::FloatToFloat,
|
||||
IntToFloat => stable_mir::mir::CastKind::IntToFloat,
|
||||
PtrToPtr => stable_mir::mir::CastKind::PtrToPtr,
|
||||
FnPtrToPtr => stable_mir::mir::CastKind::FnPtrToPtr,
|
||||
Transmute => stable_mir::mir::CastKind::Transmute,
|
||||
PointerExposeProvenance => crate::mir::CastKind::PointerExposeAddress,
|
||||
PointerWithExposedProvenance => crate::mir::CastKind::PointerWithExposedProvenance,
|
||||
PointerCoercion(c, _) => crate::mir::CastKind::PointerCoercion(c.stable(tables, cx)),
|
||||
IntToInt => crate::mir::CastKind::IntToInt,
|
||||
FloatToInt => crate::mir::CastKind::FloatToInt,
|
||||
FloatToFloat => crate::mir::CastKind::FloatToFloat,
|
||||
IntToFloat => crate::mir::CastKind::IntToFloat,
|
||||
PtrToPtr => crate::mir::CastKind::PtrToPtr,
|
||||
FnPtrToPtr => crate::mir::CastKind::FnPtrToPtr,
|
||||
Transmute => crate::mir::CastKind::Transmute,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::FakeReadCause {
|
||||
type T = stable_mir::mir::FakeReadCause;
|
||||
type T = crate::mir::FakeReadCause;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::FakeReadCause::*;
|
||||
match self {
|
||||
ForMatchGuard => stable_mir::mir::FakeReadCause::ForMatchGuard,
|
||||
ForMatchGuard => crate::mir::FakeReadCause::ForMatchGuard,
|
||||
ForMatchedPlace(local_def_id) => {
|
||||
stable_mir::mir::FakeReadCause::ForMatchedPlace(opaque(local_def_id))
|
||||
crate::mir::FakeReadCause::ForMatchedPlace(opaque(local_def_id))
|
||||
}
|
||||
ForGuardBinding => stable_mir::mir::FakeReadCause::ForGuardBinding,
|
||||
ForLet(local_def_id) => stable_mir::mir::FakeReadCause::ForLet(opaque(local_def_id)),
|
||||
ForIndex => stable_mir::mir::FakeReadCause::ForIndex,
|
||||
ForGuardBinding => crate::mir::FakeReadCause::ForGuardBinding,
|
||||
ForLet(local_def_id) => crate::mir::FakeReadCause::ForLet(opaque(local_def_id)),
|
||||
ForIndex => crate::mir::FakeReadCause::ForIndex,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Operand<'tcx> {
|
||||
type T = stable_mir::mir::Operand;
|
||||
type T = crate::mir::Operand;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -397,22 +387,22 @@ impl<'tcx> Stable<'tcx> for mir::Operand<'tcx> {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::Operand::*;
|
||||
match self {
|
||||
Copy(place) => stable_mir::mir::Operand::Copy(place.stable(tables, cx)),
|
||||
Move(place) => stable_mir::mir::Operand::Move(place.stable(tables, cx)),
|
||||
Constant(c) => stable_mir::mir::Operand::Constant(c.stable(tables, cx)),
|
||||
Copy(place) => crate::mir::Operand::Copy(place.stable(tables, cx)),
|
||||
Move(place) => crate::mir::Operand::Move(place.stable(tables, cx)),
|
||||
Constant(c) => crate::mir::Operand::Constant(c.stable(tables, cx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::ConstOperand<'tcx> {
|
||||
type T = stable_mir::mir::ConstOperand;
|
||||
type T = crate::mir::ConstOperand;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::mir::ConstOperand {
|
||||
crate::mir::ConstOperand {
|
||||
span: self.span.stable(tables, cx),
|
||||
user_ty: self.user_ty.map(|u| u.as_usize()).or(None),
|
||||
const_: self.const_.stable(tables, cx),
|
||||
@@ -421,13 +411,13 @@ impl<'tcx> Stable<'tcx> for mir::ConstOperand<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Place<'tcx> {
|
||||
type T = stable_mir::mir::Place;
|
||||
type T = crate::mir::Place;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::mir::Place {
|
||||
crate::mir::Place {
|
||||
local: self.local.as_usize(),
|
||||
projection: self.projection.iter().map(|e| e.stable(tables, cx)).collect(),
|
||||
}
|
||||
@@ -435,7 +425,7 @@ impl<'tcx> Stable<'tcx> for mir::Place<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> {
|
||||
type T = stable_mir::mir::ProjectionElem;
|
||||
type T = crate::mir::ProjectionElem;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -443,39 +433,36 @@ impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::ProjectionElem::*;
|
||||
match self {
|
||||
Deref => stable_mir::mir::ProjectionElem::Deref,
|
||||
Field(idx, ty) => stable_mir::mir::ProjectionElem::Field(
|
||||
idx.stable(tables, cx),
|
||||
ty.stable(tables, cx),
|
||||
),
|
||||
Index(local) => stable_mir::mir::ProjectionElem::Index(local.stable(tables, cx)),
|
||||
Deref => crate::mir::ProjectionElem::Deref,
|
||||
Field(idx, ty) => {
|
||||
crate::mir::ProjectionElem::Field(idx.stable(tables, cx), ty.stable(tables, cx))
|
||||
}
|
||||
Index(local) => crate::mir::ProjectionElem::Index(local.stable(tables, cx)),
|
||||
ConstantIndex { offset, min_length, from_end } => {
|
||||
stable_mir::mir::ProjectionElem::ConstantIndex {
|
||||
crate::mir::ProjectionElem::ConstantIndex {
|
||||
offset: *offset,
|
||||
min_length: *min_length,
|
||||
from_end: *from_end,
|
||||
}
|
||||
}
|
||||
Subslice { from, to, from_end } => stable_mir::mir::ProjectionElem::Subslice {
|
||||
from: *from,
|
||||
to: *to,
|
||||
from_end: *from_end,
|
||||
},
|
||||
Subslice { from, to, from_end } => {
|
||||
crate::mir::ProjectionElem::Subslice { from: *from, to: *to, from_end: *from_end }
|
||||
}
|
||||
// MIR includes an `Option<Symbol>` argument for `Downcast` that is the name of the
|
||||
// variant, used for printing MIR. However this information should also be accessible
|
||||
// via a lookup using the `VariantIdx`. The `Option<Symbol>` argument is therefore
|
||||
// dropped when converting to Stable MIR. A brief justification for this decision can be
|
||||
// found at https://github.com/rust-lang/rust/pull/117517#issuecomment-1811683486
|
||||
Downcast(_, idx) => stable_mir::mir::ProjectionElem::Downcast(idx.stable(tables, cx)),
|
||||
OpaqueCast(ty) => stable_mir::mir::ProjectionElem::OpaqueCast(ty.stable(tables, cx)),
|
||||
Subtype(ty) => stable_mir::mir::ProjectionElem::Subtype(ty.stable(tables, cx)),
|
||||
Downcast(_, idx) => crate::mir::ProjectionElem::Downcast(idx.stable(tables, cx)),
|
||||
OpaqueCast(ty) => crate::mir::ProjectionElem::OpaqueCast(ty.stable(tables, cx)),
|
||||
Subtype(ty) => crate::mir::ProjectionElem::Subtype(ty.stable(tables, cx)),
|
||||
UnwrapUnsafeBinder(..) => todo!("FIXME(unsafe_binders):"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
|
||||
type T = stable_mir::mir::UserTypeProjection;
|
||||
type T = crate::mir::UserTypeProjection;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
UserTypeProjection { base: self.base.as_usize(), projection: opaque(&self.projs) }
|
||||
@@ -483,40 +470,40 @@ impl<'tcx> Stable<'tcx> for mir::UserTypeProjection {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Local {
|
||||
type T = stable_mir::mir::Local;
|
||||
type T = crate::mir::Local;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
self.as_usize()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::RetagKind {
|
||||
type T = stable_mir::mir::RetagKind;
|
||||
type T = crate::mir::RetagKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::RetagKind;
|
||||
match self {
|
||||
RetagKind::FnEntry => stable_mir::mir::RetagKind::FnEntry,
|
||||
RetagKind::TwoPhase => stable_mir::mir::RetagKind::TwoPhase,
|
||||
RetagKind::Raw => stable_mir::mir::RetagKind::Raw,
|
||||
RetagKind::Default => stable_mir::mir::RetagKind::Default,
|
||||
RetagKind::FnEntry => crate::mir::RetagKind::FnEntry,
|
||||
RetagKind::TwoPhase => crate::mir::RetagKind::TwoPhase,
|
||||
RetagKind::Raw => crate::mir::RetagKind::Raw,
|
||||
RetagKind::Default => crate::mir::RetagKind::Default,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::UnwindAction {
|
||||
type T = stable_mir::mir::UnwindAction;
|
||||
type T = crate::mir::UnwindAction;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::UnwindAction;
|
||||
match self {
|
||||
UnwindAction::Continue => stable_mir::mir::UnwindAction::Continue,
|
||||
UnwindAction::Unreachable => stable_mir::mir::UnwindAction::Unreachable,
|
||||
UnwindAction::Terminate(_) => stable_mir::mir::UnwindAction::Terminate,
|
||||
UnwindAction::Cleanup(bb) => stable_mir::mir::UnwindAction::Cleanup(bb.as_usize()),
|
||||
UnwindAction::Continue => crate::mir::UnwindAction::Continue,
|
||||
UnwindAction::Unreachable => crate::mir::UnwindAction::Unreachable,
|
||||
UnwindAction::Terminate(_) => crate::mir::UnwindAction::Terminate,
|
||||
UnwindAction::Cleanup(bb) => crate::mir::UnwindAction::Cleanup(bb.as_usize()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::NonDivergingIntrinsic<'tcx> {
|
||||
type T = stable_mir::mir::NonDivergingIntrinsic;
|
||||
type T = crate::mir::NonDivergingIntrinsic;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -524,13 +511,14 @@ impl<'tcx> Stable<'tcx> for mir::NonDivergingIntrinsic<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::NonDivergingIntrinsic;
|
||||
use stable_mir::mir::CopyNonOverlapping;
|
||||
|
||||
use crate::mir::CopyNonOverlapping;
|
||||
match self {
|
||||
NonDivergingIntrinsic::Assume(op) => {
|
||||
stable_mir::mir::NonDivergingIntrinsic::Assume(op.stable(tables, cx))
|
||||
crate::mir::NonDivergingIntrinsic::Assume(op.stable(tables, cx))
|
||||
}
|
||||
NonDivergingIntrinsic::CopyNonOverlapping(copy_non_overlapping) => {
|
||||
stable_mir::mir::NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
|
||||
crate::mir::NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
|
||||
src: copy_non_overlapping.src.stable(tables, cx),
|
||||
dst: copy_non_overlapping.dst.stable(tables, cx),
|
||||
count: copy_non_overlapping.count.stable(tables, cx),
|
||||
@@ -541,7 +529,7 @@ impl<'tcx> Stable<'tcx> for mir::NonDivergingIntrinsic<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::AssertMessage<'tcx> {
|
||||
type T = stable_mir::mir::AssertMessage;
|
||||
type T = crate::mir::AssertMessage;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -549,98 +537,96 @@ impl<'tcx> Stable<'tcx> for mir::AssertMessage<'tcx> {
|
||||
) -> Self::T {
|
||||
use rustc_middle::mir::AssertKind;
|
||||
match self {
|
||||
AssertKind::BoundsCheck { len, index } => stable_mir::mir::AssertMessage::BoundsCheck {
|
||||
AssertKind::BoundsCheck { len, index } => crate::mir::AssertMessage::BoundsCheck {
|
||||
len: len.stable(tables, cx),
|
||||
index: index.stable(tables, cx),
|
||||
},
|
||||
AssertKind::Overflow(bin_op, op1, op2) => stable_mir::mir::AssertMessage::Overflow(
|
||||
AssertKind::Overflow(bin_op, op1, op2) => crate::mir::AssertMessage::Overflow(
|
||||
bin_op.stable(tables, cx),
|
||||
op1.stable(tables, cx),
|
||||
op2.stable(tables, cx),
|
||||
),
|
||||
AssertKind::OverflowNeg(op) => {
|
||||
stable_mir::mir::AssertMessage::OverflowNeg(op.stable(tables, cx))
|
||||
crate::mir::AssertMessage::OverflowNeg(op.stable(tables, cx))
|
||||
}
|
||||
AssertKind::DivisionByZero(op) => {
|
||||
stable_mir::mir::AssertMessage::DivisionByZero(op.stable(tables, cx))
|
||||
crate::mir::AssertMessage::DivisionByZero(op.stable(tables, cx))
|
||||
}
|
||||
AssertKind::RemainderByZero(op) => {
|
||||
stable_mir::mir::AssertMessage::RemainderByZero(op.stable(tables, cx))
|
||||
crate::mir::AssertMessage::RemainderByZero(op.stable(tables, cx))
|
||||
}
|
||||
AssertKind::ResumedAfterReturn(coroutine) => {
|
||||
stable_mir::mir::AssertMessage::ResumedAfterReturn(coroutine.stable(tables, cx))
|
||||
crate::mir::AssertMessage::ResumedAfterReturn(coroutine.stable(tables, cx))
|
||||
}
|
||||
AssertKind::ResumedAfterPanic(coroutine) => {
|
||||
stable_mir::mir::AssertMessage::ResumedAfterPanic(coroutine.stable(tables, cx))
|
||||
crate::mir::AssertMessage::ResumedAfterPanic(coroutine.stable(tables, cx))
|
||||
}
|
||||
AssertKind::ResumedAfterDrop(coroutine) => {
|
||||
stable_mir::mir::AssertMessage::ResumedAfterDrop(coroutine.stable(tables, cx))
|
||||
crate::mir::AssertMessage::ResumedAfterDrop(coroutine.stable(tables, cx))
|
||||
}
|
||||
AssertKind::MisalignedPointerDereference { required, found } => {
|
||||
stable_mir::mir::AssertMessage::MisalignedPointerDereference {
|
||||
crate::mir::AssertMessage::MisalignedPointerDereference {
|
||||
required: required.stable(tables, cx),
|
||||
found: found.stable(tables, cx),
|
||||
}
|
||||
}
|
||||
AssertKind::NullPointerDereference => {
|
||||
stable_mir::mir::AssertMessage::NullPointerDereference
|
||||
}
|
||||
AssertKind::NullPointerDereference => crate::mir::AssertMessage::NullPointerDereference,
|
||||
AssertKind::InvalidEnumConstruction(source) => {
|
||||
stable_mir::mir::AssertMessage::InvalidEnumConstruction(source.stable(tables, cx))
|
||||
crate::mir::AssertMessage::InvalidEnumConstruction(source.stable(tables, cx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::BinOp {
|
||||
type T = stable_mir::mir::BinOp;
|
||||
type T = crate::mir::BinOp;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::BinOp;
|
||||
match self {
|
||||
BinOp::Add => stable_mir::mir::BinOp::Add,
|
||||
BinOp::AddUnchecked => stable_mir::mir::BinOp::AddUnchecked,
|
||||
BinOp::Add => crate::mir::BinOp::Add,
|
||||
BinOp::AddUnchecked => crate::mir::BinOp::AddUnchecked,
|
||||
BinOp::AddWithOverflow => bug!("AddWithOverflow should have been translated already"),
|
||||
BinOp::Sub => stable_mir::mir::BinOp::Sub,
|
||||
BinOp::SubUnchecked => stable_mir::mir::BinOp::SubUnchecked,
|
||||
BinOp::Sub => crate::mir::BinOp::Sub,
|
||||
BinOp::SubUnchecked => crate::mir::BinOp::SubUnchecked,
|
||||
BinOp::SubWithOverflow => bug!("AddWithOverflow should have been translated already"),
|
||||
BinOp::Mul => stable_mir::mir::BinOp::Mul,
|
||||
BinOp::MulUnchecked => stable_mir::mir::BinOp::MulUnchecked,
|
||||
BinOp::Mul => crate::mir::BinOp::Mul,
|
||||
BinOp::MulUnchecked => crate::mir::BinOp::MulUnchecked,
|
||||
BinOp::MulWithOverflow => bug!("AddWithOverflow should have been translated already"),
|
||||
BinOp::Div => stable_mir::mir::BinOp::Div,
|
||||
BinOp::Rem => stable_mir::mir::BinOp::Rem,
|
||||
BinOp::BitXor => stable_mir::mir::BinOp::BitXor,
|
||||
BinOp::BitAnd => stable_mir::mir::BinOp::BitAnd,
|
||||
BinOp::BitOr => stable_mir::mir::BinOp::BitOr,
|
||||
BinOp::Shl => stable_mir::mir::BinOp::Shl,
|
||||
BinOp::ShlUnchecked => stable_mir::mir::BinOp::ShlUnchecked,
|
||||
BinOp::Shr => stable_mir::mir::BinOp::Shr,
|
||||
BinOp::ShrUnchecked => stable_mir::mir::BinOp::ShrUnchecked,
|
||||
BinOp::Eq => stable_mir::mir::BinOp::Eq,
|
||||
BinOp::Lt => stable_mir::mir::BinOp::Lt,
|
||||
BinOp::Le => stable_mir::mir::BinOp::Le,
|
||||
BinOp::Ne => stable_mir::mir::BinOp::Ne,
|
||||
BinOp::Ge => stable_mir::mir::BinOp::Ge,
|
||||
BinOp::Gt => stable_mir::mir::BinOp::Gt,
|
||||
BinOp::Cmp => stable_mir::mir::BinOp::Cmp,
|
||||
BinOp::Offset => stable_mir::mir::BinOp::Offset,
|
||||
BinOp::Div => crate::mir::BinOp::Div,
|
||||
BinOp::Rem => crate::mir::BinOp::Rem,
|
||||
BinOp::BitXor => crate::mir::BinOp::BitXor,
|
||||
BinOp::BitAnd => crate::mir::BinOp::BitAnd,
|
||||
BinOp::BitOr => crate::mir::BinOp::BitOr,
|
||||
BinOp::Shl => crate::mir::BinOp::Shl,
|
||||
BinOp::ShlUnchecked => crate::mir::BinOp::ShlUnchecked,
|
||||
BinOp::Shr => crate::mir::BinOp::Shr,
|
||||
BinOp::ShrUnchecked => crate::mir::BinOp::ShrUnchecked,
|
||||
BinOp::Eq => crate::mir::BinOp::Eq,
|
||||
BinOp::Lt => crate::mir::BinOp::Lt,
|
||||
BinOp::Le => crate::mir::BinOp::Le,
|
||||
BinOp::Ne => crate::mir::BinOp::Ne,
|
||||
BinOp::Ge => crate::mir::BinOp::Ge,
|
||||
BinOp::Gt => crate::mir::BinOp::Gt,
|
||||
BinOp::Cmp => crate::mir::BinOp::Cmp,
|
||||
BinOp::Offset => crate::mir::BinOp::Offset,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::UnOp {
|
||||
type T = stable_mir::mir::UnOp;
|
||||
type T = crate::mir::UnOp;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::mir::UnOp;
|
||||
match self {
|
||||
UnOp::Not => stable_mir::mir::UnOp::Not,
|
||||
UnOp::Neg => stable_mir::mir::UnOp::Neg,
|
||||
UnOp::PtrMetadata => stable_mir::mir::UnOp::PtrMetadata,
|
||||
UnOp::Not => crate::mir::UnOp::Not,
|
||||
UnOp::Neg => crate::mir::UnOp::Neg,
|
||||
UnOp::PtrMetadata => crate::mir::UnOp::PtrMetadata,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> {
|
||||
type T = stable_mir::mir::AggregateKind;
|
||||
type T = crate::mir::AggregateKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -648,11 +634,11 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> {
|
||||
) -> Self::T {
|
||||
match self {
|
||||
mir::AggregateKind::Array(ty) => {
|
||||
stable_mir::mir::AggregateKind::Array(ty.stable(tables, cx))
|
||||
crate::mir::AggregateKind::Array(ty.stable(tables, cx))
|
||||
}
|
||||
mir::AggregateKind::Tuple => stable_mir::mir::AggregateKind::Tuple,
|
||||
mir::AggregateKind::Tuple => crate::mir::AggregateKind::Tuple,
|
||||
mir::AggregateKind::Adt(def_id, var_idx, generic_arg, user_ty_index, field_idx) => {
|
||||
stable_mir::mir::AggregateKind::Adt(
|
||||
crate::mir::AggregateKind::Adt(
|
||||
tables.adt_def(*def_id),
|
||||
var_idx.stable(tables, cx),
|
||||
generic_arg.stable(tables, cx),
|
||||
@@ -660,26 +646,24 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> {
|
||||
field_idx.map(|idx| idx.index()),
|
||||
)
|
||||
}
|
||||
mir::AggregateKind::Closure(def_id, generic_arg) => {
|
||||
stable_mir::mir::AggregateKind::Closure(
|
||||
tables.closure_def(*def_id),
|
||||
generic_arg.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
mir::AggregateKind::Closure(def_id, generic_arg) => crate::mir::AggregateKind::Closure(
|
||||
tables.closure_def(*def_id),
|
||||
generic_arg.stable(tables, cx),
|
||||
),
|
||||
mir::AggregateKind::Coroutine(def_id, generic_arg) => {
|
||||
stable_mir::mir::AggregateKind::Coroutine(
|
||||
crate::mir::AggregateKind::Coroutine(
|
||||
tables.coroutine_def(*def_id),
|
||||
generic_arg.stable(tables, cx),
|
||||
cx.coroutine_movability(*def_id).stable(tables, cx),
|
||||
)
|
||||
}
|
||||
mir::AggregateKind::CoroutineClosure(def_id, generic_args) => {
|
||||
stable_mir::mir::AggregateKind::CoroutineClosure(
|
||||
crate::mir::AggregateKind::CoroutineClosure(
|
||||
tables.coroutine_closure_def(*def_id),
|
||||
generic_args.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
mir::AggregateKind::RawPtr(ty, mutability) => stable_mir::mir::AggregateKind::RawPtr(
|
||||
mir::AggregateKind::RawPtr(ty, mutability) => crate::mir::AggregateKind::RawPtr(
|
||||
ty.stable(tables, cx),
|
||||
mutability.stable(tables, cx),
|
||||
),
|
||||
@@ -688,7 +672,7 @@ impl<'tcx> Stable<'tcx> for mir::AggregateKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
|
||||
type T = stable_mir::mir::InlineAsmOperand;
|
||||
type T = crate::mir::InlineAsmOperand;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -710,18 +694,18 @@ impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
|
||||
| InlineAsmOperand::Label { .. } => (None, None),
|
||||
};
|
||||
|
||||
stable_mir::mir::InlineAsmOperand { in_value, out_place, raw_rpr: format!("{self:?}") }
|
||||
crate::mir::InlineAsmOperand { in_value, out_place, raw_rpr: format!("{self:?}") }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
|
||||
type T = stable_mir::mir::Terminator;
|
||||
type T = crate::mir::Terminator;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::mir::Terminator;
|
||||
use crate::mir::Terminator;
|
||||
Terminator {
|
||||
kind: self.kind.stable(tables, cx),
|
||||
span: self.source_info.span.stable(tables, cx),
|
||||
@@ -730,13 +714,13 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
|
||||
type T = stable_mir::mir::TerminatorKind;
|
||||
type T = crate::mir::TerminatorKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::mir::TerminatorKind;
|
||||
use crate::mir::TerminatorKind;
|
||||
match self {
|
||||
mir::TerminatorKind::Goto { target } => {
|
||||
TerminatorKind::Goto { target: target.as_usize() }
|
||||
@@ -745,7 +729,7 @@ impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
|
||||
discr: discr.stable(tables, cx),
|
||||
targets: {
|
||||
let branches = targets.iter().map(|(val, target)| (val, target.as_usize()));
|
||||
stable_mir::mir::SwitchTargets::new(
|
||||
crate::mir::SwitchTargets::new(
|
||||
branches.collect(),
|
||||
targets.otherwise().as_usize(),
|
||||
)
|
||||
@@ -830,7 +814,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::ConstAllocation<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
|
||||
type T = stable_mir::ty::Allocation;
|
||||
type T = crate::ty::Allocation;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -848,7 +832,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::Allocation {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for mir::interpret::AllocId {
|
||||
type T = stable_mir::mir::alloc::AllocId;
|
||||
type T = crate::mir::alloc::AllocId;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -885,7 +869,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::GlobalAlloc<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> {
|
||||
type T = stable_mir::ty::MirConst;
|
||||
type T = crate::ty::MirConst;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -895,17 +879,16 @@ impl<'tcx> Stable<'tcx> for rustc_middle::mir::Const<'tcx> {
|
||||
let id = tables.intern_mir_const(cx.lift(*self).unwrap());
|
||||
match *self {
|
||||
mir::Const::Ty(ty, c) => MirConst::new(
|
||||
stable_mir::ty::ConstantKind::Ty(c.stable(tables, cx)),
|
||||
crate::ty::ConstantKind::Ty(c.stable(tables, cx)),
|
||||
ty.stable(tables, cx),
|
||||
id,
|
||||
),
|
||||
mir::Const::Unevaluated(unev_const, ty) => {
|
||||
let kind =
|
||||
stable_mir::ty::ConstantKind::Unevaluated(stable_mir::ty::UnevaluatedConst {
|
||||
def: tables.const_def(unev_const.def),
|
||||
args: unev_const.args.stable(tables, cx),
|
||||
promoted: unev_const.promoted.map(|u| u.as_u32()),
|
||||
});
|
||||
let kind = crate::ty::ConstantKind::Unevaluated(crate::ty::UnevaluatedConst {
|
||||
def: tables.const_def(unev_const.def),
|
||||
args: unev_const.args.stable(tables, cx),
|
||||
promoted: unev_const.promoted.map(|u| u.as_u32()),
|
||||
});
|
||||
let ty = ty.stable(tables, cx);
|
||||
MirConst::new(kind, ty, id)
|
||||
}
|
||||
@@ -933,14 +916,14 @@ impl<'tcx> Stable<'tcx> for mir::interpret::ErrorHandled {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for MonoItem<'tcx> {
|
||||
type T = stable_mir::mir::mono::MonoItem;
|
||||
type T = crate::mir::mono::MonoItem;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::mir::mono::MonoItem as StableMonoItem;
|
||||
use crate::mir::mono::MonoItem as StableMonoItem;
|
||||
match self {
|
||||
MonoItem::Fn(instance) => StableMonoItem::Fn(instance.stable(tables, cx)),
|
||||
MonoItem::Static(def_id) => StableMonoItem::Static(tables.static_def(*def_id)),
|
||||
@@ -3,21 +3,20 @@
|
||||
use rustc_abi::FieldIdx;
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
|
||||
use super::Stable;
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
|
||||
mod abi;
|
||||
mod mir;
|
||||
mod ty;
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_hir::Safety {
|
||||
type T = stable_mir::mir::Safety;
|
||||
type T = crate::mir::Safety;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
rustc_hir::Safety::Unsafe => stable_mir::mir::Safety::Unsafe,
|
||||
rustc_hir::Safety::Safe => stable_mir::mir::Safety::Safe,
|
||||
rustc_hir::Safety::Unsafe => crate::mir::Safety::Unsafe,
|
||||
rustc_hir::Safety::Safe => crate::mir::Safety::Safe,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,19 +29,19 @@ impl<'tcx> Stable<'tcx> for FieldIdx {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineSource {
|
||||
type T = stable_mir::mir::CoroutineSource;
|
||||
type T = crate::mir::CoroutineSource;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_hir::CoroutineSource;
|
||||
match self {
|
||||
CoroutineSource::Block => stable_mir::mir::CoroutineSource::Block,
|
||||
CoroutineSource::Closure => stable_mir::mir::CoroutineSource::Closure,
|
||||
CoroutineSource::Fn => stable_mir::mir::CoroutineSource::Fn,
|
||||
CoroutineSource::Block => crate::mir::CoroutineSource::Block,
|
||||
CoroutineSource::Closure => crate::mir::CoroutineSource::Closure,
|
||||
CoroutineSource::Fn => crate::mir::CoroutineSource::Fn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
|
||||
type T = stable_mir::mir::CoroutineKind;
|
||||
type T = crate::mir::CoroutineKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -51,23 +50,23 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
|
||||
use rustc_hir::{CoroutineDesugaring, CoroutineKind};
|
||||
match *self {
|
||||
CoroutineKind::Desugared(CoroutineDesugaring::Async, source) => {
|
||||
stable_mir::mir::CoroutineKind::Desugared(
|
||||
stable_mir::mir::CoroutineDesugaring::Async,
|
||||
crate::mir::CoroutineKind::Desugared(
|
||||
crate::mir::CoroutineDesugaring::Async,
|
||||
source.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
CoroutineKind::Desugared(CoroutineDesugaring::Gen, source) => {
|
||||
stable_mir::mir::CoroutineKind::Desugared(
|
||||
stable_mir::mir::CoroutineDesugaring::Gen,
|
||||
crate::mir::CoroutineKind::Desugared(
|
||||
crate::mir::CoroutineDesugaring::Gen,
|
||||
source.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
CoroutineKind::Coroutine(movability) => {
|
||||
stable_mir::mir::CoroutineKind::Coroutine(movability.stable(tables, cx))
|
||||
crate::mir::CoroutineKind::Coroutine(movability.stable(tables, cx))
|
||||
}
|
||||
CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, source) => {
|
||||
stable_mir::mir::CoroutineKind::Desugared(
|
||||
stable_mir::mir::CoroutineDesugaring::AsyncGen,
|
||||
crate::mir::CoroutineKind::Desugared(
|
||||
crate::mir::CoroutineDesugaring::AsyncGen,
|
||||
source.stable(tables, cx),
|
||||
)
|
||||
}
|
||||
@@ -76,7 +75,7 @@ impl<'tcx> Stable<'tcx> for rustc_hir::CoroutineKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_span::Symbol {
|
||||
type T = stable_mir::Symbol;
|
||||
type T = crate::Symbol;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
self.to_string()
|
||||
@@ -84,7 +83,7 @@ impl<'tcx> Stable<'tcx> for rustc_span::Symbol {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_span::Span {
|
||||
type T = stable_mir::ty::Span;
|
||||
type T = crate::ty::Span;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -4,73 +4,69 @@ use rustc_middle::ty::Ty;
|
||||
use rustc_middle::{bug, mir, ty};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
use stable_mir::alloc;
|
||||
use stable_mir::compiler_interface::BridgeTys;
|
||||
use stable_mir::ty::{
|
||||
|
||||
use crate::alloc;
|
||||
use crate::compiler_interface::BridgeTys;
|
||||
use crate::ty::{
|
||||
AdtKind, FloatTy, GenericArgs, GenericParamDef, IntTy, Region, RigidTy, TyKind, UintTy,
|
||||
};
|
||||
use stable_mir::unstable::Stable;
|
||||
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::unstable::Stable;
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AliasTyKind {
|
||||
type T = stable_mir::ty::AliasKind;
|
||||
type T = crate::ty::AliasKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
ty::Projection => stable_mir::ty::AliasKind::Projection,
|
||||
ty::Inherent => stable_mir::ty::AliasKind::Inherent,
|
||||
ty::Opaque => stable_mir::ty::AliasKind::Opaque,
|
||||
ty::Free => stable_mir::ty::AliasKind::Free,
|
||||
ty::Projection => crate::ty::AliasKind::Projection,
|
||||
ty::Inherent => crate::ty::AliasKind::Inherent,
|
||||
ty::Opaque => crate::ty::AliasKind::Opaque,
|
||||
ty::Free => crate::ty::AliasKind::Free,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AliasTy<'tcx> {
|
||||
type T = stable_mir::ty::AliasTy;
|
||||
type T = crate::ty::AliasTy;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::AliasTy { args, def_id, .. } = self;
|
||||
stable_mir::ty::AliasTy { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) }
|
||||
crate::ty::AliasTy { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AliasTerm<'tcx> {
|
||||
type T = stable_mir::ty::AliasTerm;
|
||||
type T = crate::ty::AliasTerm;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::AliasTerm { args, def_id, .. } = self;
|
||||
stable_mir::ty::AliasTerm {
|
||||
def_id: tables.alias_def(*def_id),
|
||||
args: args.stable(tables, cx),
|
||||
}
|
||||
crate::ty::AliasTerm { def_id: tables.alias_def(*def_id), args: args.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::DynKind {
|
||||
type T = stable_mir::ty::DynKind;
|
||||
type T = crate::ty::DynKind;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
ty::Dyn => stable_mir::ty::DynKind::Dyn,
|
||||
ty::Dyn => crate::ty::DynKind::Dyn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ExistentialPredicate<'tcx> {
|
||||
type T = stable_mir::ty::ExistentialPredicate;
|
||||
type T = crate::ty::ExistentialPredicate;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::ExistentialPredicate::*;
|
||||
use crate::ty::ExistentialPredicate::*;
|
||||
match self {
|
||||
ty::ExistentialPredicate::Trait(existential_trait_ref) => {
|
||||
Trait(existential_trait_ref.stable(tables, cx))
|
||||
@@ -84,7 +80,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialPredicate<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> {
|
||||
type T = stable_mir::ty::ExistentialTraitRef;
|
||||
type T = crate::ty::ExistentialTraitRef;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -92,7 +88,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::ExistentialTraitRef { def_id, args, .. } = self;
|
||||
stable_mir::ty::ExistentialTraitRef {
|
||||
crate::ty::ExistentialTraitRef {
|
||||
def_id: tables.trait_def(*def_id),
|
||||
generic_args: args.stable(tables, cx),
|
||||
}
|
||||
@@ -100,14 +96,14 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialTraitRef<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
|
||||
type T = stable_mir::ty::TermKind;
|
||||
type T = crate::ty::TermKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::TermKind;
|
||||
use crate::ty::TermKind;
|
||||
match self {
|
||||
ty::TermKind::Ty(ty) => TermKind::Type(ty.stable(tables, cx)),
|
||||
ty::TermKind::Const(cnst) => {
|
||||
@@ -119,7 +115,7 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
|
||||
type T = stable_mir::ty::ExistentialProjection;
|
||||
type T = crate::ty::ExistentialProjection;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -127,7 +123,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::ExistentialProjection { def_id, args, term, .. } = self;
|
||||
stable_mir::ty::ExistentialProjection {
|
||||
crate::ty::ExistentialProjection {
|
||||
def_id: tables.trait_def(*def_id),
|
||||
generic_args: args.stable(tables, cx),
|
||||
term: term.kind().stable(tables, cx),
|
||||
@@ -136,7 +132,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion {
|
||||
type T = stable_mir::mir::PointerCoercion;
|
||||
type T = crate::mir::PointerCoercion;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -144,16 +140,14 @@ impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion {
|
||||
) -> Self::T {
|
||||
use rustc_middle::ty::adjustment::PointerCoercion;
|
||||
match self {
|
||||
PointerCoercion::ReifyFnPointer => stable_mir::mir::PointerCoercion::ReifyFnPointer,
|
||||
PointerCoercion::UnsafeFnPointer => stable_mir::mir::PointerCoercion::UnsafeFnPointer,
|
||||
PointerCoercion::ReifyFnPointer => crate::mir::PointerCoercion::ReifyFnPointer,
|
||||
PointerCoercion::UnsafeFnPointer => crate::mir::PointerCoercion::UnsafeFnPointer,
|
||||
PointerCoercion::ClosureFnPointer(safety) => {
|
||||
stable_mir::mir::PointerCoercion::ClosureFnPointer(safety.stable(tables, cx))
|
||||
crate::mir::PointerCoercion::ClosureFnPointer(safety.stable(tables, cx))
|
||||
}
|
||||
PointerCoercion::MutToConstPointer => {
|
||||
stable_mir::mir::PointerCoercion::MutToConstPointer
|
||||
}
|
||||
PointerCoercion::ArrayToPointer => stable_mir::mir::PointerCoercion::ArrayToPointer,
|
||||
PointerCoercion::Unsize => stable_mir::mir::PointerCoercion::Unsize,
|
||||
PointerCoercion::MutToConstPointer => crate::mir::PointerCoercion::MutToConstPointer,
|
||||
PointerCoercion::ArrayToPointer => crate::mir::PointerCoercion::ArrayToPointer,
|
||||
PointerCoercion::Unsize => crate::mir::PointerCoercion::Unsize,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,14 +172,14 @@ impl<'tcx> Stable<'tcx> for ty::AdtKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::FieldDef {
|
||||
type T = stable_mir::ty::FieldDef;
|
||||
type T = crate::ty::FieldDef;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::ty::FieldDef {
|
||||
crate::ty::FieldDef {
|
||||
def: tables.create_def_id(self.did),
|
||||
name: self.name.stable(tables, cx),
|
||||
}
|
||||
@@ -193,7 +187,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
|
||||
type T = stable_mir::ty::GenericArgs;
|
||||
type T = crate::ty::GenericArgs;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -204,14 +198,14 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
|
||||
type T = stable_mir::ty::GenericArgKind;
|
||||
type T = crate::ty::GenericArgKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::GenericArgKind;
|
||||
use crate::ty::GenericArgKind;
|
||||
match self {
|
||||
ty::GenericArgKind::Lifetime(region) => {
|
||||
GenericArgKind::Lifetime(region.stable(tables, cx))
|
||||
@@ -226,14 +220,14 @@ impl<'tcx, S, V> Stable<'tcx> for ty::Binder<'tcx, S>
|
||||
where
|
||||
S: Stable<'tcx, T = V>,
|
||||
{
|
||||
type T = stable_mir::ty::Binder<V>;
|
||||
type T = crate::ty::Binder<V>;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::Binder;
|
||||
use crate::ty::Binder;
|
||||
|
||||
Binder {
|
||||
value: self.as_ref().skip_binder().stable(tables, cx),
|
||||
@@ -250,27 +244,27 @@ impl<'tcx, S, V> Stable<'tcx> for ty::EarlyBinder<'tcx, S>
|
||||
where
|
||||
S: Stable<'tcx, T = V>,
|
||||
{
|
||||
type T = stable_mir::ty::EarlyBinder<V>;
|
||||
type T = crate::ty::EarlyBinder<V>;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::EarlyBinder;
|
||||
use crate::ty::EarlyBinder;
|
||||
|
||||
EarlyBinder { value: self.as_ref().skip_binder().stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
|
||||
type T = stable_mir::ty::FnSig;
|
||||
type T = crate::ty::FnSig;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::FnSig;
|
||||
use crate::ty::FnSig;
|
||||
|
||||
FnSig {
|
||||
inputs_and_output: self
|
||||
@@ -286,14 +280,14 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::BoundTyKind {
|
||||
type T = stable_mir::ty::BoundTyKind;
|
||||
type T = crate::ty::BoundTyKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::BoundTyKind;
|
||||
use crate::ty::BoundTyKind;
|
||||
|
||||
match self {
|
||||
ty::BoundTyKind::Anon => BoundTyKind::Anon,
|
||||
@@ -305,14 +299,14 @@ impl<'tcx> Stable<'tcx> for ty::BoundTyKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::BoundRegionKind {
|
||||
type T = stable_mir::ty::BoundRegionKind;
|
||||
type T = crate::ty::BoundRegionKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::BoundRegionKind;
|
||||
use crate::ty::BoundRegionKind;
|
||||
|
||||
match self {
|
||||
ty::BoundRegionKind::Anon => BoundRegionKind::BrAnon,
|
||||
@@ -327,14 +321,14 @@ impl<'tcx> Stable<'tcx> for ty::BoundRegionKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::BoundVariableKind {
|
||||
type T = stable_mir::ty::BoundVariableKind;
|
||||
type T = crate::ty::BoundVariableKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::BoundVariableKind;
|
||||
use crate::ty::BoundVariableKind;
|
||||
|
||||
match self {
|
||||
ty::BoundVariableKind::Ty(bound_ty_kind) => {
|
||||
@@ -392,7 +386,7 @@ impl<'tcx> Stable<'tcx> for ty::FloatTy {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for Ty<'tcx> {
|
||||
type T = stable_mir::ty::Ty;
|
||||
type T = crate::ty::Ty;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -403,7 +397,7 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
|
||||
type T = stable_mir::ty::TyKind;
|
||||
type T = crate::ty::TyKind;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
@@ -488,7 +482,7 @@ impl<'tcx> Stable<'tcx> for ty::TyKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
|
||||
type T = stable_mir::ty::Pattern;
|
||||
type T = crate::ty::Pattern;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -496,7 +490,7 @@ impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
match **self {
|
||||
ty::PatternKind::Range { start, end } => stable_mir::ty::Pattern::Range {
|
||||
ty::PatternKind::Range { start, end } => crate::ty::Pattern::Range {
|
||||
// FIXME(SMIR): update data structures to not have an Option here anymore
|
||||
start: Some(start.stable(tables, cx)),
|
||||
end: Some(end.stable(tables, cx)),
|
||||
@@ -508,7 +502,7 @@ impl<'tcx> Stable<'tcx> for ty::Pattern<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
type T = stable_mir::ty::TyConst;
|
||||
type T = crate::ty::TyConst;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -520,18 +514,16 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
ty::ConstKind::Value(cv) => {
|
||||
let const_val = cx.valtree_to_const_val(cv);
|
||||
if matches!(const_val, mir::ConstValue::ZeroSized) {
|
||||
stable_mir::ty::TyConstKind::ZSTValue(cv.ty.stable(tables, cx))
|
||||
crate::ty::TyConstKind::ZSTValue(cv.ty.stable(tables, cx))
|
||||
} else {
|
||||
stable_mir::ty::TyConstKind::Value(
|
||||
crate::ty::TyConstKind::Value(
|
||||
cv.ty.stable(tables, cx),
|
||||
alloc::new_allocation(cv.ty, const_val, tables, cx),
|
||||
)
|
||||
}
|
||||
}
|
||||
ty::ConstKind::Param(param) => {
|
||||
stable_mir::ty::TyConstKind::Param(param.stable(tables, cx))
|
||||
}
|
||||
ty::ConstKind::Unevaluated(uv) => stable_mir::ty::TyConstKind::Unevaluated(
|
||||
ty::ConstKind::Param(param) => crate::ty::TyConstKind::Param(param.stable(tables, cx)),
|
||||
ty::ConstKind::Unevaluated(uv) => crate::ty::TyConstKind::Unevaluated(
|
||||
tables.const_def(uv.def),
|
||||
uv.args.stable(tables, cx),
|
||||
),
|
||||
@@ -542,42 +534,42 @@ impl<'tcx> Stable<'tcx> for ty::Const<'tcx> {
|
||||
ty::ConstKind::Expr(_) => unimplemented!(),
|
||||
};
|
||||
let id = tables.intern_ty_const(ct);
|
||||
stable_mir::ty::TyConst::new(kind, id)
|
||||
crate::ty::TyConst::new(kind, id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ParamConst {
|
||||
type T = stable_mir::ty::ParamConst;
|
||||
type T = crate::ty::ParamConst;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use stable_mir::ty::ParamConst;
|
||||
use crate::ty::ParamConst;
|
||||
ParamConst { index: self.index, name: self.name.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ParamTy {
|
||||
type T = stable_mir::ty::ParamTy;
|
||||
type T = crate::ty::ParamTy;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use stable_mir::ty::ParamTy;
|
||||
use crate::ty::ParamTy;
|
||||
ParamTy { index: self.index, name: self.name.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::BoundTy {
|
||||
type T = stable_mir::ty::BoundTy;
|
||||
type T = crate::ty::BoundTy;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::BoundTy;
|
||||
use crate::ty::BoundTy;
|
||||
BoundTy { var: self.var.as_usize(), kind: self.kind.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::trait_def::TraitSpecializationKind {
|
||||
type T = stable_mir::ty::TraitSpecializationKind;
|
||||
type T = crate::ty::TraitSpecializationKind;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use stable_mir::ty::TraitSpecializationKind;
|
||||
use crate::ty::TraitSpecializationKind;
|
||||
|
||||
match self {
|
||||
ty::trait_def::TraitSpecializationKind::None => TraitSpecializationKind::None,
|
||||
@@ -590,14 +582,14 @@ impl<'tcx> Stable<'tcx> for ty::trait_def::TraitSpecializationKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::TraitDef {
|
||||
type T = stable_mir::ty::TraitDecl;
|
||||
type T = crate::ty::TraitDecl;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::opaque;
|
||||
use stable_mir::ty::TraitDecl;
|
||||
use crate::opaque;
|
||||
use crate::ty::TraitDecl;
|
||||
|
||||
TraitDecl {
|
||||
def_id: tables.trait_def(self.def_id),
|
||||
@@ -620,27 +612,27 @@ impl<'tcx> Stable<'tcx> for ty::TraitDef {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::TraitRef<'tcx> {
|
||||
type T = stable_mir::ty::TraitRef;
|
||||
type T = crate::ty::TraitRef;
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::TraitRef;
|
||||
use crate::ty::TraitRef;
|
||||
|
||||
TraitRef::try_new(tables.trait_def(self.def_id), self.args.stable(tables, cx)).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Generics {
|
||||
type T = stable_mir::ty::Generics;
|
||||
type T = crate::ty::Generics;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::Generics;
|
||||
use crate::ty::Generics;
|
||||
|
||||
let params: Vec<_> = self.own_params.iter().map(|param| param.stable(tables, cx)).collect();
|
||||
let param_def_id_to_index =
|
||||
@@ -661,10 +653,10 @@ impl<'tcx> Stable<'tcx> for ty::Generics {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDefKind {
|
||||
type T = stable_mir::ty::GenericParamDefKind;
|
||||
type T = crate::ty::GenericParamDefKind;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use stable_mir::ty::GenericParamDefKind;
|
||||
use crate::ty::GenericParamDefKind;
|
||||
match self {
|
||||
ty::GenericParamDefKind::Lifetime => GenericParamDefKind::Lifetime,
|
||||
ty::GenericParamDefKind::Type { has_default, synthetic } => {
|
||||
@@ -678,7 +670,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDefKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDef {
|
||||
type T = stable_mir::ty::GenericParamDef;
|
||||
type T = crate::ty::GenericParamDef;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -696,7 +688,7 @@ impl<'tcx> Stable<'tcx> for rustc_middle::ty::GenericParamDef {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
|
||||
type T = stable_mir::ty::PredicateKind;
|
||||
type T = crate::ty::PredicateKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -706,25 +698,24 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
|
||||
use rustc_middle::ty::PredicateKind;
|
||||
match self {
|
||||
PredicateKind::Clause(clause_kind) => {
|
||||
stable_mir::ty::PredicateKind::Clause(clause_kind.stable(tables, cx))
|
||||
crate::ty::PredicateKind::Clause(clause_kind.stable(tables, cx))
|
||||
}
|
||||
PredicateKind::DynCompatible(did) => {
|
||||
stable_mir::ty::PredicateKind::DynCompatible(tables.trait_def(*did))
|
||||
crate::ty::PredicateKind::DynCompatible(tables.trait_def(*did))
|
||||
}
|
||||
PredicateKind::Subtype(subtype_predicate) => {
|
||||
stable_mir::ty::PredicateKind::SubType(subtype_predicate.stable(tables, cx))
|
||||
crate::ty::PredicateKind::SubType(subtype_predicate.stable(tables, cx))
|
||||
}
|
||||
PredicateKind::Coerce(coerce_predicate) => {
|
||||
stable_mir::ty::PredicateKind::Coerce(coerce_predicate.stable(tables, cx))
|
||||
crate::ty::PredicateKind::Coerce(coerce_predicate.stable(tables, cx))
|
||||
}
|
||||
PredicateKind::ConstEquate(a, b) => stable_mir::ty::PredicateKind::ConstEquate(
|
||||
a.stable(tables, cx),
|
||||
b.stable(tables, cx),
|
||||
),
|
||||
PredicateKind::Ambiguous => stable_mir::ty::PredicateKind::Ambiguous,
|
||||
PredicateKind::ConstEquate(a, b) => {
|
||||
crate::ty::PredicateKind::ConstEquate(a.stable(tables, cx), b.stable(tables, cx))
|
||||
}
|
||||
PredicateKind::Ambiguous => crate::ty::PredicateKind::Ambiguous,
|
||||
PredicateKind::NormalizesTo(_pred) => unimplemented!(),
|
||||
PredicateKind::AliasRelate(a, b, alias_relation_direction) => {
|
||||
stable_mir::ty::PredicateKind::AliasRelate(
|
||||
crate::ty::PredicateKind::AliasRelate(
|
||||
a.kind().stable(tables, cx),
|
||||
b.kind().stable(tables, cx),
|
||||
alias_relation_direction.stable(tables, cx),
|
||||
@@ -735,7 +726,7 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
|
||||
type T = stable_mir::ty::ClauseKind;
|
||||
type T = crate::ty::ClauseKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -745,30 +736,30 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
|
||||
use rustc_middle::ty::ClauseKind;
|
||||
match *self {
|
||||
ClauseKind::Trait(trait_object) => {
|
||||
stable_mir::ty::ClauseKind::Trait(trait_object.stable(tables, cx))
|
||||
crate::ty::ClauseKind::Trait(trait_object.stable(tables, cx))
|
||||
}
|
||||
ClauseKind::RegionOutlives(region_outlives) => {
|
||||
stable_mir::ty::ClauseKind::RegionOutlives(region_outlives.stable(tables, cx))
|
||||
crate::ty::ClauseKind::RegionOutlives(region_outlives.stable(tables, cx))
|
||||
}
|
||||
ClauseKind::TypeOutlives(type_outlives) => {
|
||||
let ty::OutlivesPredicate::<_, _>(a, b) = type_outlives;
|
||||
stable_mir::ty::ClauseKind::TypeOutlives(stable_mir::ty::OutlivesPredicate(
|
||||
crate::ty::ClauseKind::TypeOutlives(crate::ty::OutlivesPredicate(
|
||||
a.stable(tables, cx),
|
||||
b.stable(tables, cx),
|
||||
))
|
||||
}
|
||||
ClauseKind::Projection(projection_predicate) => {
|
||||
stable_mir::ty::ClauseKind::Projection(projection_predicate.stable(tables, cx))
|
||||
crate::ty::ClauseKind::Projection(projection_predicate.stable(tables, cx))
|
||||
}
|
||||
ClauseKind::ConstArgHasType(const_, ty) => stable_mir::ty::ClauseKind::ConstArgHasType(
|
||||
ClauseKind::ConstArgHasType(const_, ty) => crate::ty::ClauseKind::ConstArgHasType(
|
||||
const_.stable(tables, cx),
|
||||
ty.stable(tables, cx),
|
||||
),
|
||||
ClauseKind::WellFormed(term) => {
|
||||
stable_mir::ty::ClauseKind::WellFormed(term.kind().stable(tables, cx))
|
||||
crate::ty::ClauseKind::WellFormed(term.kind().stable(tables, cx))
|
||||
}
|
||||
ClauseKind::ConstEvaluatable(const_) => {
|
||||
stable_mir::ty::ClauseKind::ConstEvaluatable(const_.stable(tables, cx))
|
||||
crate::ty::ClauseKind::ConstEvaluatable(const_.stable(tables, cx))
|
||||
}
|
||||
ClauseKind::HostEffect(..) => {
|
||||
todo!()
|
||||
@@ -778,20 +769,20 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ClosureKind {
|
||||
type T = stable_mir::ty::ClosureKind;
|
||||
type T = crate::ty::ClosureKind;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::ty::ClosureKind::*;
|
||||
match self {
|
||||
Fn => stable_mir::ty::ClosureKind::Fn,
|
||||
FnMut => stable_mir::ty::ClosureKind::FnMut,
|
||||
FnOnce => stable_mir::ty::ClosureKind::FnOnce,
|
||||
Fn => crate::ty::ClosureKind::Fn,
|
||||
FnMut => crate::ty::ClosureKind::FnMut,
|
||||
FnOnce => crate::ty::ClosureKind::FnOnce,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::SubtypePredicate<'tcx> {
|
||||
type T = stable_mir::ty::SubtypePredicate;
|
||||
type T = crate::ty::SubtypePredicate;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -799,12 +790,12 @@ impl<'tcx> Stable<'tcx> for ty::SubtypePredicate<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::SubtypePredicate { a, b, a_is_expected: _ } = self;
|
||||
stable_mir::ty::SubtypePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
|
||||
crate::ty::SubtypePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> {
|
||||
type T = stable_mir::ty::CoercePredicate;
|
||||
type T = crate::ty::CoercePredicate;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -812,24 +803,24 @@ impl<'tcx> Stable<'tcx> for ty::CoercePredicate<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::CoercePredicate { a, b } = self;
|
||||
stable_mir::ty::CoercePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
|
||||
crate::ty::CoercePredicate { a: a.stable(tables, cx), b: b.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AliasRelationDirection {
|
||||
type T = stable_mir::ty::AliasRelationDirection;
|
||||
type T = crate::ty::AliasRelationDirection;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::ty::AliasRelationDirection::*;
|
||||
match self {
|
||||
Equate => stable_mir::ty::AliasRelationDirection::Equate,
|
||||
Subtype => stable_mir::ty::AliasRelationDirection::Subtype,
|
||||
Equate => crate::ty::AliasRelationDirection::Equate,
|
||||
Subtype => crate::ty::AliasRelationDirection::Subtype,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::TraitPredicate<'tcx> {
|
||||
type T = stable_mir::ty::TraitPredicate;
|
||||
type T = crate::ty::TraitPredicate;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -837,7 +828,7 @@ impl<'tcx> Stable<'tcx> for ty::TraitPredicate<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::TraitPredicate { trait_ref, polarity } = self;
|
||||
stable_mir::ty::TraitPredicate {
|
||||
crate::ty::TraitPredicate {
|
||||
trait_ref: trait_ref.stable(tables, cx),
|
||||
polarity: polarity.stable(tables, cx),
|
||||
}
|
||||
@@ -848,7 +839,7 @@ impl<'tcx, T> Stable<'tcx> for ty::OutlivesPredicate<'tcx, T>
|
||||
where
|
||||
T: Stable<'tcx>,
|
||||
{
|
||||
type T = stable_mir::ty::OutlivesPredicate<T::T, Region>;
|
||||
type T = crate::ty::OutlivesPredicate<T::T, Region>;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -856,12 +847,12 @@ where
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::OutlivesPredicate(a, b) = self;
|
||||
stable_mir::ty::OutlivesPredicate(a.stable(tables, cx), b.stable(tables, cx))
|
||||
crate::ty::OutlivesPredicate(a.stable(tables, cx), b.stable(tables, cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
||||
type T = stable_mir::ty::ProjectionPredicate;
|
||||
type T = crate::ty::ProjectionPredicate;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -869,7 +860,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
let ty::ProjectionPredicate { projection_term, term } = self;
|
||||
stable_mir::ty::ProjectionPredicate {
|
||||
crate::ty::ProjectionPredicate {
|
||||
projection_term: projection_term.stable(tables, cx),
|
||||
term: term.kind().stable(tables, cx),
|
||||
}
|
||||
@@ -877,32 +868,32 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ImplPolarity {
|
||||
type T = stable_mir::ty::ImplPolarity;
|
||||
type T = crate::ty::ImplPolarity;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::ty::ImplPolarity::*;
|
||||
match self {
|
||||
Positive => stable_mir::ty::ImplPolarity::Positive,
|
||||
Negative => stable_mir::ty::ImplPolarity::Negative,
|
||||
Reservation => stable_mir::ty::ImplPolarity::Reservation,
|
||||
Positive => crate::ty::ImplPolarity::Positive,
|
||||
Negative => crate::ty::ImplPolarity::Negative,
|
||||
Reservation => crate::ty::ImplPolarity::Reservation,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::PredicatePolarity {
|
||||
type T = stable_mir::ty::PredicatePolarity;
|
||||
type T = crate::ty::PredicatePolarity;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_middle::ty::PredicatePolarity::*;
|
||||
match self {
|
||||
Positive => stable_mir::ty::PredicatePolarity::Positive,
|
||||
Negative => stable_mir::ty::PredicatePolarity::Negative,
|
||||
Positive => crate::ty::PredicatePolarity::Positive,
|
||||
Negative => crate::ty::PredicatePolarity::Negative,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
|
||||
type T = stable_mir::ty::Region;
|
||||
type T = crate::ty::Region;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -914,14 +905,14 @@ impl<'tcx> Stable<'tcx> for ty::Region<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
||||
type T = stable_mir::ty::RegionKind;
|
||||
type T = crate::ty::RegionKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::{BoundRegion, EarlyParamRegion, RegionKind};
|
||||
use crate::ty::{BoundRegion, EarlyParamRegion, RegionKind};
|
||||
match self {
|
||||
ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
|
||||
index: early_reg.index,
|
||||
@@ -935,15 +926,13 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
||||
},
|
||||
),
|
||||
ty::ReStatic => RegionKind::ReStatic,
|
||||
ty::RePlaceholder(place_holder) => {
|
||||
RegionKind::RePlaceholder(stable_mir::ty::Placeholder {
|
||||
universe: place_holder.universe.as_u32(),
|
||||
bound: BoundRegion {
|
||||
var: place_holder.bound.var.as_u32(),
|
||||
kind: place_holder.bound.kind.stable(tables, cx),
|
||||
},
|
||||
})
|
||||
}
|
||||
ty::RePlaceholder(place_holder) => RegionKind::RePlaceholder(crate::ty::Placeholder {
|
||||
universe: place_holder.universe.as_u32(),
|
||||
bound: BoundRegion {
|
||||
var: place_holder.bound.var.as_u32(),
|
||||
kind: place_holder.bound.kind.stable(tables, cx),
|
||||
},
|
||||
}),
|
||||
ty::ReErased => RegionKind::ReErased,
|
||||
_ => unreachable!("{self:?}"),
|
||||
}
|
||||
@@ -951,7 +940,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> {
|
||||
type T = stable_mir::mir::mono::Instance;
|
||||
type T = crate::mir::mono::Instance;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
@@ -960,10 +949,10 @@ impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> {
|
||||
) -> Self::T {
|
||||
let def = tables.instance_def(cx.lift(*self).unwrap());
|
||||
let kind = match self.def {
|
||||
ty::InstanceKind::Item(..) => stable_mir::mir::mono::InstanceKind::Item,
|
||||
ty::InstanceKind::Intrinsic(..) => stable_mir::mir::mono::InstanceKind::Intrinsic,
|
||||
ty::InstanceKind::Item(..) => crate::mir::mono::InstanceKind::Item,
|
||||
ty::InstanceKind::Intrinsic(..) => crate::mir::mono::InstanceKind::Intrinsic,
|
||||
ty::InstanceKind::Virtual(_def_id, idx) => {
|
||||
stable_mir::mir::mono::InstanceKind::Virtual { idx }
|
||||
crate::mir::mono::InstanceKind::Virtual { idx }
|
||||
}
|
||||
ty::InstanceKind::VTableShim(..)
|
||||
| ty::InstanceKind::ReifyShim(..)
|
||||
@@ -976,43 +965,42 @@ impl<'tcx> Stable<'tcx> for ty::Instance<'tcx> {
|
||||
| ty::InstanceKind::FnPtrShim(..)
|
||||
| ty::InstanceKind::FutureDropPollShim(..)
|
||||
| ty::InstanceKind::AsyncDropGlue(..)
|
||||
| ty::InstanceKind::AsyncDropGlueCtorShim(..) => {
|
||||
stable_mir::mir::mono::InstanceKind::Shim
|
||||
}
|
||||
| ty::InstanceKind::AsyncDropGlueCtorShim(..) => crate::mir::mono::InstanceKind::Shim,
|
||||
};
|
||||
stable_mir::mir::mono::Instance { def, kind }
|
||||
crate::mir::mono::Instance { def, kind }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Variance {
|
||||
type T = stable_mir::mir::Variance;
|
||||
type T = crate::mir::Variance;
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
ty::Bivariant => stable_mir::mir::Variance::Bivariant,
|
||||
ty::Contravariant => stable_mir::mir::Variance::Contravariant,
|
||||
ty::Covariant => stable_mir::mir::Variance::Covariant,
|
||||
ty::Invariant => stable_mir::mir::Variance::Invariant,
|
||||
ty::Bivariant => crate::mir::Variance::Bivariant,
|
||||
ty::Contravariant => crate::mir::Variance::Contravariant,
|
||||
ty::Covariant => crate::mir::Variance::Covariant,
|
||||
ty::Invariant => crate::mir::Variance::Invariant,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::Movability {
|
||||
type T = stable_mir::ty::Movability;
|
||||
type T = crate::ty::Movability;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
match self {
|
||||
ty::Movability::Static => stable_mir::ty::Movability::Static,
|
||||
ty::Movability::Movable => stable_mir::ty::Movability::Movable,
|
||||
ty::Movability::Static => crate::ty::Movability::Static,
|
||||
ty::Movability::Movable => crate::ty::Movability::Movable,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi {
|
||||
type T = stable_mir::ty::Abi;
|
||||
type T = crate::ty::Abi;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use rustc_abi::ExternAbi;
|
||||
use stable_mir::ty::Abi;
|
||||
|
||||
use crate::ty::Abi;
|
||||
match *self {
|
||||
ExternAbi::Rust => Abi::Rust,
|
||||
ExternAbi::C { unwind } => Abi::C { unwind },
|
||||
@@ -1046,14 +1034,14 @@ impl<'tcx> Stable<'tcx> for rustc_abi::ExternAbi {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_session::cstore::ForeignModule {
|
||||
type T = stable_mir::ty::ForeignModule;
|
||||
type T = crate::ty::ForeignModule;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::ty::ForeignModule {
|
||||
crate::ty::ForeignModule {
|
||||
def_id: tables.foreign_module_def(self.def_id),
|
||||
abi: self.abi.stable(tables, cx),
|
||||
}
|
||||
@@ -1061,14 +1049,14 @@ impl<'tcx> Stable<'tcx> for rustc_session::cstore::ForeignModule {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AssocKind {
|
||||
type T = stable_mir::ty::AssocKind;
|
||||
type T = crate::ty::AssocKind;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::{AssocKind, AssocTypeData};
|
||||
use crate::ty::{AssocKind, AssocTypeData};
|
||||
match *self {
|
||||
ty::AssocKind::Const { name } => AssocKind::Const { name: name.to_string() },
|
||||
ty::AssocKind::Fn { name, has_self } => {
|
||||
@@ -1087,10 +1075,10 @@ impl<'tcx> Stable<'tcx> for ty::AssocKind {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AssocItemContainer {
|
||||
type T = stable_mir::ty::AssocItemContainer;
|
||||
type T = crate::ty::AssocItemContainer;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &SmirCtxt<'_, BridgeTys>) -> Self::T {
|
||||
use stable_mir::ty::AssocItemContainer;
|
||||
use crate::ty::AssocItemContainer;
|
||||
match self {
|
||||
ty::AssocItemContainer::Trait => AssocItemContainer::Trait,
|
||||
ty::AssocItemContainer::Impl => AssocItemContainer::Impl,
|
||||
@@ -1099,14 +1087,14 @@ impl<'tcx> Stable<'tcx> for ty::AssocItemContainer {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::AssocItem {
|
||||
type T = stable_mir::ty::AssocItem;
|
||||
type T = crate::ty::AssocItem;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::ty::AssocItem {
|
||||
crate::ty::AssocItem {
|
||||
def_id: tables.assoc_def(self.def_id),
|
||||
kind: self.kind.stable(tables, cx),
|
||||
container: self.container.stable(tables, cx),
|
||||
@@ -1116,14 +1104,14 @@ impl<'tcx> Stable<'tcx> for ty::AssocItem {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for ty::ImplTraitInTraitData {
|
||||
type T = stable_mir::ty::ImplTraitInTraitData;
|
||||
type T = crate::ty::ImplTraitInTraitData;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
_: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
use stable_mir::ty::ImplTraitInTraitData;
|
||||
use crate::ty::ImplTraitInTraitData;
|
||||
match self {
|
||||
ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id } => {
|
||||
ImplTraitInTraitData::Trait {
|
||||
@@ -1139,13 +1127,13 @@ impl<'tcx> Stable<'tcx> for ty::ImplTraitInTraitData {
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for rustc_middle::ty::util::Discr<'tcx> {
|
||||
type T = stable_mir::ty::Discr;
|
||||
type T = crate::ty::Discr;
|
||||
|
||||
fn stable<'cx>(
|
||||
&self,
|
||||
tables: &mut Tables<'cx, BridgeTys>,
|
||||
cx: &SmirCtxt<'cx, BridgeTys>,
|
||||
) -> Self::T {
|
||||
stable_mir::ty::Discr { val: self.val, ty: self.ty.stable(tables, cx) }
|
||||
crate::ty::Discr { val: self.val, ty: self.ty.stable(tables, cx) }
|
||||
}
|
||||
}
|
||||
93
compiler/stable_mir/src/unstable/internal_cx/mod.rs
Normal file
93
compiler/stable_mir/src/unstable/internal_cx/mod.rs
Normal file
@@ -0,0 +1,93 @@
|
||||
//! Implementation of InternalCx.
|
||||
|
||||
use rustc_middle::ty::{List, Ty, TyCtxt};
|
||||
use rustc_middle::{mir, ty};
|
||||
pub(crate) use traits::*;
|
||||
|
||||
use super::InternalCx;
|
||||
|
||||
pub(crate) mod traits;
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirExistentialProjection<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
term: ty::Term<'tcx>,
|
||||
) -> ty::ExistentialProjection<'tcx> {
|
||||
ty::ExistentialProjection::new_from_args(self.tcx(), def_id, args, term)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirExistentialTraitRef<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::ExistentialTraitRef<'tcx> {
|
||||
ty::ExistentialTraitRef::new_from_args(self.tcx(), trait_def_id, args)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirTraitRef<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx> {
|
||||
ty::TraitRef::new_from_args(self.tcx(), trait_def_id, args)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> InternalCx<'tcx> for TyCtxt<'tcx> {
|
||||
fn tcx(self) -> TyCtxt<'tcx> {
|
||||
self
|
||||
}
|
||||
|
||||
fn lift<T: ty::Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
|
||||
TyCtxt::lift(self, value)
|
||||
}
|
||||
|
||||
fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: ty::CollectAndApply<ty::GenericArg<'tcx>, ty::GenericArgsRef<'tcx>>,
|
||||
{
|
||||
TyCtxt::mk_args_from_iter(self, iter)
|
||||
}
|
||||
|
||||
fn mk_pat(self, v: ty::PatternKind<'tcx>) -> ty::Pattern<'tcx> {
|
||||
TyCtxt::mk_pat(self, v)
|
||||
}
|
||||
|
||||
fn mk_poly_existential_predicates(
|
||||
self,
|
||||
eps: &[ty::PolyExistentialPredicate<'tcx>],
|
||||
) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
|
||||
TyCtxt::mk_poly_existential_predicates(self, eps)
|
||||
}
|
||||
|
||||
fn mk_type_list(self, v: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
|
||||
TyCtxt::mk_type_list(self, v)
|
||||
}
|
||||
|
||||
fn lifetimes_re_erased(self) -> ty::Region<'tcx> {
|
||||
self.lifetimes.re_erased
|
||||
}
|
||||
|
||||
fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: ty::CollectAndApply<ty::BoundVariableKind, &'tcx List<ty::BoundVariableKind>>,
|
||||
{
|
||||
TyCtxt::mk_bound_variable_kinds_from_iter(self, iter)
|
||||
}
|
||||
|
||||
fn mk_place_elems(self, v: &[mir::PlaceElem<'tcx>]) -> &'tcx List<mir::PlaceElem<'tcx>> {
|
||||
TyCtxt::mk_place_elems(self, v)
|
||||
}
|
||||
|
||||
fn adt_def(self, def_id: rustc_hir::def_id::DefId) -> ty::AdtDef<'tcx> {
|
||||
self.adt_def(def_id)
|
||||
}
|
||||
}
|
||||
31
compiler/stable_mir/src/unstable/internal_cx/traits.rs
Normal file
31
compiler/stable_mir/src/unstable/internal_cx/traits.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
//! A set of traits that define a stable interface to rustc's internals.
|
||||
//!
|
||||
//! These traits are primarily used to clarify the behavior of different
|
||||
//! functions that share the same name across various contexts.
|
||||
|
||||
use rustc_middle::ty;
|
||||
|
||||
pub(crate) trait SmirExistentialProjection<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
term: ty::Term<'tcx>,
|
||||
) -> ty::ExistentialProjection<'tcx>;
|
||||
}
|
||||
|
||||
pub(crate) trait SmirExistentialTraitRef<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::ExistentialTraitRef<'tcx>;
|
||||
}
|
||||
|
||||
pub(crate) trait SmirTraitRef<'tcx> {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx>;
|
||||
}
|
||||
@@ -10,104 +10,18 @@ use rustc_hir::def::DefKind;
|
||||
use rustc_middle::ty::{List, Ty, TyCtxt};
|
||||
use rustc_middle::{mir, ty};
|
||||
use rustc_smir::Tables;
|
||||
use rustc_smir::context::{
|
||||
SmirCtxt, SmirExistentialProjection, SmirExistentialTraitRef, SmirTraitRef,
|
||||
};
|
||||
use stable_mir::{CtorKind, ItemKind};
|
||||
use rustc_smir::context::SmirCtxt;
|
||||
|
||||
use super::compiler_interface::BridgeTys;
|
||||
use crate::{rustc_smir, stable_mir};
|
||||
use crate::{CtorKind, ItemKind};
|
||||
|
||||
pub(crate) mod convert;
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirExistentialProjection<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
term: ty::Term<'tcx>,
|
||||
) -> ty::ExistentialProjection<'tcx> {
|
||||
ty::ExistentialProjection::new_from_args(self.tcx(), def_id, args, term)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirExistentialTraitRef<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::ExistentialTraitRef<'tcx> {
|
||||
ty::ExistentialTraitRef::new_from_args(self.tcx(), trait_def_id, args)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: InternalCx<'tcx>> SmirTraitRef<'tcx> for T {
|
||||
fn new_from_args(
|
||||
&self,
|
||||
trait_def_id: rustc_span::def_id::DefId,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx> {
|
||||
ty::TraitRef::new_from_args(self.tcx(), trait_def_id, args)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> InternalCx<'tcx> for TyCtxt<'tcx> {
|
||||
fn tcx(self) -> TyCtxt<'tcx> {
|
||||
self
|
||||
}
|
||||
|
||||
fn lift<T: ty::Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
|
||||
TyCtxt::lift(self, value)
|
||||
}
|
||||
|
||||
fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: ty::CollectAndApply<ty::GenericArg<'tcx>, ty::GenericArgsRef<'tcx>>,
|
||||
{
|
||||
TyCtxt::mk_args_from_iter(self, iter)
|
||||
}
|
||||
|
||||
fn mk_pat(self, v: ty::PatternKind<'tcx>) -> ty::Pattern<'tcx> {
|
||||
TyCtxt::mk_pat(self, v)
|
||||
}
|
||||
|
||||
fn mk_poly_existential_predicates(
|
||||
self,
|
||||
eps: &[ty::PolyExistentialPredicate<'tcx>],
|
||||
) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
|
||||
TyCtxt::mk_poly_existential_predicates(self, eps)
|
||||
}
|
||||
|
||||
fn mk_type_list(self, v: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
|
||||
TyCtxt::mk_type_list(self, v)
|
||||
}
|
||||
|
||||
fn lifetimes_re_erased(self) -> ty::Region<'tcx> {
|
||||
self.lifetimes.re_erased
|
||||
}
|
||||
|
||||
fn mk_bound_variable_kinds_from_iter<I, T>(self, iter: I) -> T::Output
|
||||
where
|
||||
I: Iterator<Item = T>,
|
||||
T: ty::CollectAndApply<ty::BoundVariableKind, &'tcx List<ty::BoundVariableKind>>,
|
||||
{
|
||||
TyCtxt::mk_bound_variable_kinds_from_iter(self, iter)
|
||||
}
|
||||
|
||||
fn mk_place_elems(self, v: &[mir::PlaceElem<'tcx>]) -> &'tcx List<mir::PlaceElem<'tcx>> {
|
||||
TyCtxt::mk_place_elems(self, v)
|
||||
}
|
||||
|
||||
fn adt_def(self, def_id: rustc_hir::def_id::DefId) -> ty::AdtDef<'tcx> {
|
||||
self.adt_def(def_id)
|
||||
}
|
||||
}
|
||||
mod internal_cx;
|
||||
|
||||
/// Trait that defines the methods that are fine to call from [`RustcInternal`].
|
||||
///
|
||||
/// This trait is only for [`RustcInternal`]. Any other other access to rustc's internals
|
||||
/// should go through [`crate::rustc_smir::context::SmirCtxt`].
|
||||
/// should go through [`rustc_smir::context::SmirCtxt`].
|
||||
pub trait InternalCx<'tcx>: Copy + Clone {
|
||||
fn tcx(self) -> TyCtxt<'tcx>;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use stable_mir::Opaque;
|
||||
use stable_mir::ty::TyConst;
|
||||
|
||||
use super::ty::{
|
||||
Allocation, Binder, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
||||
MirConst, Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||
};
|
||||
use crate::stable_mir;
|
||||
use crate::Opaque;
|
||||
use crate::ty::TyConst;
|
||||
|
||||
pub trait Visitor: Sized {
|
||||
type Break;
|
||||
@@ -111,6 +111,15 @@ impl_zeroable_primitive!(
|
||||
/// ```
|
||||
///
|
||||
/// [null pointer optimization]: crate::option#representation
|
||||
///
|
||||
/// # Note on generic usage
|
||||
///
|
||||
/// `NonZero<T>` can only be used with some standard library primitive types
|
||||
/// (such as `u8`, `i32`, and etc.). The type parameter `T` must implement the
|
||||
/// internal trait [`ZeroablePrimitive`], which is currently permanently unstable
|
||||
/// and cannot be implemented by users. Therefore, you cannot use `NonZero<T>`
|
||||
/// with your own types, nor can you implement traits for all `NonZero<T>`,
|
||||
/// only for concrete types.
|
||||
#[stable(feature = "generic_nonzero", since = "1.79.0")]
|
||||
#[repr(transparent)]
|
||||
#[rustc_nonnull_optimization_guaranteed]
|
||||
|
||||
@@ -1244,7 +1244,7 @@ impl PathBuf {
|
||||
///
|
||||
/// The caller has free choice over the returned lifetime, including 'static.
|
||||
/// Indeed, this function is ideally used for data that lives for the remainder of
|
||||
/// the program’s life, as dropping the returned reference will cause a memory leak.
|
||||
/// the program's life, as dropping the returned reference will cause a memory leak.
|
||||
///
|
||||
/// It does not reallocate or shrink the `PathBuf`, so the leaked allocation may include
|
||||
/// unused capacity that is not part of the returned slice. If you want to discard excess
|
||||
@@ -3028,7 +3028,7 @@ impl Path {
|
||||
///
|
||||
/// This function always resolves `..` to the "lexical" parent.
|
||||
/// That is "a/b/../c" will always resolve to `a/c` which can change the meaning of the path.
|
||||
/// In particular, `a/c` and `a/b/../c` are distinct on many systems because `b` may be a symbolic link, so its parent isn’t `a`.
|
||||
/// In particular, `a/c` and `a/b/../c` are distinct on many systems because `b` may be a symbolic link, so its parent isn't `a`.
|
||||
///
|
||||
/// </div>
|
||||
///
|
||||
|
||||
@@ -12,7 +12,8 @@ lto = "off"
|
||||
#
|
||||
# If compiler-affecting directories are not modified, use precompiled rustc to speed up
|
||||
# library development by skipping compiler builds.
|
||||
download-rustc = "if-unchanged"
|
||||
# FIXME: download-rustc is currently broken: https://github.com/rust-lang/rust/issues/142505
|
||||
download-rustc = false
|
||||
|
||||
[llvm]
|
||||
# Will download LLVM from CI if available on your platform.
|
||||
|
||||
@@ -456,4 +456,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
|
||||
severity: ChangeSeverity::Warning,
|
||||
summary: "The default check stage has been changed to 1. It is no longer possible to `x check` with stage 0. All check commands have to be on stage 1+. Bootstrap tools can now also only be checked for the host target.",
|
||||
},
|
||||
ChangeInfo {
|
||||
change_id: 143577,
|
||||
severity: ChangeSeverity::Warning,
|
||||
summary: "`download-rustc` has been temporarily disabled for the library profile due to implementation bugs (see #142505).",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -15,19 +15,15 @@ COPY scripts/crosstool-ng-build.sh /scripts/
|
||||
COPY host-x86_64/dist-powerpc64le-linux-gnu/powerpc64le-unknown-linux-gnu.defconfig /tmp/crosstool.defconfig
|
||||
RUN /scripts/crosstool-ng-build.sh
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN apt-get install -y --no-install-recommends rpm2cpio cpio
|
||||
COPY scripts/shared.sh scripts/build-powerpc64le-toolchain.sh /build/
|
||||
RUN ./build-powerpc64le-toolchain.sh
|
||||
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
ENV PATH=$PATH:/x-tools/powerpc64le-unknown-linux-gnu/bin
|
||||
|
||||
ENV \
|
||||
AR_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-ar \
|
||||
CC_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-gcc \
|
||||
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-linux-gnu-g++
|
||||
AR_powerpc64le_unknown_linux_gnu=powerpc64le-unknown-linux-gnu-ar \
|
||||
CC_powerpc64le_unknown_linux_gnu=powerpc64le-unknown-linux-gnu-gcc \
|
||||
CXX_powerpc64le_unknown_linux_gnu=powerpc64le-unknown-linux-gnu-g++
|
||||
|
||||
ENV HOSTS=powerpc64le-unknown-linux-gnu
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ CT_ARCH_64=y
|
||||
# CT_DEMULTILIB is not set
|
||||
CT_ARCH_ARCH="powerpc64le"
|
||||
CT_KERNEL_LINUX=y
|
||||
CT_LINUX_V_4_19=y
|
||||
CT_LINUX_V_3_10=y
|
||||
CT_GLIBC_V_2_17=y
|
||||
CT_CC_LANG_CXX=y
|
||||
CT_GETTEXT_NEEDED=y
|
||||
|
||||
@@ -15,12 +15,6 @@ COPY scripts/crosstool-ng-build.sh /scripts/
|
||||
COPY host-x86_64/dist-powerpc64le-linux-musl/powerpc64le-unknown-linux-musl.defconfig /tmp/crosstool.defconfig
|
||||
RUN /scripts/crosstool-ng-build.sh
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN apt-get install -y --no-install-recommends rpm2cpio cpio
|
||||
COPY scripts/shared.sh scripts/build-powerpc64le-toolchain.sh /build/
|
||||
RUN ./build-powerpc64le-toolchain.sh
|
||||
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
source shared.sh
|
||||
|
||||
BINUTILS=2.32
|
||||
GCC=8.3.0
|
||||
TARGET=powerpc64le-linux-gnu
|
||||
SYSROOT=/usr/local/$TARGET/sysroot
|
||||
|
||||
# First, download the CentOS7 glibc.ppc64le and relevant header files.
|
||||
# (upstream ppc64le support wasn't added until 2.19, which el7 backported.)
|
||||
mkdir -p $SYSROOT
|
||||
pushd $SYSROOT
|
||||
|
||||
# centos_base=http://vault.centos.org/altarch/7.3.1611/os/ppc64le/Packages/
|
||||
# Mirrored from centos_base above
|
||||
centos_base=https://ci-mirrors.rust-lang.org/rustc
|
||||
glibc_v=2.17-157-2020-11-25.el7
|
||||
kernel_v=3.10.0-514-2020-11-25.el7
|
||||
for package in glibc{,-devel,-headers}-$glibc_v kernel-headers-$kernel_v; do
|
||||
curl $centos_base/$package.ppc64le.rpm | \
|
||||
rpm2cpio - | cpio -idm
|
||||
done
|
||||
|
||||
ln -sT lib64 lib
|
||||
ln -sT lib64 usr/lib
|
||||
|
||||
popd
|
||||
|
||||
# Next, download and build binutils.
|
||||
mkdir binutils-$TARGET
|
||||
pushd binutils-$TARGET
|
||||
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf -
|
||||
mkdir binutils-build
|
||||
cd binutils-build
|
||||
hide_output ../binutils-$BINUTILS/configure --target=$TARGET --with-sysroot=$SYSROOT
|
||||
hide_output make -j10
|
||||
hide_output make install
|
||||
popd
|
||||
rm -rf binutils-$TARGET
|
||||
|
||||
# Finally, download and build gcc.
|
||||
mkdir gcc-$TARGET
|
||||
pushd gcc-$TARGET
|
||||
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | tar xJf -
|
||||
cd gcc-$GCC
|
||||
hide_output ./contrib/download_prerequisites
|
||||
|
||||
mkdir ../gcc-build
|
||||
cd ../gcc-build
|
||||
hide_output ../gcc-$GCC/configure \
|
||||
--enable-languages=c,c++ \
|
||||
--target=$TARGET \
|
||||
--with-cpu=power8 \
|
||||
--with-sysroot=$SYSROOT \
|
||||
--disable-libcilkrts \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-libgomp \
|
||||
--disable-libquadmath \
|
||||
--disable-libssp \
|
||||
--disable-libvtv \
|
||||
--disable-libcilkrt \
|
||||
--disable-libada \
|
||||
--disable-libsanitizer \
|
||||
--disable-libquadmath-support \
|
||||
--disable-lto
|
||||
hide_output hide_output make -j10
|
||||
hide_output make install
|
||||
|
||||
popd
|
||||
rm -rf gcc-$TARGET
|
||||
@@ -894,7 +894,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
start_abi,
|
||||
&[func_arg],
|
||||
Some(&ret_place),
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
|
||||
// Restore the old active thread frame.
|
||||
|
||||
@@ -436,7 +436,7 @@ pub fn create_ecx<'tcx>(
|
||||
ImmTy::from_uint(sigpipe, ecx.machine.layouts.u8),
|
||||
],
|
||||
Some(&ret_place),
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
}
|
||||
MiriEntryFnType::MiriStart => {
|
||||
@@ -445,7 +445,7 @@ pub fn create_ecx<'tcx>(
|
||||
ExternAbi::Rust,
|
||||
&[argc, argv],
|
||||
Some(&ret_place),
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
caller_abi: ExternAbi,
|
||||
args: &[ImmTy<'tcx>],
|
||||
dest: Option<&MPlaceTy<'tcx>>,
|
||||
stack_pop: StackPopCleanup,
|
||||
cont: ReturnContinuation,
|
||||
) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
|
||||
@@ -472,7 +472,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
&args.iter().map(|a| FnArg::Copy(a.clone().into())).collect::<Vec<_>>(),
|
||||
/*with_caller_location*/ false,
|
||||
&dest.into(),
|
||||
stack_pop,
|
||||
cont,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1199,7 +1199,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
|
||||
ReturnContinuation::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
|
||||
)?;
|
||||
interp_ok(())
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
&[data.clone()],
|
||||
None,
|
||||
// Directly return to caller.
|
||||
StackPopCleanup::Goto { ret, unwind: mir::UnwindAction::Continue },
|
||||
ReturnContinuation::Goto { ret, unwind: mir::UnwindAction::Continue },
|
||||
)?;
|
||||
|
||||
// We ourselves will return `0`, eventually (will be overwritten if we catch a panic).
|
||||
@@ -143,7 +143,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
&[catch_unwind.data, payload],
|
||||
None,
|
||||
// Directly return to caller of `catch_unwind`.
|
||||
StackPopCleanup::Goto {
|
||||
ReturnContinuation::Goto {
|
||||
ret: catch_unwind.ret,
|
||||
// `catch_fn` must not unwind.
|
||||
unwind: mir::UnwindAction::Unreachable,
|
||||
@@ -172,7 +172,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[this.mplace_to_ref(&msg)?],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind },
|
||||
ReturnContinuation::Goto { ret: None, unwind },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[this.mplace_to_ref(&msg)?],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
|
||||
ReturnContinuation::Goto { ret: None, unwind: mir::UnwindAction::Unreachable },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[index, len],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind },
|
||||
ReturnContinuation::Goto { ret: None, unwind },
|
||||
)?;
|
||||
}
|
||||
MisalignedPointerDereference { required, found } => {
|
||||
@@ -241,7 +241,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[required, found],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind },
|
||||
ReturnContinuation::Goto { ret: None, unwind },
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::Rust,
|
||||
&[],
|
||||
None,
|
||||
StackPopCleanup::Goto { ret: None, unwind },
|
||||
ReturnContinuation::Goto { ret: None, unwind },
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::System { unwind: false },
|
||||
&[null_ptr.clone(), ImmTy::from_scalar(reason, this.machine.layouts.u32), null_ptr],
|
||||
None,
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
interp_ok(())
|
||||
}
|
||||
@@ -346,7 +346,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::C { unwind: false },
|
||||
&[ImmTy::from_scalar(data, this.machine.layouts.mut_raw_ptr)],
|
||||
None,
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
|
||||
return interp_ok(Poll::Pending);
|
||||
@@ -383,7 +383,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
||||
ExternAbi::C { unwind: false },
|
||||
&[ImmTy::from_scalar(ptr, this.machine.layouts.mut_raw_ptr)],
|
||||
None,
|
||||
StackPopCleanup::Root { cleanup: true },
|
||||
ReturnContinuation::Stop { cleanup: true },
|
||||
)?;
|
||||
|
||||
return interp_ok(Poll::Pending);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
- // MIR for `Trait::a` before Inline
|
||||
+ // MIR for `Trait::a` after Inline
|
||||
|
||||
fn Trait::a(_1: &Self) -> () {
|
||||
debug self => _1;
|
||||
let mut _0: ();
|
||||
let _2: ();
|
||||
let mut _3: &();
|
||||
let _4: ();
|
||||
let mut _5: &();
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
StorageLive(_3);
|
||||
_5 = const <Self as Trait>::a::promoted[0];
|
||||
_3 = &(*_5);
|
||||
_2 = <() as Trait>::b(move _3) -> [return: bb1, unwind unreachable];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
_0 = const ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
- // MIR for `Trait::a` before Inline
|
||||
+ // MIR for `Trait::a` after Inline
|
||||
|
||||
fn Trait::a(_1: &Self) -> () {
|
||||
debug self => _1;
|
||||
let mut _0: ();
|
||||
let _2: ();
|
||||
let mut _3: &();
|
||||
let _4: ();
|
||||
let mut _5: &();
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
StorageLive(_3);
|
||||
_5 = const <Self as Trait>::a::promoted[0];
|
||||
_3 = &(*_5);
|
||||
_2 = <() as Trait>::b(move _3) -> [return: bb1, unwind continue];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
_0 = const ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
- // MIR for `Trait::b` before Inline
|
||||
+ // MIR for `Trait::b` after Inline
|
||||
|
||||
fn Trait::b(_1: &Self) -> () {
|
||||
debug self => _1;
|
||||
let mut _0: ();
|
||||
let _2: ();
|
||||
let mut _3: &();
|
||||
let _4: ();
|
||||
let mut _5: &();
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
StorageLive(_3);
|
||||
_5 = const <Self as Trait>::b::promoted[0];
|
||||
_3 = &(*_5);
|
||||
_2 = <() as Trait>::a(move _3) -> [return: bb1, unwind unreachable];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
_0 = const ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
- // MIR for `Trait::b` before Inline
|
||||
+ // MIR for `Trait::b` after Inline
|
||||
|
||||
fn Trait::b(_1: &Self) -> () {
|
||||
debug self => _1;
|
||||
let mut _0: ();
|
||||
let _2: ();
|
||||
let mut _3: &();
|
||||
let _4: ();
|
||||
let mut _5: &();
|
||||
|
||||
bb0: {
|
||||
StorageLive(_2);
|
||||
StorageLive(_3);
|
||||
_5 = const <Self as Trait>::b::promoted[0];
|
||||
_3 = &(*_5);
|
||||
_2 = <() as Trait>::a(move _3) -> [return: bb1, unwind continue];
|
||||
}
|
||||
|
||||
bb1: {
|
||||
StorageDead(_3);
|
||||
StorageDead(_2);
|
||||
_0 = const ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
19
tests/mir-opt/inline_default_trait_body.rs
Normal file
19
tests/mir-opt/inline_default_trait_body.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
||||
// skip-filecheck
|
||||
//@ test-mir-pass: Inline
|
||||
//@ edition: 2021
|
||||
//@ compile-flags: -Zinline-mir --crate-type=lib
|
||||
|
||||
// EMIT_MIR inline_default_trait_body.Trait-a.Inline.diff
|
||||
// EMIT_MIR inline_default_trait_body.Trait-b.Inline.diff
|
||||
pub trait Trait {
|
||||
fn a(&self) {
|
||||
().b();
|
||||
}
|
||||
|
||||
fn b(&self) {
|
||||
().a();
|
||||
}
|
||||
}
|
||||
|
||||
impl Trait for () {}
|
||||
2
tests/run-make/linker-warning/bar.rs
Normal file
2
tests/run-make/linker-warning/bar.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
#[repr(C)]
|
||||
pub struct Bar(u32);
|
||||
2
tests/run-make/linker-warning/foo.rs
Normal file
2
tests/run-make/linker-warning/foo.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
#[repr(C)]
|
||||
pub struct Foo(u32);
|
||||
@@ -1 +1,10 @@
|
||||
fn main() {}
|
||||
unsafe extern "C" {
|
||||
#[cfg(only_foo)]
|
||||
fn does_not_exist(p: *const u8) -> *const foo::Foo;
|
||||
#[cfg(not(only_foo))]
|
||||
fn does_not_exist(p: *const bar::Bar) -> *const foo::Foo;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = unsafe { does_not_exist(core::ptr::null()) };
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ fn run_rustc() -> Rustc {
|
||||
.arg("-Clink-self-contained=-linker")
|
||||
.arg("-Zunstable-options")
|
||||
.arg("-Wlinker-messages")
|
||||
.args(["--extern", "foo", "--extern", "bar"])
|
||||
.output("main")
|
||||
.linker("./fake-linker");
|
||||
if run_make_support::target() == "x86_64-unknown-linux-gnu" {
|
||||
@@ -21,8 +22,10 @@ fn run_rustc() -> Rustc {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// first, compile our linker
|
||||
// first, compile our linker and our dependencies
|
||||
rustc().arg("fake-linker.rs").output("fake-linker").run();
|
||||
rustc().arg("foo.rs").crate_type("rlib").run();
|
||||
rustc().arg("bar.rs").crate_type("rlib").run();
|
||||
|
||||
// Run rustc with our fake linker, and make sure it shows warnings
|
||||
let warnings = run_rustc().link_arg("run_make_warn").run();
|
||||
@@ -48,7 +51,8 @@ fn main() {
|
||||
let out = run_rustc().link_arg("run_make_error").run_fail();
|
||||
out.assert_stderr_contains("fake-linker")
|
||||
.assert_stderr_contains("object files omitted")
|
||||
.assert_stderr_contains_regex(r"\{")
|
||||
.assert_stderr_contains("/{libfoo,libbar}.rlib\"")
|
||||
.assert_stderr_contains("-*}.rlib\"")
|
||||
.assert_stderr_not_contains(r".rcgu.o")
|
||||
.assert_stderr_not_contains_regex(r"lib(/|\\\\)libstd");
|
||||
|
||||
@@ -68,6 +72,10 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
// Make sure a single dependency doesn't use brace expansion.
|
||||
let out1 = run_rustc().cfg("only_foo").link_arg("run_make_error").run_fail();
|
||||
out1.assert_stderr_contains("fake-linker").assert_stderr_contains("/libfoo.rlib\"");
|
||||
|
||||
// Make sure we show linker warnings even across `-Z no-link`
|
||||
rustc()
|
||||
.arg("-Zno-link")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
error: linking with `./fake-linker` failed: exit status: 1
|
||||
|
|
||||
= note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
|
||||
= note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/build-root/test/run-make/linker-warning/rmake_out/{libfoo,libbar}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
|
||||
= note: some arguments are omitted. use `--verbose` to show all linker arguments
|
||||
= note: error: baz
|
||||
|
||||
|
||||
@@ -11,10 +11,9 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::abi::{
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::ascii::Char;
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::{CrateDef, CrateItems};
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::mir::mono::Instance;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::CrateDef;
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_span;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_hir;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::mir::mono::{Instance, InstanceKind};
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::CrateDef;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::mir::alloc::GlobalAlloc;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::mir::{
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use rustc_hir::def::DefKind;
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use stable_mir::ItemKind;
|
||||
|
||||
@@ -10,15 +10,14 @@
|
||||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_smir::rustc_internal;
|
||||
use stable_mir::rustc_internal;
|
||||
use std::io::Write;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#![feature(rustc_private)]
|
||||
#![feature(assert_matches)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_middle;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate stable_mir;
|
||||
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#![feature(assert_matches)]
|
||||
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate rustc_smir;
|
||||
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate stable_mir;
|
||||
|
||||
@@ -89,7 +89,7 @@ error: fn_abi_of(test) = FnAbi {
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:23:1
|
||||
--> $DIR/debug.rs:27:1
|
||||
|
|
||||
LL | fn test(_x: u8) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -185,7 +185,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi {
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:29:1
|
||||
--> $DIR/debug.rs:33:1
|
||||
|
|
||||
LL | type TestFnPtr = fn(bool) -> u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
@@ -263,13 +263,13 @@ error: fn_abi_of(test_generic) = FnAbi {
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:32:1
|
||||
--> $DIR/debug.rs:36:1
|
||||
|
|
||||
LL | fn test_generic<T>(_x: *const T) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
|
||||
--> $DIR/debug.rs:35:1
|
||||
--> $DIR/debug.rs:39:1
|
||||
|
|
||||
LL | const C: () = ();
|
||||
| ^^^^^^^^^^^
|
||||
@@ -419,7 +419,7 @@ error: ABIs are not compatible
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:51:1
|
||||
--> $DIR/debug.rs:55:1
|
||||
|
|
||||
LL | type TestAbiNe = (fn(u8), fn(u32));
|
||||
| ^^^^^^^^^^^^^^
|
||||
@@ -571,7 +571,7 @@ error: ABIs are not compatible
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:54:1
|
||||
--> $DIR/debug.rs:58:1
|
||||
|
|
||||
LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -720,7 +720,7 @@ error: ABIs are not compatible
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:57:1
|
||||
--> $DIR/debug.rs:61:1
|
||||
|
|
||||
LL | type TestAbiNeFloat = (fn(f32), fn(u32));
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
@@ -870,13 +870,13 @@ error: ABIs are not compatible
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:61:1
|
||||
--> $DIR/debug.rs:65:1
|
||||
|
|
||||
LL | type TestAbiNeSign = (fn(i32), fn(u32));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/debug.rs:64:46
|
||||
--> $DIR/debug.rs:68:46
|
||||
|
|
||||
LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
|
||||
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
@@ -885,13 +885,13 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
|
||||
= note: only the last element of a tuple may have a dynamically sized type
|
||||
|
||||
error: unrecognized argument
|
||||
--> $DIR/debug.rs:66:13
|
||||
--> $DIR/debug.rs:70:13
|
||||
|
|
||||
LL | #[rustc_abi("assert_eq")]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
|
||||
--> $DIR/debug.rs:39:5
|
||||
--> $DIR/debug.rs:43:5
|
||||
|
|
||||
LL | const C: () = ();
|
||||
| ^^^^^^^^^^^
|
||||
@@ -981,7 +981,7 @@ error: fn_abi_of(assoc_test) = FnAbi {
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:44:5
|
||||
--> $DIR/debug.rs:48:5
|
||||
|
|
||||
LL | fn assoc_test(&self) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
991
tests/ui/abi/debug.riscv64.stderr
Normal file
991
tests/ui/abi/debug.riscv64.stderr
Normal file
@@ -0,0 +1,991 @@
|
||||
error: fn_abi_of(test) = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u8,
|
||||
layout: Layout {
|
||||
size: Size(1 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=255,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Zext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: bool,
|
||||
layout: Layout {
|
||||
size: Size(1 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=1,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: Some(
|
||||
Niche {
|
||||
offset: Size(0 bytes),
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=1,
|
||||
},
|
||||
),
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Zext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:27:1
|
||||
|
|
||||
LL | fn test(_x: u8) -> bool {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: fn_abi_of(TestFnPtr) = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: bool,
|
||||
layout: Layout {
|
||||
size: Size(1 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=1,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: Some(
|
||||
Niche {
|
||||
offset: Size(0 bytes),
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=1,
|
||||
},
|
||||
),
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Zext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u8,
|
||||
layout: Layout {
|
||||
size: Size(1 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=255,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:33:1
|
||||
|
|
||||
LL | type TestFnPtr = fn(bool) -> u8;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: fn_abi_of(test_generic) = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: *const T,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Pointer(
|
||||
AddressSpace(
|
||||
0,
|
||||
),
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:36:1
|
||||
|
|
||||
LL | fn test_generic<T>(_x: *const T) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
|
||||
--> $DIR/debug.rs:39:1
|
||||
|
|
||||
LL | const C: () = ();
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: ABIs are not compatible
|
||||
left ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u8,
|
||||
layout: Layout {
|
||||
size: Size(1 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I8,
|
||||
false,
|
||||
),
|
||||
valid_range: 0..=255,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Zext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
right ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u32,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I32,
|
||||
false,
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Sext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:55:1
|
||||
|
|
||||
LL | type TestAbiNe = (fn(u8), fn(u32));
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: ABIs are not compatible
|
||||
left ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: [u8; 32],
|
||||
layout: Layout {
|
||||
size: Size(32 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Array {
|
||||
stride: Size(1 bytes),
|
||||
count: 32,
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Indirect {
|
||||
attrs: ArgAttributes {
|
||||
regular: NoAlias | NoCapture | NonNull | NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(32 bytes),
|
||||
pointee_align: Some(
|
||||
Align(1 bytes),
|
||||
),
|
||||
},
|
||||
meta_attrs: None,
|
||||
on_stack: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
right ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: [u32; 32],
|
||||
layout: Layout {
|
||||
size: Size(128 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Array {
|
||||
stride: Size(4 bytes),
|
||||
count: 32,
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Indirect {
|
||||
attrs: ArgAttributes {
|
||||
regular: NoAlias | NoCapture | NonNull | NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(128 bytes),
|
||||
pointee_align: Some(
|
||||
Align(4 bytes),
|
||||
),
|
||||
},
|
||||
meta_attrs: None,
|
||||
on_stack: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:58:1
|
||||
|
|
||||
LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: ABIs are not compatible
|
||||
left ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: f32,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Float(
|
||||
F32,
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
right ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u32,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I32,
|
||||
false,
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Sext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:61:1
|
||||
|
|
||||
LL | type TestAbiNeFloat = (fn(f32), fn(u32));
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: ABIs are not compatible
|
||||
left ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: i32,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I32,
|
||||
true,
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Sext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
right ABI = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: u32,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Int(
|
||||
I32,
|
||||
false,
|
||||
),
|
||||
valid_range: $FULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoUndef,
|
||||
arg_ext: Sext,
|
||||
pointee_size: Size(0 bytes),
|
||||
pointee_align: None,
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:65:1
|
||||
|
|
||||
LL | type TestAbiNeSign = (fn(i32), fn(u32));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the size for values of type `str` cannot be known at compilation time
|
||||
--> $DIR/debug.rs:68:46
|
||||
|
|
||||
LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str)));
|
||||
| ^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `str`
|
||||
= note: only the last element of a tuple may have a dynamically sized type
|
||||
|
||||
error: unrecognized argument
|
||||
--> $DIR/debug.rs:70:13
|
||||
|
|
||||
LL | #[rustc_abi("assert_eq")]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions
|
||||
--> $DIR/debug.rs:43:5
|
||||
|
|
||||
LL | const C: () = ();
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: fn_abi_of(assoc_test) = FnAbi {
|
||||
args: [
|
||||
ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: &S,
|
||||
layout: Layout {
|
||||
size: $SOME_SIZE,
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Scalar(
|
||||
Initialized {
|
||||
value: Pointer(
|
||||
AddressSpace(
|
||||
0,
|
||||
),
|
||||
),
|
||||
valid_range: $NON_NULL,
|
||||
},
|
||||
),
|
||||
fields: Primitive,
|
||||
largest_niche: Some(
|
||||
Niche {
|
||||
offset: Size(0 bytes),
|
||||
value: Pointer(
|
||||
AddressSpace(
|
||||
0,
|
||||
),
|
||||
),
|
||||
valid_range: $NON_NULL,
|
||||
},
|
||||
),
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Direct(
|
||||
ArgAttributes {
|
||||
regular: NoAlias | NonNull | ReadOnly | NoUndef,
|
||||
arg_ext: None,
|
||||
pointee_size: Size(2 bytes),
|
||||
pointee_align: Some(
|
||||
Align(2 bytes),
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
],
|
||||
ret: ArgAbi {
|
||||
layout: TyAndLayout {
|
||||
ty: (),
|
||||
layout: Layout {
|
||||
size: Size(0 bytes),
|
||||
align: AbiAlign {
|
||||
abi: $SOME_ALIGN,
|
||||
},
|
||||
backend_repr: Memory {
|
||||
sized: true,
|
||||
},
|
||||
fields: Arbitrary {
|
||||
offsets: [],
|
||||
memory_index: [],
|
||||
},
|
||||
largest_niche: None,
|
||||
uninhabited: false,
|
||||
variants: Single {
|
||||
index: 0,
|
||||
},
|
||||
max_repr_align: None,
|
||||
unadjusted_abi_align: $SOME_ALIGN,
|
||||
randomization_seed: $SEED,
|
||||
},
|
||||
},
|
||||
mode: Ignore,
|
||||
},
|
||||
c_variadic: false,
|
||||
fixed_count: 1,
|
||||
conv: Rust,
|
||||
can_unwind: $SOME_BOOL,
|
||||
}
|
||||
--> $DIR/debug.rs:48:5
|
||||
|
|
||||
LL | fn assoc_test(&self) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
@@ -8,6 +8,10 @@
|
||||
//@ normalize-stderr: "(valid_range): [1-9]\.\.=(429496729[0-9]|1844674407370955161[0-9])" -> "$1: $$NON_NULL"
|
||||
// Some attributes are only computed for release builds:
|
||||
//@ compile-flags: -O
|
||||
//@ revisions: generic riscv64
|
||||
//@ [riscv64] compile-flags: --target riscv64gc-unknown-linux-gnu
|
||||
//@ [riscv64] needs-llvm-components: riscv
|
||||
//@ [generic] ignore-riscv64
|
||||
#![feature(rustc_attrs)]
|
||||
#![crate_type = "lib"]
|
||||
#![feature(no_core)]
|
||||
|
||||
Reference in New Issue
Block a user