From e8e13f04b2218fbc5faa9774a1b5bba9296f3389 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Sat, 13 Jul 2019 01:34:00 +0000 Subject: [PATCH 01/10] simplify std::io::Write::write rustdoc The std::io::Write::write method currensly suggests consumers guaranteed that `0 <= n <= buf.len()`, for `Ok(n)`, however `n` is of type `usize` causing the compiler to emit a warning: ``` warning: comparison is useless due to type limits --> lib.rs:6:18 | 6 | Ok(n) => 0 <= n && n <= output.len(), | ^^^^^^ | = note: #[warn(unused_comparisons)] on by default ``` This PR removes the suggestion to check `0 <= n` since it is moot. r? @steveklabnik --- src/libstd/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index a8d4d1181aa4f..ebe68dba6e6ed 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -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. /// From 08a8de8181e606f009007475c743d4572758e160 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 25 Jul 2019 14:29:05 +0200 Subject: [PATCH 02/10] Add keywords item into the sidebar --- src/librustdoc/html/render.rs | 3 ++- src/test/rustdoc/keyword.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 3cd520fd4b50b..d7b8a7f1b4a0a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -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!("
  • {name}
  • ", diff --git a/src/test/rustdoc/keyword.rs b/src/test/rustdoc/keyword.rs index c721c024468dd..db5d115c6da74 100644 --- a/src/test/rustdoc/keyword.rs +++ b/src/test/rustdoc/keyword.rs @@ -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!' From f3a3290ba36b66ee091f6442fe7f0a22dc57941b Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 30 Jul 2019 04:22:09 +0200 Subject: [PATCH 03/10] Account for maybe_whole_expr in range patterns. --- src/libsyntax/parse/parser.rs | 1 + src/libsyntax/parse/token.rs | 13 +++ .../issue-63115-range-pat-interpolated.rs | 16 ++++ src/test/ui/parser/recover-range-pats.rs | 28 +++++++ src/test/ui/parser/recover-range-pats.stderr | 83 ++++++++++++++++++- 5 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/parser/issue-63115-range-pat-interpolated.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6cb965bf817d1..2fa6d20430bf1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3741,6 +3741,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 diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 472e4b474d627..d6d13c19f7183 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -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 ofmacro expansion)? + crate fn is_whole_expr(&self) -> bool { + if let Interpolated(ref nt) = self.kind { + if let NtExpr(_) | NtLiteral(_) | NtPath(_) | 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) || diff --git a/src/test/ui/parser/issue-63115-range-pat-interpolated.rs b/src/test/ui/parser/issue-63115-range-pat-interpolated.rs new file mode 100644 index 0000000000000..a7d10ca9320a6 --- /dev/null +++ b/src/test/ui/parser/issue-63115-range-pat-interpolated.rs @@ -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); +} diff --git a/src/test/ui/parser/recover-range-pats.rs b/src/test/ui/parser/recover-range-pats.rs index c66652ff4fa01..260e108315973 100644 --- a/src/test/ui/parser/recover-range-pats.rs +++ b/src/test/ui/parser/recover-range-pats.rs @@ -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); +} diff --git a/src/test/ui/parser/recover-range-pats.stderr b/src/test/ui/parser/recover-range-pats.stderr index c50d5e6eb6153..89ec059cb8234 100644 --- a/src/test/ui/parser/recover-range-pats.stderr +++ b/src/test/ui/parser/recover-range-pats.stderr @@ -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 | @@ -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 | @@ -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`. From bca1c3cfae45a372c423c5013492c8c4306779f6 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Wed, 31 Jul 2019 20:48:20 +0900 Subject: [PATCH 04/10] Add test for issue-58951 --- src/test/ui/existential_types/issue-58951.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/test/ui/existential_types/issue-58951.rs diff --git a/src/test/ui/existential_types/issue-58951.rs b/src/test/ui/existential_types/issue-58951.rs new file mode 100644 index 0000000000000..014ed8940040e --- /dev/null +++ b/src/test/ui/existential_types/issue-58951.rs @@ -0,0 +1,10 @@ +// run-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() {} From 3f461f5ec674ba42c12cb000f307c98464ed5ee7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 31 Jul 2019 19:55:01 +0300 Subject: [PATCH 05/10] cleanup StringReader fields --- src/libsyntax/parse/lexer/mod.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 3cd5464f35710..263eb1ac7a480 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -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, + 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>, - // 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, override_span: Option, } @@ -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(), @@ -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; @@ -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`, From 6551285ccaf1562eb73ca1013730165b4d415d8e Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 31 Jul 2019 21:25:11 +0200 Subject: [PATCH 06/10] Address review comments. --- src/libsyntax/parse/parser.rs | 8 ++------ src/libsyntax/parse/token.rs | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2fa6d20430bf1..ae4925ec34083 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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`. _ => {}, }; } @@ -2781,12 +2782,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 { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index d6d13c19f7183..73adb5c947c0b 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -478,10 +478,10 @@ impl Token { /// 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 ofmacro expansion)? + /// (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(_) | NtBlock(_) = **nt { + if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt { return true; } } From d033e8de217e96c0d44f87f0d5858d221e10189a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 1 Aug 2019 11:17:01 +0900 Subject: [PATCH 07/10] Change to check-pass --- src/test/ui/existential_types/issue-58951.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/existential_types/issue-58951.rs b/src/test/ui/existential_types/issue-58951.rs index 014ed8940040e..410dcdfe347ed 100644 --- a/src/test/ui/existential_types/issue-58951.rs +++ b/src/test/ui/existential_types/issue-58951.rs @@ -1,4 +1,4 @@ -// run-pass +// check-pass #![feature(existential_type)] existential type A: Iterator; From 8d9377822de8207e7a63002837abece28f754994 Mon Sep 17 00:00:00 2001 From: Baoshan Pang Date: Wed, 31 Jul 2019 17:09:07 -0700 Subject: [PATCH 08/10] issue-2214.rs: lgamma is lgamma on vxWorks ignore process-envs.rs and process-remove-from-env.rs as there is no 'env' on vxWorks --- src/test/ui/issues/issue-2214.rs | 5 ++++- src/test/ui/process/process-envs.rs | 1 + src/test/ui/process/process-remove-from-env.rs | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/ui/issues/issue-2214.rs b/src/test/ui/issues/issue-2214.rs index 22f33545cb909..c4c56cd109d67 100644 --- a/src/test/ui/issues/issue-2214.rs +++ b/src/test/ui/issues/issue-2214.rs @@ -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; } } diff --git a/src/test/ui/process/process-envs.rs b/src/test/ui/process/process-envs.rs index a7779c55f1f92..62a4733f89a03 100644 --- a/src/test/ui/process/process-envs.rs +++ b/src/test/ui/process/process-envs.rs @@ -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; diff --git a/src/test/ui/process/process-remove-from-env.rs b/src/test/ui/process/process-remove-from-env.rs index 32cbb6ac85ac8..3fee9e2abb9f8 100644 --- a/src/test/ui/process/process-remove-from-env.rs +++ b/src/test/ui/process/process-remove-from-env.rs @@ -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; From b0913567a06c3dc5f1a5dd28312ffaa6982d58f8 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Thu, 1 Aug 2019 12:38:37 +0700 Subject: [PATCH 09/10] Fix typos in release notes. --- RELEASES.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 51cd6578ec531..7ad739d06d54f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -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 @@ -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`. - [You can now convert a `&Option` into `Option<&T>` and `&mut Option` into `Option<&mut T>` using the `From` trait.][53218] @@ -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. @@ -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 ------------------- From 8f8b3f26c2aac88b8d9ad4a43124142724f29df0 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 1 Aug 2019 11:34:53 +0200 Subject: [PATCH 10/10] ci: forward the TOOLSTATE_PUBLISH environment variable inside docker A recent commit modified toolstate to only push updated data when the TOOLSTATE_PUBLISH environment variable is present. This worked fine on Windows but failed on Linux, since Linux jobs run inside Docker containers and the variable wasn't forwarded inside it. This changes the Docker startup code to set the TOOLSTATE_PUBLISH enviornment variable inside the container if it's present outside. --- src/ci/docker/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 7d3f013ea0172..415d6b63eb8dc 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -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 \