mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things
This commit is contained in:
parent
19f1d782d5
commit
a38e98371b
11
Cargo.lock
11
Cargo.lock
@ -3257,6 +3257,7 @@ dependencies = [
|
|||||||
"rustc_driver",
|
"rustc_driver",
|
||||||
"rustc_driver_impl",
|
"rustc_driver_impl",
|
||||||
"rustc_smir",
|
"rustc_smir",
|
||||||
|
"stable_mir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4421,7 +4422,7 @@ dependencies = [
|
|||||||
"rustc_session",
|
"rustc_session",
|
||||||
"rustc_span",
|
"rustc_span",
|
||||||
"rustc_target",
|
"rustc_target",
|
||||||
"scoped-tls",
|
"stable_mir",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -4958,6 +4959,14 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stable_mir"
|
||||||
|
version = "0.1.0-preview"
|
||||||
|
dependencies = [
|
||||||
|
"scoped-tls",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stacker"
|
name = "stacker"
|
||||||
version = "0.1.15"
|
version = "0.1.15"
|
||||||
|
@ -13,6 +13,7 @@ rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
|
|||||||
# Make sure rustc_smir ends up in the sysroot, because this
|
# Make sure rustc_smir ends up in the sysroot, because this
|
||||||
# crate is intended to be used by stable MIR consumers, which are not in-tree
|
# crate is intended to be used by stable MIR consumers, which are not in-tree
|
||||||
rustc_smir = { path = "../rustc_smir" }
|
rustc_smir = { path = "../rustc_smir" }
|
||||||
|
stable_mir = { path = "../stable_mir" }
|
||||||
|
|
||||||
[dependencies.jemalloc-sys]
|
[dependencies.jemalloc-sys]
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
@ -4,24 +4,14 @@ version = "0.0.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Use optional dependencies for rustc_* in order to support building this crate separately.
|
rustc_hir = { path = "../rustc_hir" }
|
||||||
rustc_hir = { path = "../rustc_hir", optional = true }
|
rustc_middle = { path = "../rustc_middle" }
|
||||||
rustc_middle = { path = "../rustc_middle", optional = true }
|
rustc_span = { path = "../rustc_span" }
|
||||||
rustc_span = { path = "../rustc_span", optional = true }
|
rustc_target = { path = "../rustc_target" }
|
||||||
rustc_target = { path = "../rustc_target", optional = true }
|
rustc_driver = { path = "../rustc_driver" }
|
||||||
rustc_driver = { path = "../rustc_driver", optional = true }
|
rustc_interface = { path = "../rustc_interface" }
|
||||||
rustc_interface = { path = "../rustc_interface", optional = true}
|
rustc_session = {path = "../rustc_session" }
|
||||||
rustc_session = {path = "../rustc_session", optional = true}
|
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
scoped-tls = "1.0"
|
stable_mir = {path = "../stable_mir" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [
|
|
||||||
"rustc_hir",
|
|
||||||
"rustc_middle",
|
|
||||||
"rustc_span",
|
|
||||||
"rustc_target",
|
|
||||||
"rustc_driver",
|
|
||||||
"rustc_interface",
|
|
||||||
"rustc_session",
|
|
||||||
]
|
|
||||||
|
@ -10,26 +10,12 @@
|
|||||||
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
|
||||||
test(attr(allow(unused_variables), deny(warnings)))
|
test(attr(allow(unused_variables), deny(warnings)))
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(feature = "default"), feature(rustc_private))]
|
#![feature(rustc_private)]
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
#![feature(type_alias_impl_trait)] // Used to define opaque types.
|
#![feature(type_alias_impl_trait)] // Used to define opaque types.
|
||||||
#![feature(intra_doc_pointers)]
|
#![feature(intra_doc_pointers)]
|
||||||
|
|
||||||
// Declare extern rustc_* crates to enable building this crate separately from the compiler.
|
|
||||||
#[cfg(not(feature = "default"))]
|
|
||||||
extern crate rustc_hir;
|
|
||||||
#[cfg(not(feature = "default"))]
|
|
||||||
extern crate rustc_middle;
|
|
||||||
#[cfg(not(feature = "default"))]
|
|
||||||
extern crate rustc_span;
|
|
||||||
#[cfg(not(feature = "default"))]
|
|
||||||
extern crate rustc_target;
|
|
||||||
|
|
||||||
pub mod rustc_internal;
|
pub mod rustc_internal;
|
||||||
pub mod stable_mir;
|
|
||||||
|
|
||||||
// Make this module private for now since external users should not call these directly.
|
// Make this module private for now since external users should not call these directly.
|
||||||
mod rustc_smir;
|
mod rustc_smir;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate scoped_tls;
|
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
use std::ops::{ControlFlow, Index};
|
use std::ops::{ControlFlow, Index};
|
||||||
|
|
||||||
use crate::rustc_internal;
|
use crate::rustc_internal;
|
||||||
use crate::stable_mir::CompilerError;
|
use crate::rustc_smir::Tables;
|
||||||
use crate::{rustc_smir::Tables, stable_mir};
|
|
||||||
use rustc_driver::{Callbacks, Compilation, RunCompiler};
|
use rustc_driver::{Callbacks, Compilation, RunCompiler};
|
||||||
use rustc_interface::{interface, Queries};
|
use rustc_interface::{interface, Queries};
|
||||||
use rustc_middle::mir::interpret::AllocId;
|
use rustc_middle::mir::interpret::AllocId;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
pub use rustc_span::def_id::{CrateNum, DefId};
|
pub use rustc_span::def_id::{CrateNum, DefId};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
use stable_mir::CompilerError;
|
||||||
|
|
||||||
impl<'tcx> Index<stable_mir::DefId> for Tables<'tcx> {
|
impl<'tcx> Index<stable_mir::DefId> for Tables<'tcx> {
|
||||||
type Output = DefId;
|
type Output = DefId;
|
||||||
@ -129,7 +129,7 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
|
pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
|
||||||
crate::stable_mir::run(
|
stable_mir::run(
|
||||||
Tables { tcx, def_ids: vec![], alloc_ids: vec![], spans: vec![], types: vec![] },
|
Tables { tcx, def_ids: vec![], alloc_ids: vec![], spans: vec![], types: vec![] },
|
||||||
f,
|
f,
|
||||||
);
|
);
|
||||||
|
@ -3,11 +3,9 @@ use rustc_middle::mir::{
|
|||||||
ConstValue,
|
ConstValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::rustc_smir::{Stable, Tables};
|
||||||
rustc_smir::{Stable, Tables},
|
use stable_mir::mir::Mutability;
|
||||||
stable_mir::mir::Mutability,
|
use stable_mir::ty::{Allocation, ProvenanceMap};
|
||||||
stable_mir::ty::{Allocation, ProvenanceMap},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Creates new empty `Allocation` from given `Align`.
|
/// Creates new empty `Allocation` from given `Align`.
|
||||||
fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation {
|
fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation {
|
||||||
|
@ -7,19 +7,16 @@
|
|||||||
//!
|
//!
|
||||||
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
|
||||||
|
|
||||||
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
|
||||||
use crate::stable_mir::ty::{
|
|
||||||
FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy,
|
|
||||||
};
|
|
||||||
use crate::stable_mir::{self, opaque, CompilerError, Context};
|
|
||||||
use hir::def::DefKind;
|
use hir::def::DefKind;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
|
use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
|
||||||
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||||
use rustc_span::ErrorGuaranteed;
|
|
||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
|
use stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
||||||
|
use stable_mir::ty::{FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy};
|
||||||
|
use stable_mir::{self, opaque, Context};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
mod alloc;
|
mod alloc;
|
||||||
@ -112,7 +109,7 @@ impl<'tcx> Context for Tables<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_kind(&mut self, ty: crate::stable_mir::ty::Ty) -> TyKind {
|
fn ty_kind(&mut self, ty: stable_mir::ty::Ty) -> TyKind {
|
||||||
self.types[ty.0].clone().stable(self)
|
self.types[ty.0].clone().stable(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1517,12 +1514,6 @@ impl<'tcx> Stable<'tcx> for rustc_span::Span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<ErrorGuaranteed> for CompilerError<T> {
|
|
||||||
fn from(_error: ErrorGuaranteed) -> Self {
|
|
||||||
CompilerError::CompilationFailed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> Stable<'tcx> for DefKind {
|
impl<'tcx> Stable<'tcx> for DefKind {
|
||||||
type T = stable_mir::DefKind;
|
type T = stable_mir::DefKind;
|
||||||
|
|
||||||
|
8
compiler/stable_mir/Cargo.toml
Normal file
8
compiler/stable_mir/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "stable_mir"
|
||||||
|
version = "0.1.0-preview"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
tracing = "0.1"
|
||||||
|
scoped-tls = "1.0"
|
@ -1,11 +1,10 @@
|
|||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use super::{
|
use crate::Opaque;
|
||||||
ty::{
|
|
||||||
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig,
|
use super::ty::{
|
||||||
GenericArgKind, GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
Allocation, Binder, Const, ConstDef, ConstantKind, ExistentialPredicate, FnSig, GenericArgKind,
|
||||||
},
|
GenericArgs, Promoted, RigidTy, TermKind, Ty, TyKind, UnevaluatedConst,
|
||||||
Opaque,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Folder: Sized {
|
pub trait Folder: Sized {
|
@ -1,15 +1,21 @@
|
|||||||
//! Module that implements the public interface to the Stable MIR.
|
//! The WIP stable interface to rustc internals.
|
||||||
//!
|
//!
|
||||||
//! This module shall contain all type definitions and APIs that we expect third-party tools to invoke to
|
//! 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.
|
//! interact with the compiler.
|
||||||
//!
|
//!
|
||||||
//! The goal is to eventually move this module to its own crate which shall be published on
|
//! The goal is to eventually be published on
|
||||||
//! [crates.io](https://crates.io).
|
//! [crates.io](https://crates.io).
|
||||||
//!
|
|
||||||
//! ## Note:
|
|
||||||
//!
|
|
||||||
//! There shouldn't be any direct references to internal compiler constructs in this module.
|
|
||||||
//! If you need an internal construct, consider using `rustc_internal` or `rustc_smir`.
|
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -19,6 +25,9 @@ use self::ty::{
|
|||||||
GenericPredicates, Generics, ImplDef, ImplTrait, Span, TraitDecl, TraitDef, Ty, TyKind,
|
GenericPredicates, Generics, ImplDef, ImplTrait, Span, TraitDecl, TraitDef, Ty, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate scoped_tls;
|
||||||
|
|
||||||
pub mod fold;
|
pub mod fold;
|
||||||
pub mod mir;
|
pub mod mir;
|
||||||
pub mod ty;
|
pub mod ty;
|
||||||
@ -32,11 +41,11 @@ pub type CrateNum = usize;
|
|||||||
|
|
||||||
/// A unique identification number for each item accessible for the current compilation unit.
|
/// A unique identification number for each item accessible for the current compilation unit.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct DefId(pub(crate) usize);
|
pub struct DefId(pub usize);
|
||||||
|
|
||||||
impl Debug for DefId {
|
impl Debug for DefId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("DefId:")
|
f.debug_struct("DefId")
|
||||||
.field("id", &self.0)
|
.field("id", &self.0)
|
||||||
.field("name", &with(|cx| cx.name_of_def_id(*self)))
|
.field("name", &with(|cx| cx.name_of_def_id(*self)))
|
||||||
.finish()
|
.finish()
|
||||||
@ -45,7 +54,7 @@ impl Debug for DefId {
|
|||||||
|
|
||||||
/// A unique identification number for each provenance
|
/// A unique identification number for each provenance
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct AllocId(pub(crate) usize);
|
pub struct AllocId(pub usize);
|
||||||
|
|
||||||
/// A list of crate items.
|
/// A list of crate items.
|
||||||
pub type CrateItems = Vec<CrateItem>;
|
pub type CrateItems = Vec<CrateItem>;
|
||||||
@ -73,7 +82,7 @@ pub enum CompilerError<T> {
|
|||||||
/// Holds information about a crate.
|
/// Holds information about a crate.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct Crate {
|
pub struct Crate {
|
||||||
pub(crate) id: CrateNum,
|
pub id: CrateNum,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
pub is_local: bool,
|
pub is_local: bool,
|
||||||
}
|
}
|
||||||
@ -84,7 +93,7 @@ pub type DefKind = Opaque;
|
|||||||
/// For now, it only stores the item DefId. Use functions inside `rustc_internal` module to
|
/// For now, it only stores the item DefId. Use functions inside `rustc_internal` module to
|
||||||
/// use this item.
|
/// use this item.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct CrateItem(pub(crate) DefId);
|
pub struct CrateItem(pub DefId);
|
||||||
|
|
||||||
impl CrateItem {
|
impl CrateItem {
|
||||||
pub fn body(&self) -> mir::Body {
|
pub fn body(&self) -> mir::Body {
|
||||||
@ -170,9 +179,12 @@ pub trait Context {
|
|||||||
/// Prints the name of given `DefId`
|
/// Prints the name of given `DefId`
|
||||||
fn name_of_def_id(&self, def_id: DefId) -> String;
|
fn name_of_def_id(&self, def_id: DefId) -> String;
|
||||||
|
|
||||||
|
/// Prints a human readable form of `Span`
|
||||||
fn print_span(&self, span: Span) -> String;
|
fn print_span(&self, span: Span) -> String;
|
||||||
|
|
||||||
|
/// Prints the kind of given `DefId`
|
||||||
fn def_kind(&mut self, def_id: DefId) -> DefKind;
|
fn def_kind(&mut self, def_id: DefId) -> DefKind;
|
||||||
|
|
||||||
/// `Span` of an item
|
/// `Span` of an item
|
||||||
fn span_of_an_item(&mut self, def_id: DefId) -> Span;
|
fn span_of_an_item(&mut self, def_id: DefId) -> Span;
|
||||||
|
|
||||||
@ -200,7 +212,7 @@ pub fn run(mut context: impl Context, f: impl FnOnce()) {
|
|||||||
|
|
||||||
/// Loads the current context and calls a function with it.
|
/// Loads the current context and calls a function with it.
|
||||||
/// Do not nest these, as that will ICE.
|
/// Do not nest these, as that will ICE.
|
||||||
pub(crate) fn with<R>(f: impl FnOnce(&mut dyn Context) -> R) -> R {
|
pub fn with<R>(f: impl FnOnce(&mut dyn Context) -> R) -> R {
|
||||||
assert!(TLV.is_set());
|
assert!(TLV.is_set());
|
||||||
TLV.with(|tlv| {
|
TLV.with(|tlv| {
|
||||||
let ptr = tlv.get();
|
let ptr = tlv.get();
|
||||||
@ -225,6 +237,6 @@ impl std::fmt::Debug for Opaque {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn opaque<T: Debug>(value: &T) -> Opaque {
|
pub fn opaque<T: Debug>(value: &T) -> Opaque {
|
||||||
Opaque(format!("{value:?}"))
|
Opaque(format!("{value:?}"))
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
use crate::stable_mir::ty::{
|
use crate::ty::{AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region};
|
||||||
AdtDef, ClosureDef, Const, GeneratorDef, GenericArgs, Movability, Region,
|
use crate::Opaque;
|
||||||
};
|
use crate::{ty::Ty, Span};
|
||||||
use crate::stable_mir::Opaque;
|
|
||||||
use crate::stable_mir::{self, ty::Ty, Span};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Body {
|
pub struct Body {
|
||||||
@ -135,7 +133,7 @@ pub enum AsyncGeneratorKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type LocalDefId = Opaque;
|
pub(crate) type LocalDefId = Opaque;
|
||||||
/// [`rustc_middle::mir::Coverage`] is heavily tied to internal details of the
|
/// The rustc coverage data structures are heavily tied to internal details of the
|
||||||
/// coverage implementation that are likely to change, and are unlikely to be
|
/// coverage implementation that are likely to change, and are unlikely to be
|
||||||
/// useful to third-party tools for the foreseeable future.
|
/// useful to third-party tools for the foreseeable future.
|
||||||
pub(crate) type Coverage = Opaque;
|
pub(crate) type Coverage = Opaque;
|
||||||
@ -215,7 +213,7 @@ pub enum Rvalue {
|
|||||||
/// generator lowering, `Generator` aggregate kinds are disallowed too.
|
/// generator lowering, `Generator` aggregate kinds are disallowed too.
|
||||||
Aggregate(AggregateKind, Vec<Operand>),
|
Aggregate(AggregateKind, Vec<Operand>),
|
||||||
|
|
||||||
/// * `Offset` has the same semantics as [`offset`](pointer::offset), except that the second
|
/// * `Offset` has the same semantics as `<*const T>::offset`, except that the second
|
||||||
/// parameter may be a `usize` as well.
|
/// parameter may be a `usize` as well.
|
||||||
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
|
/// * The comparison operations accept `bool`s, `char`s, signed or unsigned integers, floats,
|
||||||
/// raw pointers, or function pointers and return a `bool`. The types of the operands must be
|
/// raw pointers, or function pointers and return a `bool`. The types of the operands must be
|
||||||
@ -245,16 +243,14 @@ pub enum Rvalue {
|
|||||||
/// deref operation, immediately followed by one or more projections.
|
/// deref operation, immediately followed by one or more projections.
|
||||||
CopyForDeref(Place),
|
CopyForDeref(Place),
|
||||||
|
|
||||||
/// Computes the discriminant of the place, returning it as an integer of type
|
/// Computes the discriminant of the place, returning it as an integer.
|
||||||
/// [`discriminant_ty`]. Returns zero for types without discriminant.
|
/// Returns zero for types without discriminant.
|
||||||
///
|
///
|
||||||
/// The validity requirements for the underlying value are undecided for this rvalue, see
|
/// The validity requirements for the underlying value are undecided for this rvalue, see
|
||||||
/// [#91095]. Note too that the value of the discriminant is not the same thing as the
|
/// [#91095]. Note too that the value of the discriminant is not the same thing as the
|
||||||
/// variant index; use [`discriminant_for_variant`] to convert.
|
/// variant index;
|
||||||
///
|
///
|
||||||
/// [`discriminant_ty`]: rustc_middle::ty::Ty::discriminant_ty
|
|
||||||
/// [#91095]: https://github.com/rust-lang/rust/issues/91095
|
/// [#91095]: https://github.com/rust-lang/rust/issues/91095
|
||||||
/// [`discriminant_for_variant`]: rustc_middle::ty::Ty::discriminant_for_variant
|
|
||||||
Discriminant(Place),
|
Discriminant(Place),
|
||||||
|
|
||||||
/// Yields the length of the place, as a `usize`.
|
/// Yields the length of the place, as a `usize`.
|
||||||
@ -295,7 +291,7 @@ pub enum Rvalue {
|
|||||||
///
|
///
|
||||||
/// **Needs clarification**: Are there weird additional semantics here related to the runtime
|
/// **Needs clarification**: Are there weird additional semantics here related to the runtime
|
||||||
/// nature of this operation?
|
/// nature of this operation?
|
||||||
ThreadLocalRef(stable_mir::CrateItem),
|
ThreadLocalRef(crate::CrateItem),
|
||||||
|
|
||||||
/// Computes a value as described by the operation.
|
/// Computes a value as described by the operation.
|
||||||
NullaryOp(NullOp, Ty),
|
NullaryOp(NullOp, Ty),
|
@ -1,8 +1,9 @@
|
|||||||
use super::{
|
use super::{
|
||||||
mir::Safety,
|
mir::Safety,
|
||||||
mir::{Body, Mutability},
|
mir::{Body, Mutability},
|
||||||
with, AllocId, DefId, Opaque,
|
with, AllocId, DefId,
|
||||||
};
|
};
|
||||||
|
use crate::Opaque;
|
||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -33,9 +34,9 @@ pub struct Const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Ident = Opaque;
|
type Ident = Opaque;
|
||||||
pub(crate) type Region = Opaque;
|
pub type Region = Opaque;
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct Span(pub(crate) usize);
|
pub struct Span(pub usize);
|
||||||
|
|
||||||
impl Debug for Span {
|
impl Debug for Span {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
@ -110,10 +111,10 @@ pub enum Movability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct ForeignDef(pub(crate) DefId);
|
pub struct ForeignDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct FnDef(pub(crate) DefId);
|
pub struct FnDef(pub DefId);
|
||||||
|
|
||||||
impl FnDef {
|
impl FnDef {
|
||||||
pub fn body(&self) -> Body {
|
pub fn body(&self) -> Body {
|
||||||
@ -122,34 +123,34 @@ impl FnDef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct ClosureDef(pub(crate) DefId);
|
pub struct ClosureDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct GeneratorDef(pub(crate) DefId);
|
pub struct GeneratorDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct ParamDef(pub(crate) DefId);
|
pub struct ParamDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct BrNamedDef(pub(crate) DefId);
|
pub struct BrNamedDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct AdtDef(pub(crate) DefId);
|
pub struct AdtDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct AliasDef(pub(crate) DefId);
|
pub struct AliasDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct TraitDef(pub(crate) DefId);
|
pub struct TraitDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct GenericDef(pub(crate) DefId);
|
pub struct GenericDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct ConstDef(pub(crate) DefId);
|
pub struct ConstDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||||
pub struct ImplDef(pub(crate) DefId);
|
pub struct ImplDef(pub DefId);
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
pub struct GenericArgs(pub Vec<GenericArgKind>);
|
||||||
@ -333,7 +334,7 @@ pub type Bytes = Vec<Option<u8>>;
|
|||||||
pub type Size = usize;
|
pub type Size = usize;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
pub struct Prov(pub(crate) AllocId);
|
pub struct Prov(pub AllocId);
|
||||||
pub type Align = u64;
|
pub type Align = u64;
|
||||||
pub type Promoted = u32;
|
pub type Promoted = u32;
|
||||||
pub type InitMaskMaterialized = Vec<u64>;
|
pub type InitMaskMaterialized = Vec<u64>;
|
@ -1,11 +1,10 @@
|
|||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
use super::{
|
use crate::Opaque;
|
||||||
ty::{
|
|
||||||
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind,
|
use super::ty::{
|
||||||
GenericArgs, Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
Allocation, Binder, Const, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
|
||||||
},
|
Promoted, RigidTy, TermKind, Ty, UnevaluatedConst,
|
||||||
Opaque,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Visitor: Sized {
|
pub trait Visitor: Sized {
|
@ -1789,7 +1789,10 @@ pub fn run_cargo(
|
|||||||
// During check builds we need to keep crate metadata
|
// During check builds we need to keep crate metadata
|
||||||
keep = true;
|
keep = true;
|
||||||
} else if rlib_only_metadata {
|
} else if rlib_only_metadata {
|
||||||
if filename.contains("jemalloc_sys") || filename.contains("rustc_smir") {
|
if filename.contains("jemalloc_sys")
|
||||||
|
|| filename.contains("rustc_smir")
|
||||||
|
|| filename.contains("stable_mir")
|
||||||
|
{
|
||||||
// jemalloc_sys and rustc_smir are not linked into librustc_driver.so,
|
// jemalloc_sys and rustc_smir are not linked into librustc_driver.so,
|
||||||
// so we need to distribute them as rlib to be able to use them.
|
// so we need to distribute them as rlib to be able to use them.
|
||||||
keep |= filename.ends_with(".rlib");
|
keep |= filename.ends_with(".rlib");
|
||||||
|
@ -11,9 +11,10 @@
|
|||||||
|
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_smir;
|
extern crate rustc_smir;
|
||||||
|
extern crate stable_mir;
|
||||||
|
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_smir::{rustc_internal, stable_mir};
|
use rustc_smir::rustc_internal;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
extern crate rustc_hir;
|
extern crate rustc_hir;
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_smir;
|
extern crate rustc_smir;
|
||||||
|
extern crate stable_mir;
|
||||||
|
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_smir::{
|
use rustc_smir::rustc_internal;
|
||||||
rustc_internal,
|
|
||||||
stable_mir::{self, fold::Foldable},
|
use stable_mir::fold::Foldable;
|
||||||
};
|
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
@ -542,6 +542,10 @@ cc = ["@davidtwco", "@compiler-errors", "@JohnTitor", "@TaKO8Ki"]
|
|||||||
message = "This PR changes Stable MIR"
|
message = "This PR changes Stable MIR"
|
||||||
cc = ["@oli-obk", "@celinval", "@spastorino"]
|
cc = ["@oli-obk", "@celinval", "@spastorino"]
|
||||||
|
|
||||||
|
[mentions."compiler/stable_mir"]
|
||||||
|
message = "This PR changes Stable MIR"
|
||||||
|
cc = ["@oli-obk", "@celinval", "@spastorino"]
|
||||||
|
|
||||||
[mentions."compiler/rustc_target/src/spec"]
|
[mentions."compiler/rustc_target/src/spec"]
|
||||||
message = """
|
message = """
|
||||||
These commits modify **compiler targets**.
|
These commits modify **compiler targets**.
|
||||||
|
Loading…
Reference in New Issue
Block a user