Skip to content

Commit f835ab4

Browse files
committed
refactor: move convert module to stable_mir
note that this commit delete `convert/error.rs`, we would use `SmirError::from_internal` instead. **Unresolved questions:** - There are still a few direct calls to rustc's internals scattered across `impl Stable`s, but most of them appear to be relatively stable, e.g., `mir::interpret::ConstAllocation::inner(self)` and `mir::syntax::SwitchTargets::otherwise(self)`.
1 parent 82e4c7c commit f835ab4

File tree

11 files changed

+1225
-589
lines changed

11 files changed

+1225
-589
lines changed

compiler/rustc_smir/src/rustc_internal/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ use rustc_span::Span;
1717
use rustc_span::def_id::{CrateNum, DefId};
1818
use scoped_tls::scoped_thread_local;
1919
use stable_mir::Error;
20+
use stable_mir::convert::{RustcInternal, Stable};
2021

2122
use crate::rustc_smir::context::SmirCtxt;
22-
use crate::rustc_smir::{Stable, Tables};
2323
use crate::rustc_smir::{Bridge, IndexedVal, SmirContainer, Tables};
2424
use crate::stable_mir;
2525

26-
mod internal;
2726
pub mod pretty;
2827

2928
/// Convert an internal Rust compiler item into its stable counterpart, if one exists.
@@ -340,11 +339,3 @@ impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> Index<V
340339
k
341340
}
342341
}
343-
344-
/// Trait used to translate a stable construct to its rustc counterpart.
345-
///
346-
/// This is basically a mirror of [crate::rustc_smir::Stable].
347-
pub trait RustcInternal {
348-
type T<'tcx>;
349-
fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T<'tcx>;
350-
}

compiler/rustc_smir/src/rustc_smir/convert/error.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

compiler/rustc_smir/src/rustc_smir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::rustc_internal::IndexMap;
2222
pub mod alloc;
2323
mod builder;
2424
pub mod context;
25-
mod convert;
2625

2726
/// A container which is used for TLS.
2827
pub struct SmirContainer<'tcx, B: Bridge> {

compiler/rustc_smir/src/stable_mir/compiler_interface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::cell::Cell;
88
use rustc_hir::def::DefKind;
99
use rustc_smir::{Bridge, SmirContainer, Tables};
1010
use stable_mir::abi::{FnAbi, Layout, LayoutShape};
11+
use stable_mir::convert::{RustcInternal, Stable};
1112
use stable_mir::crate_def::Attribute;
1213
use stable_mir::mir::alloc::{AllocId, GlobalAlloc};
1314
use stable_mir::mir::mono::{Instance, InstanceDef, StaticDef};

0 commit comments

Comments
 (0)