@@ -97,7 +97,7 @@ fn t6() {
97
97
#[ test]
98
98
fn t7 ( ) {
99
99
let sm = init_source_map ( ) ;
100
- let span = Span :: new ( BytePos ( 12 ) , BytePos ( 23 ) , NO_EXPANSION ) ;
100
+ let span = Span :: with_root_ctxt ( BytePos ( 12 ) , BytePos ( 23 ) ) ;
101
101
let file_lines = sm. span_to_lines ( span) . unwrap ( ) ;
102
102
103
103
assert_eq ! ( file_lines. file. name, PathBuf :: from( "blork.rs" ) . into( ) ) ;
@@ -113,7 +113,7 @@ fn span_from_selection(input: &str, selection: &str) -> Span {
113
113
assert_eq ! ( input. len( ) , selection. len( ) ) ;
114
114
let left_index = selection. find ( '~' ) . unwrap ( ) as u32 ;
115
115
let right_index = selection. rfind ( '~' ) . map ( |x|x as u32 ) . unwrap_or ( left_index) ;
116
- Span :: new ( BytePos ( left_index) , BytePos ( right_index + 1 ) , NO_EXPANSION )
116
+ Span :: with_root_ctxt ( BytePos ( left_index) , BytePos ( right_index + 1 ) )
117
117
}
118
118
119
119
/// Tests `span_to_snippet` and `span_to_lines` for a span converting 3
@@ -143,7 +143,7 @@ fn span_to_snippet_and_lines_spanning_multiple_lines() {
143
143
#[ test]
144
144
fn t8 ( ) {
145
145
let sm = init_source_map ( ) ;
146
- let span = Span :: new ( BytePos ( 12 ) , BytePos ( 23 ) , NO_EXPANSION ) ;
146
+ let span = Span :: with_root_ctxt ( BytePos ( 12 ) , BytePos ( 23 ) ) ;
147
147
let snippet = sm. span_to_snippet ( span) ;
148
148
149
149
assert_eq ! ( snippet, Ok ( "second line" . to_string( ) ) ) ;
@@ -153,7 +153,7 @@ fn t8() {
153
153
#[ test]
154
154
fn t9 ( ) {
155
155
let sm = init_source_map ( ) ;
156
- let span = Span :: new ( BytePos ( 12 ) , BytePos ( 23 ) , NO_EXPANSION ) ;
156
+ let span = Span :: with_root_ctxt ( BytePos ( 12 ) , BytePos ( 23 ) ) ;
157
157
let sstr = sm. span_to_string ( span) ;
158
158
159
159
assert_eq ! ( sstr, "blork.rs:2:1: 2:12" ) ;
@@ -176,7 +176,7 @@ fn span_merging_fail() {
176
176
/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`.
177
177
trait SourceMapExtension {
178
178
fn span_substr (
179
- self ,
179
+ & self ,
180
180
file : & Lrc < SourceFile > ,
181
181
source_text : & str ,
182
182
substring : & str ,
@@ -208,10 +208,9 @@ impl SourceMapExtension for SourceMap {
208
208
let lo = hi + offset;
209
209
hi = lo + substring. len ( ) ;
210
210
if i == n {
211
- let span = Span :: new (
211
+ let span = Span :: with_root_ctxt (
212
212
BytePos ( lo as u32 + file. start_pos . 0 ) ,
213
213
BytePos ( hi as u32 + file. start_pos . 0 ) ,
214
- NO_EXPANSION ,
215
214
) ;
216
215
assert_eq ! ( & self . span_to_snippet( span) . unwrap( ) [ ..] , substring) ;
217
216
return span;
0 commit comments