Skip to content
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

Rollup of 8 pull requests #63194

Merged
merged 18 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
8 changes: 4 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ Compiler
--------
- [You can now set a linker flavor for `rustc` with the `-Clinker-flavor`
command line argument.][56351]
- [The mininum required LLVM version has been bumped to 6.0.][56642]
- [The minimum required LLVM version has been bumped to 6.0.][56642]
- [Added support for the PowerPC64 architecture on FreeBSD.][57615]
- [The `x86_64-fortanix-unknown-sgx` target support has been upgraded to
tier 2 support.][57130] Visit the [platform support][platform-support] page for
Expand Down Expand Up @@ -970,7 +970,7 @@ Compiler

Libraries
---------
- [You can now convert `num::NonZero*` types to their raw equivalvents using the
- [You can now convert `num::NonZero*` types to their raw equivalents using the
`From` trait.][54240] E.g. `u8` now implements `From<NonZeroU8>`.
- [You can now convert a `&Option<T>` into `Option<&T>` and `&mut Option<T>`
into `Option<&mut T>` using the `From` trait.][53218]
Expand Down Expand Up @@ -1163,7 +1163,7 @@ Security Notes
caused by an integer overflow. This has been fixed by deterministically
panicking when an overflow happens.

Thank you to Scott McMurray for responsibily disclosing this vulnerability to
Thank you to Scott McMurray for responsibly disclosing this vulnerability to
us.


Expand Down Expand Up @@ -1435,7 +1435,7 @@ Security Notes
given machine. This release fixes that vulnerability; you can read
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].

Thank you to Red Hat for responsibily disclosing this vulnerability to us.
Thank you to Red Hat for responsibly disclosing this vulnerability to us.

Compatibility Notes
-------------------
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ docker \
--env BUILD_SOURCEBRANCHNAME \
--env TOOLSTATE_REPO_ACCESS_TOKEN \
--env TOOLSTATE_REPO \
--env TOOLSTATE_PUBLISH \
--env CI_JOB_NAME="${CI_JOB_NAME-$IMAGE}" \
--init \
--rm \
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5007,7 +5007,8 @@ fn sidebar_module(fmt: &mut fmt::Formatter<'_>, _it: &clean::Item,
ItemType::Enum, ItemType::Constant, ItemType::Static, ItemType::Trait,
ItemType::Function, ItemType::Typedef, ItemType::Union, ItemType::Impl,
ItemType::TyMethod, ItemType::Method, ItemType::StructField, ItemType::Variant,
ItemType::AssocType, ItemType::AssocConst, ItemType::ForeignType] {
ItemType::AssocType, ItemType::AssocConst, ItemType::ForeignType,
ItemType::Keyword] {
if items.iter().any(|it| !it.is_stripped() && it.type_() == myty) {
let (short, name) = item_ty_to_strs(&myty);
sidebar.push_str(&format!("<li><a href=\"#{id}\">{name}</a></li>",
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ pub trait Write {
/// an [`Err`] variant.
///
/// If the return value is [`Ok(n)`] then it must be guaranteed that
/// `0 <= n <= buf.len()`. A return value of `0` typically means that the
/// `n <= buf.len()`. A return value of `0` typically means that the
/// underlying object is no longer able to accept bytes and will likely not
/// be able to in the future as well, or that the buffer provided is empty.
///
Expand Down
23 changes: 11 additions & 12 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ pub struct UnmatchedBrace {
}

pub struct StringReader<'a> {
crate sess: &'a ParseSess,
/// The absolute offset within the source_map of the current character
crate pos: BytePos,
/// The current character (which has been read from self.pos)
crate source_file: Lrc<syntax_pos::SourceFile>,
sess: &'a ParseSess,
/// Initial position, read-only.
start_pos: BytePos,
/// The absolute offset within the source_map of the current character.
pos: BytePos,
/// Stop reading src at this index.
crate end_src_index: usize,
end_src_index: usize,
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.
/// Source text to tokenize.
src: Lrc<String>,
override_span: Option<Span>,
}
Expand All @@ -56,8 +55,8 @@ impl<'a> StringReader<'a> {

StringReader {
sess,
start_pos: source_file.start_pos,
pos: source_file.start_pos,
source_file,
end_src_index: src.len(),
src,
fatal_errs: Vec::new(),
Expand Down Expand Up @@ -108,12 +107,12 @@ impl<'a> StringReader<'a> {
let text: &str = &self.src[start_src_index..self.end_src_index];

if text.is_empty() {
let span = self.mk_sp(self.source_file.end_pos, self.source_file.end_pos);
let span = self.mk_sp(self.pos, self.pos);
return Ok(Token::new(token::Eof, span));
}

{
let is_beginning_of_file = self.pos == self.source_file.start_pos;
let is_beginning_of_file = self.pos == self.start_pos;
if is_beginning_of_file {
if let Some(shebang_len) = rustc_lexer::strip_shebang(text) {
let start = self.pos;
Expand Down Expand Up @@ -533,7 +532,7 @@ impl<'a> StringReader<'a> {

#[inline]
fn src_index(&self, pos: BytePos) -> usize {
(pos - self.source_file.start_pos).to_usize()
(pos - self.start_pos).to_usize()
}

/// Slice of the source text from `start` up to but excluding `self.pos`,
Expand Down
9 changes: 3 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ macro_rules! maybe_whole_expr {
$p.token.span, ExprKind::Block(block, None), ThinVec::new()
));
}
// N.B: `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
_ => {},
};
}
Expand Down Expand Up @@ -2756,12 +2757,7 @@ impl<'a> Parser<'a> {
// can't continue an expression after an ident
token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw),
token::Literal(..) | token::Pound => true,
token::Interpolated(ref nt) => match **nt {
token::NtIdent(..) | token::NtExpr(..) |
token::NtBlock(..) | token::NtPath(..) => true,
_ => false,
},
_ => false
_ => t.is_whole_expr(),
};
let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr);
if cannot_continue_expr {
Expand Down Expand Up @@ -3728,6 +3724,7 @@ impl<'a> Parser<'a> {
self.token.is_path_start() // e.g. `MY_CONST`;
|| self.token == token::Dot // e.g. `.5` for recovery;
|| self.token.can_begin_literal_or_bool() // e.g. `42`.
|| self.token.is_whole_expr()
}

// Helper function to decide whether to parse as ident binding
Expand Down
13 changes: 13 additions & 0 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,19 @@ impl Token {
false
}

/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
/// That is, is this a pre-parsed expression dropped into the token stream
/// (which happens while parsing the result of macro expansion)?
crate fn is_whole_expr(&self) -> bool {
if let Interpolated(ref nt) = self.kind {
if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
return true;
}
}

false
}

/// Returns `true` if the token is either the `mut` or `const` keyword.
crate fn is_mutability(&self) -> bool {
self.is_keyword(kw::Mut) ||
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc/keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// @has foo/index.html '//h2[@id="keywords"]' 'Keywords'
// @has foo/index.html '//a[@href="keyword.match.html"]' 'match'
// @has foo/index.html '//div[@class="block items"]//a/@href' '#keywords'
// @has foo/keyword.match.html '//a[@class="keyword"]' 'match'
// @has foo/keyword.match.html '//span[@class="in-band"]' 'Keyword match'
// @has foo/keyword.match.html '//section[@id="main"]//div[@class="docblock"]//p' 'this is a test!'
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/existential_types/issue-58951.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass
#![feature(existential_type)]

existential type A: Iterator;
fn def_a() -> A { 0..1 }
pub fn use_a() {
def_a().map(|x| x);
}

fn main() {}
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-2214.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ mod m {

#[link_name = "m"]
extern {
#[cfg(any(unix, target_os = "cloudabi"))]
#[cfg(any(all(unix, not(target_os = "vxworks")), target_os = "cloudabi"))]
#[link_name="lgamma_r"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
#[cfg(windows)]
#[link_name="lgamma"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
#[cfg(target_os = "vxworks")]
#[link_name="lgamma"]
pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double;
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/parser/issue-63115-range-pat-interpolated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass

#![feature(exclusive_range_pattern)]

#![allow(ellipsis_inclusive_range_patterns)]

fn main() {
macro_rules! mac_expr {
($e:expr) => {
if let 2...$e = 3 {}
if let 2..=$e = 3 {}
if let 2..$e = 3 {}
}
}
mac_expr!(4);
}
28 changes: 28 additions & 0 deletions src/test/ui/parser/recover-range-pats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,31 @@ fn inclusive2_to() {
//~| ERROR `...` range patterns are deprecated
//~| ERROR mismatched types
}

fn with_macro_expr_var() {
macro_rules! mac2 {
($e1:expr, $e2:expr) => {
let $e1..$e2;
let $e1...$e2;
//~^ ERROR `...` range patterns are deprecated
let $e1..=$e2;
}
}

mac2!(0, 1);

macro_rules! mac {
($e:expr) => {
let ..$e; //~ ERROR `..X` range patterns are not supported
let ...$e; //~ ERROR `...X` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
let ..=$e; //~ ERROR `..=X` range patterns are not supported
let $e..; //~ ERROR `X..` range patterns are not supported
let $e...; //~ ERROR `X...` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
let $e..=; //~ ERROR `X..=` range patterns are not supported
}
}

mac!(0);
}
83 changes: 82 additions & 1 deletion src/test/ui/parser/recover-range-pats.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,60 @@ error: `...X` range patterns are not supported
LL | if let ....3 = 0 {}
| ^^^^^ help: try using the minimum value for the type: `MIN...0.3`

error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:139:17
|
LL | let ..$e;
| ^^ help: try using the minimum value for the type: `MIN..0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:140:17
|
LL | let ...$e;
| ^^^ help: try using the minimum value for the type: `MIN...0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:142:17
|
LL | let ..=$e;
| ^^^ help: try using the minimum value for the type: `MIN..=0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:143:19
|
LL | let $e..;
| ^^ help: try using the maximum value for the type: `0..MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:144:19
|
LL | let $e...;
| ^^^ help: try using the maximum value for the type: `0...MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:146:19
|
LL | let $e..=;
| ^^^ help: try using the maximum value for the type: `0..=MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:41:13
|
Expand Down Expand Up @@ -316,6 +370,33 @@ error: `...` range patterns are deprecated
LL | if let ....3 = 0 {}
| ^^^ help: use `..=` for an inclusive range

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:129:20
|
LL | let $e1...$e2;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac2!(0, 1);
| ------------ in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:140:17
|
LL | let ...$e;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac!(0);
| -------- in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:144:19
|
LL | let $e...;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac!(0);
| -------- in this macro invocation

error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:19:12
|
Expand Down Expand Up @@ -532,7 +613,7 @@ LL | if let ....3 = 0 {}
= note: expected type `{integer}`
found type `{float}`

error: aborting due to 76 previous errors
error: aborting due to 85 previous errors

Some errors have detailed explanations: E0029, E0308.
For more information about an error, try `rustc --explain E0029`.
1 change: 1 addition & 0 deletions src/test/ui/process/process-envs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
// ignore-sgx no processes
// ignore-vxworks no 'env'

use std::process::Command;
use std::env;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/process/process-remove-from-env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// ignore-cloudabi no processes
// ignore-emscripten no processes
// ignore-sgx no processes
// ignore-vxworks no 'env'

use std::process::Command;
use std::env;
Expand Down