File tree 2 files changed +11
-0
lines changed
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> {
42
42
self . tcx . def_path_str ( self [ def_id] )
43
43
}
44
44
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
+
45
49
fn all_local_items ( & mut self ) -> stable_mir:: CrateItems {
46
50
self . tcx . mir_keys ( ( ) ) . iter ( ) . map ( |item| self . crate_item ( item. to_def_id ( ) ) ) . collect ( )
47
51
}
Original file line number Diff line number Diff line change @@ -89,6 +89,10 @@ impl CrateItem {
89
89
pub fn body ( & self ) -> mir:: Body {
90
90
with ( |cx| cx. mir_body ( self . 0 ) )
91
91
}
92
+
93
+ pub fn span ( & self ) -> ty:: Span {
94
+ with ( |cx| cx. span_of_an_item ( self . 0 ) )
95
+ }
92
96
}
93
97
94
98
/// Return the function where execution starts if the current
@@ -156,6 +160,9 @@ pub trait Context {
156
160
/// Prints the name of given `DefId`
157
161
fn name_of_def_id ( & self , def_id : DefId ) -> String ;
158
162
163
+ /// `Span` of an item
164
+ fn span_of_an_item ( & mut self , def_id : DefId ) -> Span ;
165
+
159
166
/// Obtain the representation of a type.
160
167
fn ty_kind ( & mut self , ty : Ty ) -> TyKind ;
161
168
You can’t perform that action at this time.
0 commit comments