Fix test by adding a stable way to get an opaque DefKind
This commit is contained in:
parent
55b6f64902
commit
33998a9751
3 changed files with 33 additions and 12 deletions
|
@ -13,6 +13,7 @@ use crate::stable_mir::ty::{
|
|||
FloatTy, GenericParamDef, IntTy, Movability, RigidTy, Span, TyKind, UintTy,
|
||||
};
|
||||
use crate::stable_mir::{self, CompilerError, Context};
|
||||
use hir::def::DefKind;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
||||
|
@ -48,6 +49,9 @@ impl<'tcx> Context for Tables<'tcx> {
|
|||
self.tcx.sess.source_map().span_to_diagnostic_string(self[span])
|
||||
}
|
||||
|
||||
fn def_kind(&mut self, def_id: stable_mir::DefId) -> stable_mir::DefKind {
|
||||
self.tcx.def_kind(self[def_id]).stable(self)
|
||||
}
|
||||
|
||||
fn span_of_an_item(&mut self, def_id: stable_mir::DefId) -> Span {
|
||||
self.tcx.def_span(self[def_id]).stable(self)
|
||||
|
@ -1519,3 +1523,12 @@ impl<T> From<ErrorGuaranteed> for CompilerError<T> {
|
|||
CompilerError::CompilationFailed
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Stable<'tcx> for DefKind {
|
||||
type T = stable_mir::DefKind;
|
||||
|
||||
fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
|
||||
// FIXME: add a real implementation of stable DefKind
|
||||
opaque(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,14 @@ impl CrateItem {
|
|||
pub fn span(&self) -> Span {
|
||||
with(|cx| cx.span_of_an_item(self.0))
|
||||
}
|
||||
|
||||
pub fn name(&self) -> String {
|
||||
with(|cx| cx.name_of_def_id(self.0))
|
||||
}
|
||||
|
||||
pub fn kind(&self) -> DefKind {
|
||||
with(|cx| cx.def_kind(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the function where execution starts if the current
|
||||
|
@ -165,6 +173,8 @@ pub trait Context {
|
|||
fn name_of_def_id(&self, def_id: DefId) -> String;
|
||||
|
||||
fn print_span(&self, span: Span) -> String;
|
||||
|
||||
fn def_kind(&mut self, def_id: DefId) -> DefKind;
|
||||
/// `Span` of an item
|
||||
fn span_of_an_item(&mut self, def_id: DefId) -> Span;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue