File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ impl<'tcx> Context for Tables<'tcx> {
4242 self . tcx . def_path_str ( self [ def_id] )
4343 }
4444
45+ fn span_of_an_item ( & mut self , def_id : stable_mir:: DefId ) -> stable_mir:: ty:: Span {
46+ self . tcx . def_span ( self [ def_id] ) . stable ( self )
47+ }
48+
4549 fn all_local_items ( & mut self ) -> stable_mir:: CrateItems {
4650 self . tcx . mir_keys ( ( ) ) . iter ( ) . map ( |item| self . crate_item ( item. to_def_id ( ) ) ) . collect ( )
4751 }
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ impl CrateItem {
8989 pub fn body ( & self ) -> mir:: Body {
9090 with ( |cx| cx. mir_body ( self . 0 ) )
9191 }
92+
93+ pub fn span ( & self ) -> ty:: Span {
94+ with ( |cx| cx. span_of_an_item ( self . 0 ) )
95+ }
9296}
9397
9498/// Return the function where execution starts if the current
@@ -156,6 +160,9 @@ pub trait Context {
156160 /// Prints the name of given `DefId`
157161 fn name_of_def_id ( & self , def_id : DefId ) -> String ;
158162
163+ /// `Span` of an item
164+ fn span_of_an_item ( & mut self , def_id : DefId ) -> Span ;
165+
159166 /// Obtain the representation of a type.
160167 fn ty_kind ( & mut self , ty : Ty ) -> TyKind ;
161168
You can’t perform that action at this time.
0 commit comments