From 591b41abb8d2c6e7b0798ad658e3cc49bc92b2df Mon Sep 17 00:00:00 2001 From: "Celina G. Val" Date: Tue, 21 Nov 2023 19:09:01 -0800 Subject: [PATCH] Provide conversion of stable span to internal span This will allow users to use rustc span messages to display user friendly messages. --- compiler/rustc_smir/src/rustc_internal/internal.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index fe226ef60ed..202ca1b156a 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -11,8 +11,8 @@ use stable_mir::mir::alloc::AllocId; use stable_mir::mir::mono::{Instance, MonoItem, StaticDef}; use stable_mir::ty::{ AdtDef, Binder, BoundRegionKind, BoundTyKind, BoundVariableKind, ClosureKind, Const, - ExistentialTraitRef, FloatTy, GenericArgKind, GenericArgs, IntTy, Region, RigidTy, TraitRef, - Ty, UintTy, + ExistentialTraitRef, FloatTy, GenericArgKind, GenericArgs, IntTy, Region, RigidTy, Span, + TraitRef, Ty, UintTy, }; use stable_mir::{CrateItem, DefId}; @@ -279,6 +279,14 @@ impl<'tcx> RustcInternal<'tcx> for AdtDef { } } +impl<'tcx> RustcInternal<'tcx> for Span { + type T = rustc_span::Span; + + fn internal(&self, tables: &mut Tables<'tcx>) -> Self::T { + tables[*self] + } +} + impl<'tcx, T> RustcInternal<'tcx> for &T where T: RustcInternal<'tcx>,