Skip to content

Rollup of 8 pull requests #62372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bb26e07
Add debug assertions to write_bytes and copy*
nitnelave Feb 27, 2019
0533f12
Handle null from LLVMRustGetSectionName
nitnelave Mar 27, 2019
8a4573f
format a bit
RalfJung Jun 24, 2019
4159b27
order things more traditionally
RalfJung Jun 24, 2019
a68afc5
ignore some codegen tests in debug mode
RalfJung Jun 25, 2019
d3e1bf9
nits
RalfJung Jun 25, 2019
1c6b4d5
rustc: codegen: Build import library for all windows targets
chouquette May 27, 2019
c1b6716
libstd: windows: compat: Allow use of attributes
chouquette May 27, 2019
863cd6b
bootstrap: Build startup object for all windows-gnu target
chouquette May 27, 2019
e5d7043
std: Link UWP with allowed libraries only
chouquette May 27, 2019
98f9bba
libunwind: Use libunwind when targeting UWP
chouquette May 27, 2019
20eb746
std: rand: Use BCrypt on UWP
chouquette May 27, 2019
0f15466
std: win: Don't use SetHandleInformation on UWP
chouquette May 27, 2019
5466e9f
std: win: Don't expose link() on UWP
chouquette May 27, 2019
b514557
std: win: Don't use GetUserProfileDirectoryW on UWP
chouquette May 27, 2019
07d11ae
std: win: Don't use GetFileInformationByHandle on UWP
chouquette May 27, 2019
a7ad699
std: win: Don't use console APIs on UWP
chouquette May 27, 2019
1a0a263
std: win: Disable stack overflow handling on UWP
chouquette May 27, 2019
1726259
Add UWP targets
chouquette May 27, 2019
0ffb643
Make sure `#[rustc_doc_only_macro]` and other rustc attributes are re…
petrochenkov Jun 29, 2019
e4e7eb2
Feature gate `rustc` attributes harder
petrochenkov Jun 30, 2019
069c52f
Check if the archive has already been added to avoid duplicates
petrhosek Jul 2, 2019
ec8c2e1
Use a single CtxtInterners
Zoxc May 31, 2019
de8bf5b
libstd: windows: Use qualified path for cfg_if
chouquette Jul 3, 2019
848962f
libstd: windows: Use cfg_if instead of NIH ifdef macro
chouquette Jul 3, 2019
096a2a2
libstd: windows: Reindent after last change
chouquette Jul 3, 2019
bb7fbb9
Add separate 'async_closure' feature gate.
Centril Jul 2, 2019
43315bc
Adjust tests wrt. 'async_closure' feature gate.
Centril Jul 2, 2019
830ff4a
remove StringReader::peek
matklad Jul 2, 2019
e9dc95c
remove peek_token from StringReader
matklad Jul 2, 2019
256df83
remove peek_span_src_raw from StringReader
matklad Jul 3, 2019
601bad8
cleanup lexer constructors
matklad Jul 3, 2019
30fa99e
move constructors to top
matklad Jul 3, 2019
1c6eb19
slightly comment lexer API
matklad Jul 3, 2019
8bea334
don't rely on spans when checking tokens for jointness
matklad Jul 3, 2019
3035a05
remove unused mk_sp_and_raw
matklad Jul 3, 2019
3e362a4
make unwrap_or_abort non-generic again
matklad Jul 3, 2019
55bd214
Add tracking issue for Box::into_pin
Nemo157 Jul 4, 2019
356a8a7
Rollup merge of #60260 - videolabs:rust_uwp2, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
bfe2925
Rollup merge of #61392 - Zoxc:single-interner, r=eddyb
Mark-Simulacrum Jul 4, 2019
7bae0b7
Rollup merge of #62103 - RalfJung:debug-assert, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
b5246fd
Rollup merge of #62133 - petrochenkov:norustc, r=eddyb
Mark-Simulacrum Jul 4, 2019
30d5f41
Rollup merge of #62286 - petrhosek:rustc-no-duplicate-archives, r=cra…
Mark-Simulacrum Jul 4, 2019
99366a9
Rollup merge of #62292 - Centril:split-async-closures, r=cramertj
Mark-Simulacrum Jul 4, 2019
7854e9e
Rollup merge of #62329 - matklad:no-peeking, r=petrochenkov
Mark-Simulacrum Jul 4, 2019
866233b
Rollup merge of #62371 - Nemo157:fix-62288, r=Centril
Mark-Simulacrum Jul 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move constructors to top
  • Loading branch information
matklad committed Jul 4, 2019
commit 30fa99e5b8c89df2c27d10a5d38a7c0d50f155a7
102 changes: 51 additions & 51 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,57 @@ pub struct StringReader<'a> {
}

impl<'a> StringReader<'a> {
pub fn new(sess: &'a ParseSess,
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Self {
let mut sr = StringReader::new_internal(sess, source_file, override_span);
sr.bump();
sr
}

pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
let begin = sess.source_map().lookup_byte_offset(span.lo());
let end = sess.source_map().lookup_byte_offset(span.hi());

// Make the range zero-length if the span is invalid.
if span.lo() > span.hi() || begin.sf.start_pos != end.sf.start_pos {
span = span.shrink_to_lo();
}

let mut sr = StringReader::new_internal(sess, begin.sf, None);

// Seek the lexer to the right byte range.
sr.next_pos = span.lo();
sr.end_src_index = sr.src_index(span.hi());

sr.bump();

sr
}

fn new_internal(sess: &'a ParseSess, source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Self
{
if source_file.src.is_none() {
sess.span_diagnostic.bug(&format!("Cannot lex source_file without source: {}",
source_file.name));
}

let src = (*source_file.src.as_ref().unwrap()).clone();

StringReader {
sess,
next_pos: source_file.start_pos,
pos: source_file.start_pos,
ch: Some('\n'),
source_file,
end_src_index: src.len(),
src,
fatal_errs: Vec::new(),
override_span,
}
}

fn mk_sp(&self, lo: BytePos, hi: BytePos) -> Span {
self.mk_sp_and_raw(lo, hi).0
}
Expand Down Expand Up @@ -149,57 +200,6 @@ impl<'a> StringReader<'a> {
buffer
}

pub fn new(sess: &'a ParseSess,
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Self {
let mut sr = StringReader::new_internal(sess, source_file, override_span);
sr.bump();
sr
}

fn new_internal(sess: &'a ParseSess, source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Self
{
if source_file.src.is_none() {
sess.span_diagnostic.bug(&format!("Cannot lex source_file without source: {}",
source_file.name));
}

let src = (*source_file.src.as_ref().unwrap()).clone();

StringReader {
sess,
next_pos: source_file.start_pos,
pos: source_file.start_pos,
ch: Some('\n'),
source_file,
end_src_index: src.len(),
src,
fatal_errs: Vec::new(),
override_span,
}
}

pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
let begin = sess.source_map().lookup_byte_offset(span.lo());
let end = sess.source_map().lookup_byte_offset(span.hi());

// Make the range zero-length if the span is invalid.
if span.lo() > span.hi() || begin.sf.start_pos != end.sf.start_pos {
span = span.shrink_to_lo();
}

let mut sr = StringReader::new_internal(sess, begin.sf, None);

// Seek the lexer to the right byte range.
sr.next_pos = span.lo();
sr.end_src_index = sr.src_index(span.hi());

sr.bump();

sr
}

#[inline]
fn ch_is(&self, c: char) -> bool {
self.ch == Some(c)
Expand Down