Rollup merge of #59687 - matklad:shebang, r=petrochenkov
cleanup shebang handling in the lexer
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
use crate::ast::{self, Ident};
|
use crate::ast::{self, Ident};
|
||||||
use crate::source_map::{SourceMap, FilePathMapping};
|
|
||||||
use crate::parse::{token, ParseSess};
|
use crate::parse::{token, ParseSess};
|
||||||
use crate::symbol::Symbol;
|
use crate::symbol::Symbol;
|
||||||
|
|
||||||
use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder};
|
use errors::{Applicability, FatalError, Diagnostic, DiagnosticBuilder};
|
||||||
use syntax_pos::{BytePos, CharPos, Pos, Span, NO_EXPANSION};
|
use syntax_pos::{BytePos, Pos, Span, NO_EXPANSION};
|
||||||
use core::unicode::property::Pattern_White_Space;
|
use core::unicode::property::Pattern_White_Space;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@@ -667,14 +666,9 @@ impl<'a> StringReader<'a> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I guess this is the only way to figure out if
|
let is_beginning_of_file = self.pos == self.source_file.start_pos;
|
||||||
// we're at the beginning of the file...
|
if is_beginning_of_file {
|
||||||
let smap = SourceMap::new(FilePathMapping::empty());
|
|
||||||
smap.files.borrow_mut().source_files.push(self.source_file.clone());
|
|
||||||
let loc = smap.lookup_char_pos_adj(self.pos);
|
|
||||||
debug!("Skipping a shebang");
|
debug!("Skipping a shebang");
|
||||||
if loc.line == 1 && loc.col == CharPos(0) {
|
|
||||||
// FIXME: Add shebang "token", return it
|
|
||||||
let start = self.pos;
|
let start = self.pos;
|
||||||
while !self.ch_is('\n') && !self.is_eof() {
|
while !self.ch_is('\n') && !self.is_eof() {
|
||||||
self.bump();
|
self.bump();
|
||||||
@@ -1911,7 +1905,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::ast::{Ident, CrateConfig};
|
use crate::ast::{Ident, CrateConfig};
|
||||||
use crate::symbol::Symbol;
|
use crate::symbol::Symbol;
|
||||||
use crate::source_map::SourceMap;
|
use crate::source_map::{SourceMap, FilePathMapping};
|
||||||
use crate::feature_gate::UnstableFeatures;
|
use crate::feature_gate::UnstableFeatures;
|
||||||
use crate::parse::token;
|
use crate::parse::token;
|
||||||
use crate::diagnostics::plugin::ErrorMap;
|
use crate::diagnostics::plugin::ErrorMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user