Skip to content

Rollup of 8 pull requests #62424

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
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
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
16b37b5
Update linked OpenSSL version
alexcrichton Jun 26, 2019
05f4a57
forward read_c_str method from Memory to Alloc
RalfJung Jun 30, 2019
2bad604
request at least ptr-size alignment from posix_memalign
RalfJung Jul 2, 2019
576369b
improve and deduplicate comments
RalfJung Jul 2, 2019
45e7ba9
test more possible overaligned requests
RalfJung Jul 2, 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
2e47fc3
fix unused-import error on android
RalfJung Jul 3, 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
8ad28cd
Machine: make self-like parameters come first
RalfJung Jul 2, 2019
127610b
Go back to just passing MemoryExtra to the machine-level allocation h…
RalfJung Jul 2, 2019
1297a27
Add basic support for "other" kinds of values for function pointers, …
RalfJung Jun 30, 2019
5612feb
add machine hook to handle calls to 'extra' function values
RalfJung Jun 30, 2019
486720f
fix determinig the size of foreign static allocations
RalfJung Jun 30, 2019
b4be08a
fix for tidy
RalfJung Jun 30, 2019
842bbd2
make Memory::get_fn take a Scalar like most of the Memory API surface
RalfJung Jul 1, 2019
956a3ef
more inlining
RalfJung Jul 2, 2019
52e6f85
organize methods a bit better
RalfJung Jul 2, 2019
317c6ac
use get_size_and_align to test if an allocation is live
RalfJung Jul 1, 2019
d9d6b3b
turns out that dangling pointer branch is dead code; remove it and im…
RalfJung Jul 1, 2019
ceb496c
improve validity error range printing for singleton ranges
RalfJung Jul 1, 2019
3640d93
test: output-type-permutations: Clean up .dll.a as well
chouquette Jul 4, 2019
12672e2
Add test for ICE #62375
wesleywiser Jul 4, 2019
a5a2649
Rollup merge of #60260 - videolabs:rust_uwp2, r=alexcrichton
Centril Jul 5, 2019
ce92353
Rollup merge of #62151 - alexcrichton:update-openssl, r=Mark-Simulacrum
Centril Jul 5, 2019
08cd2b3
Rollup merge of #62245 - RalfJung:miri-extra-fn, r=eddyb,zackmdavis
Centril Jul 5, 2019
d11dc9e
Rollup merge of #62257 - RalfJung:miri-c-str, r=estebank
Centril Jul 5, 2019
015df68
Rollup merge of #62264 - RalfJung:inline-forcing, r=zackmdavis
Centril Jul 5, 2019
6cffcc9
Rollup merge of #62296 - RalfJung:memalign, r=alexcrichton
Centril Jul 5, 2019
e42e51e
Rollup merge of #62329 - matklad:no-peeking, r=petrochenkov
Centril Jul 5, 2019
a5ab8b2
Rollup merge of #62377 - wesleywiser:fix_62375, r=alexcrichton
Centril Jul 5, 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
remove peek_span_src_raw from StringReader
  • Loading branch information
matklad committed Jul 4, 2019
commit 256df83f642ff3cfff82b266edc7d9bbe3fd2ecc
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/span_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a> SpanUtils<'a> {
pub fn sub_span_of_token(&self, span: Span, tok: TokenKind) -> Option<Span> {
let mut toks = self.retokenise_span(span);
loop {
let next = toks.real_token();
let next = toks.next_token();
if next == token::Eof {
return None;
}
Expand Down
98 changes: 37 additions & 61 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ pub struct StringReader<'a> {
crate source_file: Lrc<syntax_pos::SourceFile>,
/// Stop reading src at this index.
crate end_src_index: usize,
// cached:
peek_span_src_raw: Span,
fatal_errs: Vec<DiagnosticBuilder<'a>>,
// cache a direct reference to the source text, so that we don't have to
// retrieve it via `self.source_file.src.as_ref().unwrap()` all the time.
Expand All @@ -59,7 +57,7 @@ impl<'a> StringReader<'a> {
(real, raw)
}

fn unwrap_or_abort(&mut self, res: Result<Token, ()>) -> Token {
fn unwrap_or_abort<T>(&mut self, res: Result<T, ()>) -> T {
match res {
Ok(tok) => tok,
Err(_) => {
Expand All @@ -69,36 +67,52 @@ impl<'a> StringReader<'a> {
}
}

fn next_token(&mut self) -> Token where Self: Sized {
let res = self.try_next_token();
self.unwrap_or_abort(res)
}

/// Returns the next token. EFFECT: advances the string_reader.
pub fn try_next_token(&mut self) -> Result<Token, ()> {
assert!(self.fatal_errs.is_empty());
self.advance_token()
let (token, _raw_span) = self.try_next_token_with_raw_span()?;
Ok(token)
}

fn try_real_token(&mut self) -> Result<Token, ()> {
let mut t = self.try_next_token()?;
pub fn next_token(&mut self) -> Token {
let res = self.try_next_token();
self.unwrap_or_abort(res)
}

fn try_real_token(&mut self) -> Result<(Token, Span), ()> {
loop {
match t.kind {
token::Whitespace | token::Comment | token::Shebang(_) => {
t = self.try_next_token()?;
}
_ => break,
let t = self.try_next_token_with_raw_span()?;
match t.0.kind {
token::Whitespace | token::Comment | token::Shebang(_) => continue,
_ => return Ok(t),
}
}

Ok(t)
}

pub fn real_token(&mut self) -> Token {
fn real_token(&mut self) -> (Token, Span) {
let res = self.try_real_token();
self.unwrap_or_abort(res)
}

fn try_next_token_with_raw_span(&mut self) -> Result<(Token, Span), ()> {
assert!(self.fatal_errs.is_empty());
match self.scan_whitespace_or_comment() {
Some(comment) => {
let raw_span = comment.span;
Ok((comment, raw_span))
}
None => {
let (kind, start_pos, end_pos) = if self.is_eof() {
(token::Eof, self.source_file.end_pos, self.source_file.end_pos)
} else {
let start_pos = self.pos;
(self.next_token_inner()?, start_pos, self.pos)
};
let (real, raw) = self.mk_sp_and_raw(start_pos, end_pos);
Ok((Token::new(kind, real), raw))
}
}
}

#[inline]
fn is_eof(&self) -> bool {
self.ch.is_none()
Expand Down Expand Up @@ -141,7 +155,6 @@ impl<'a> StringReader<'a> {
override_span: Option<Span>) -> Self {
let mut sr = StringReader::new_raw_internal(sess, source_file, override_span);
sr.bump();

sr
}

Expand All @@ -162,7 +175,6 @@ impl<'a> StringReader<'a> {
ch: Some('\n'),
source_file,
end_src_index: src.len(),
peek_span_src_raw: syntax_pos::DUMMY_SP,
src,
fatal_errs: Vec::new(),
override_span,
Expand All @@ -172,12 +184,8 @@ impl<'a> StringReader<'a> {
pub fn new_or_buffered_errs(sess: &'a ParseSess,
source_file: Lrc<syntax_pos::SourceFile>,
override_span: Option<Span>) -> Result<Self, Vec<Diagnostic>> {
let mut sr = StringReader::new_raw(sess, source_file, override_span);
if sr.advance_token().is_err() {
Err(sr.buffer_fatal_errors())
} else {
Ok(sr)
}
let sr = StringReader::new_raw(sess, source_file, override_span);
Ok(sr)
}

pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
Expand All @@ -197,11 +205,6 @@ impl<'a> StringReader<'a> {

sr.bump();

if sr.advance_token().is_err() {
sr.emit_fatal_errors();
FatalError.raise();
}

sr
}

Expand Down Expand Up @@ -257,28 +260,6 @@ impl<'a> StringReader<'a> {
self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..])
}

/// Advance peek_token to refer to the next token, and
/// possibly update the interner.
fn advance_token(&mut self) -> Result<Token, ()> {
match self.scan_whitespace_or_comment() {
Some(comment) => {
self.peek_span_src_raw = comment.span;
Ok(comment)
}
None => {
let (kind, start_pos, end_pos) = if self.is_eof() {
(token::Eof, self.source_file.end_pos, self.source_file.end_pos)
} else {
let start_pos = self.pos;
(self.next_token_inner()?, start_pos, self.pos)
};
let (real, raw) = self.mk_sp_and_raw(start_pos, end_pos);
self.peek_span_src_raw = raw;
Ok(Token::new(kind, real))
}
}
}

#[inline]
fn src_index(&self, pos: BytePos) -> usize {
(pos - self.source_file.start_pos).to_usize()
Expand Down Expand Up @@ -1447,12 +1428,7 @@ mod tests {
teststr: String)
-> StringReader<'a> {
let sf = sm.new_source_file(PathBuf::from(teststr.clone()).into(), teststr);
let mut sr = StringReader::new_raw(sess, sf, None);
if sr.advance_token().is_err() {
sr.emit_fatal_errors();
FatalError.raise();
}
sr
StringReader::new_raw(sess, sf, None)
}

#[test]
Expand Down
15 changes: 8 additions & 7 deletions src/libsyntax/parse/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use syntax_pos::Span;
use syntax_pos::{Span, DUMMY_SP};

use crate::print::pprust::token_to_string;
use crate::parse::lexer::{StringReader, UnmatchedBrace};
Expand All @@ -11,6 +11,7 @@ impl<'a> StringReader<'a> {
let mut tt_reader = TokenTreesReader {
string_reader: self,
token: Token::dummy(),
raw_span: DUMMY_SP,
open_braces: Vec::new(),
unmatched_braces: Vec::new(),
matching_delim_spans: Vec::new(),
Expand All @@ -24,6 +25,7 @@ impl<'a> StringReader<'a> {
struct TokenTreesReader<'a> {
string_reader: StringReader<'a>,
token: Token,
raw_span: Span,
/// Stack of open delimiters and their spans. Used for error message.
open_braces: Vec<(token::DelimToken, Span)>,
unmatched_braces: Vec<UnmatchedBrace>,
Expand Down Expand Up @@ -206,18 +208,17 @@ impl<'a> TokenTreesReader<'a> {
// Note that testing for joint-ness here is done via the raw
// source span as the joint-ness is a property of the raw source
// rather than wanting to take `override_span` into account.
// Additionally, we actually check if the *next* pair of tokens
// is joint, but this is equivalent to checking the current pair.
let raw = self.string_reader.peek_span_src_raw;
let raw_span = self.raw_span;
self.real_token();
let is_joint = raw.hi() == self.string_reader.peek_span_src_raw.lo()
&& self.token.is_op();
let is_joint = raw_span.hi() == self.raw_span.lo() && self.token.is_op();
Ok((tt, if is_joint { Joint } else { NonJoint }))
}
}
}

fn real_token(&mut self) {
self.token = self.string_reader.real_token();
let (token, raw_span) = self.string_reader.real_token();
self.token = token;
self.raw_span = raw_span;
}
}