@@ -127,30 +127,17 @@ pub struct StableSourceFileId(u128);
127
127
// StableSourceFileId, perhaps built atop source_file.name_hash.
128
128
impl StableSourceFileId {
129
129
pub fn new ( source_file : & SourceFile ) -> StableSourceFileId {
130
- StableSourceFileId :: new_from_pieces (
131
- & source_file. name ,
132
- source_file. name_was_remapped ,
133
- source_file. unmapped_path . as_ref ( ) ,
134
- )
130
+ StableSourceFileId :: new_from_pieces ( & source_file. name , source_file. name_was_remapped )
135
131
}
136
132
137
- fn new_from_pieces (
138
- name : & FileName ,
139
- name_was_remapped : bool ,
140
- unmapped_path : Option < & FileName > ,
141
- ) -> StableSourceFileId {
133
+ fn new_from_pieces ( name : & FileName , name_was_remapped : bool ) -> StableSourceFileId {
142
134
let mut hasher = StableHasher :: new ( ) ;
143
135
144
- if let FileName :: Real ( real_name) = name {
145
- // rust-lang/rust#70924: Use the stable (virtualized) name when
146
- // available. (We do not want artifacts from transient file system
147
- // paths for libstd to leak into our build artifacts.)
148
- real_name. stable_name ( ) . hash ( & mut hasher)
149
- } else {
150
- name. hash ( & mut hasher) ;
151
- }
136
+ // If name was virtualized, we need to take both the local path
137
+ // and stablised path into account, in case two different paths were
138
+ // mapped to the same
139
+ name. hash ( & mut hasher) ;
152
140
name_was_remapped. hash ( & mut hasher) ;
153
- unmapped_path. hash ( & mut hasher) ;
154
141
155
142
StableSourceFileId ( hasher. finish ( ) )
156
143
}
@@ -286,25 +273,21 @@ impl SourceMap {
286
273
filename : FileName ,
287
274
src : String ,
288
275
) -> Result < Lrc < SourceFile > , OffsetOverflowError > {
289
- // We need to preserve the unmapped path is as it is
290
- // used to determine the directory for loading submodules and include files.
291
276
// Note that filename may not be a valid path, eg it may be `<anon>` etc,
292
277
// but this is okay because the directory determined by `path.pop()` will
293
278
// be empty, so the working directory will be used.
294
- let ( mapped_filename , was_remapped) = self . path_mapping . map_filename_prefix ( & filename) ;
279
+ let ( filename , was_remapped) = self . path_mapping . map_filename_prefix ( & filename) ;
295
280
296
- let file_id =
297
- StableSourceFileId :: new_from_pieces ( & mapped_filename, was_remapped, Some ( & filename) ) ;
281
+ let file_id = StableSourceFileId :: new_from_pieces ( & filename, was_remapped) ;
298
282
299
283
let lrc_sf = match self . source_file_by_stable_id ( file_id) {
300
284
Some ( lrc_sf) => lrc_sf,
301
285
None => {
302
286
let start_pos = self . allocate_address_space ( src. len ( ) ) ?;
303
287
304
288
let source_file = Lrc :: new ( SourceFile :: new (
305
- mapped_filename,
306
- was_remapped,
307
289
filename,
290
+ was_remapped,
308
291
src,
309
292
Pos :: from_usize ( start_pos) ,
310
293
self . hash_kind ,
@@ -368,7 +351,6 @@ impl SourceMap {
368
351
let source_file = Lrc :: new ( SourceFile {
369
352
name : filename,
370
353
name_was_remapped : name_was_remapped || name_is_remapped,
371
- unmapped_path : None ,
372
354
src : None ,
373
355
src_hash,
374
356
external_src : Lock :: new ( ExternalSource :: Foreign {
@@ -459,14 +441,6 @@ impl SourceMap {
459
441
self . lookup_char_pos ( sp. lo ( ) ) . file . name . clone ( )
460
442
}
461
443
462
- pub fn span_to_unmapped_path ( & self , sp : Span ) -> FileName {
463
- self . lookup_char_pos ( sp. lo ( ) )
464
- . file
465
- . unmapped_path
466
- . clone ( )
467
- . expect ( "`SourceMap::span_to_unmapped_path` called for imported `SourceFile`?" )
468
- }
469
-
470
444
pub fn is_multiline ( & self , sp : Span ) -> bool {
471
445
let lo = self . lookup_char_pos ( sp. lo ( ) ) ;
472
446
let hi = self . lookup_char_pos ( sp. hi ( ) ) ;
0 commit comments