Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4540,9 +4540,6 @@ dependencies = [
"rustc_session",
"rustc_span",
"rustc_target",
"scoped-tls",
"serde",
"tracing",
]

[[package]]
Expand Down Expand Up @@ -5095,7 +5092,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]]
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_smir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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")))
}
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}
Expand Down
Loading
Loading