|
1 | 1 | use crate::ast::{self, Ident};
|
2 |
| -use crate::source_map::{SourceMap, FilePathMapping}; |
3 | 2 | use crate::parse::{token, ParseSess};
|
4 | 3 | use crate::symbol::Symbol;
|
5 | 4 |
|
6 | 5 | use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder};
|
7 |
| -use syntax_pos::{BytePos, CharPos, Pos, Span, NO_EXPANSION}; |
| 6 | +use syntax_pos::{BytePos, Pos, Span, NO_EXPANSION}; |
8 | 7 | use core::unicode::property::Pattern_White_Space;
|
9 | 8 |
|
10 | 9 | use std::borrow::Cow;
|
@@ -667,14 +666,9 @@ impl<'a> StringReader<'a> {
|
667 | 666 | return None;
|
668 | 667 | }
|
669 | 668 |
|
670 |
| - // I guess this is the only way to figure out if |
671 |
| - // we're at the beginning of the file... |
672 |
| - let smap = SourceMap::new(FilePathMapping::empty()); |
673 |
| - smap.files.borrow_mut().source_files.push(self.source_file.clone()); |
674 |
| - let loc = smap.lookup_char_pos_adj(self.pos); |
675 |
| - debug!("Skipping a shebang"); |
676 |
| - if loc.line == 1 && loc.col == CharPos(0) { |
677 |
| - // FIXME: Add shebang "token", return it |
| 669 | + let is_beginning_of_file = self.pos == self.source_file.start_pos; |
| 670 | + if is_beginning_of_file { |
| 671 | + debug!("Skipping a shebang"); |
678 | 672 | let start = self.pos;
|
679 | 673 | while !self.ch_is('\n') && !self.is_eof() {
|
680 | 674 | self.bump();
|
@@ -1911,7 +1905,7 @@ mod tests {
|
1911 | 1905 |
|
1912 | 1906 | use crate::ast::{Ident, CrateConfig};
|
1913 | 1907 | use crate::symbol::Symbol;
|
1914 |
| - use crate::source_map::SourceMap; |
| 1908 | + use crate::source_map::{SourceMap, FilePathMapping}; |
1915 | 1909 | use crate::feature_gate::UnstableFeatures;
|
1916 | 1910 | use crate::parse::token;
|
1917 | 1911 | use crate::diagnostics::plugin::ErrorMap;
|
|
0 commit comments