From 3e109787af3c40c534aaa77caed7352cb4255b2a Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 19 Mar 2020 14:38:09 +0000 Subject: [PATCH 1/5] Update stdarch submodule --- src/stdarch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stdarch b/src/stdarch index dea57529b3695..abe96ca3b87fc 160000 --- a/src/stdarch +++ b/src/stdarch @@ -1 +1 @@ -Subproject commit dea57529b3695605909e7d327bb6551d7a10c788 +Subproject commit abe96ca3b87fcca6aa1dfcefd40d8c8d92d2e673 From 481abaf33753af87197a56f21beb5343cfce1651 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 18 Mar 2020 18:57:37 +0100 Subject: [PATCH 2/5] ci: use python from the correct path Apparently the old path we were using for Python 2 on Windows was not documented, and eventually got removed. This switches our CI to use the correct path. --- src/ci/scripts/install-msys2-packages.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ci/scripts/install-msys2-packages.sh b/src/ci/scripts/install-msys2-packages.sh index 843a2bf2d5e55..22b9854ad5eb4 100755 --- a/src/ci/scripts/install-msys2-packages.sh +++ b/src/ci/scripts/install-msys2-packages.sh @@ -13,6 +13,7 @@ if isWindows; then # one way or another. The msys interpreters seem to have weird path conversions # baked in which break LLVM's build system one way or another, so let's use the # native version which keeps everything as native as possible. - cp C:/Python27amd64/python.exe C:/Python27amd64/python2.7.exe - ciCommandAddPath "C:\\Python27amd64" + python_home="C:/hostedtoolcache/windows/Python/2.7.17/x64" + cp "${python_home}/python.exe" "${python_home}/python2.7.exe" + ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\2.7.17\\x64" fi From 983c133c8b69c6be06344c3e3a559da3ff5d9c5f Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Mon, 16 Mar 2020 23:36:14 +0100 Subject: [PATCH 3/5] can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs. --- src/librustc_ast/token.rs | 17 ++++++++++---- src/librustc_ast/util/literal.rs | 2 +- src/librustc_expand/mbe/macro_parser.rs | 2 +- src/librustc_parse/parser/expr.rs | 1 + src/librustc_parse/parser/item.rs | 2 +- src/librustc_parse/parser/pat.rs | 2 +- .../extern-abi-from-mac-literal-frag.rs | 22 ++++++++++++++++++- ...sue-70050-ntliteral-accepts-negated-lit.rs | 16 ++++++++++++++ 8 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 src/test/ui/parser/issue-70050-ntliteral-accepts-negated-lit.rs diff --git a/src/librustc_ast/token.rs b/src/librustc_ast/token.rs index b67b7d346f756..92382c7e30d57 100644 --- a/src/librustc_ast/token.rs +++ b/src/librustc_ast/token.rs @@ -424,7 +424,7 @@ impl Token { NtExpr(..) | NtBlock(..) | NtLiteral(..) => true, _ => false, }, - _ => self.can_begin_literal_or_bool(), + _ => self.can_begin_literal_maybe_minus(), } } @@ -448,13 +448,22 @@ impl Token { /// Returns `true` if the token is any literal, a minus (which can prefix a literal, /// for example a '-42', or one of the boolean idents). /// - /// Keep this in sync with `Lit::from_token`. - pub fn can_begin_literal_or_bool(&self) -> bool { + /// In other words, would this token be a valid start of `parse_literal_maybe_minus`? + /// + /// Keep this in sync with and `Lit::from_token`, excluding unary negation. + pub fn can_begin_literal_maybe_minus(&self) -> bool { match self.uninterpolate().kind { Literal(..) | BinOp(Minus) => true, Ident(name, false) if name.is_bool_lit() => true, Interpolated(ref nt) => match &**nt { - NtExpr(e) | NtLiteral(e) => matches!(e.kind, ast::ExprKind::Lit(_)), + NtLiteral(_) => true, + NtExpr(e) => match &e.kind { + ast::ExprKind::Lit(_) => true, + ast::ExprKind::Unary(ast::UnOp::Neg, e) => { + matches!(&e.kind, ast::ExprKind::Lit(_)) + } + _ => false, + }, _ => false, }, _ => false, diff --git a/src/librustc_ast/util/literal.rs b/src/librustc_ast/util/literal.rs index d1757394f3a1d..1b17f343a6d67 100644 --- a/src/librustc_ast/util/literal.rs +++ b/src/librustc_ast/util/literal.rs @@ -189,7 +189,7 @@ impl Lit { /// Converts arbitrary token into an AST literal. /// - /// Keep this in sync with `Token::can_begin_literal_or_bool`. + /// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation. pub fn from_token(token: &Token) -> Result { let lit = match token.uninterpolate().kind { token::Ident(name, false) if name.is_bool_lit() => { diff --git a/src/librustc_expand/mbe/macro_parser.rs b/src/librustc_expand/mbe/macro_parser.rs index 6d4d7f5b4f394..a035461acc6e8 100644 --- a/src/librustc_expand/mbe/macro_parser.rs +++ b/src/librustc_expand/mbe/macro_parser.rs @@ -775,7 +775,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool { } sym::ty => token.can_begin_type(), sym::ident => get_macro_ident(token).is_some(), - sym::literal => token.can_begin_literal_or_bool(), + sym::literal => token.can_begin_literal_maybe_minus(), sym::vis => match token.kind { // The follow-set of :vis + "priv" keyword + interpolated token::Comma | token::Ident(..) | token::Interpolated(_) => true, diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 16ea2773b2009..44eee0b5f3602 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -1338,6 +1338,7 @@ impl<'a> Parser<'a> { } /// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`). + /// Keep this in sync with `Token::can_begin_literal_maybe_minus`. pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P> { maybe_whole_expr!(self); diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 126686c8defbf..deb737056df15 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1449,7 +1449,7 @@ impl<'a> Parser<'a> { }) // `extern ABI fn` || self.check_keyword(kw::Extern) - && self.look_ahead(1, |t| t.can_begin_literal_or_bool()) + && self.look_ahead(1, |t| t.can_begin_literal_maybe_minus()) && self.look_ahead(2, |t| t.is_keyword(kw::Fn)) } diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index f52a91ff5989d..687b7760d8a61 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -698,7 +698,7 @@ impl<'a> Parser<'a> { self.look_ahead(dist, |t| { t.is_path_start() // e.g. `MY_CONST`; || t.kind == token::Dot // e.g. `.5` for recovery; - || t.can_begin_literal_or_bool() // e.g. `42`. + || t.can_begin_literal_maybe_minus() // e.g. `42`. || t.is_whole_expr() }) } diff --git a/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs b/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs index cb23f2c808c34..4ecb21d26ab9b 100644 --- a/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs +++ b/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs @@ -1,7 +1,7 @@ // check-pass // In this test we check that the parser accepts an ABI string when it -// comes from a macro `literal` fragment as opposed to a hardcoded string. +// comes from a macro `literal` or `expr` fragment as opposed to a hardcoded string. fn main() {} @@ -17,6 +17,18 @@ macro_rules! abi_from_lit_frag { } } +macro_rules! abi_from_expr_frag { + ($abi:expr) => { + extern $abi { + fn _import(); + } + + extern $abi fn _export() {} + + type _PTR = extern $abi fn(); + }; +} + mod rust { abi_from_lit_frag!("Rust"); } @@ -24,3 +36,11 @@ mod rust { mod c { abi_from_lit_frag!("C"); } + +mod rust_expr { + abi_from_expr_frag!("Rust"); +} + +mod c_expr { + abi_from_expr_frag!("C"); +} diff --git a/src/test/ui/parser/issue-70050-ntliteral-accepts-negated-lit.rs b/src/test/ui/parser/issue-70050-ntliteral-accepts-negated-lit.rs new file mode 100644 index 0000000000000..aca9d9eb0a5b4 --- /dev/null +++ b/src/test/ui/parser/issue-70050-ntliteral-accepts-negated-lit.rs @@ -0,0 +1,16 @@ +// check-pass + +macro_rules! foo { + ($a:literal) => { + bar!($a) + }; +} + +macro_rules! bar { + ($b:literal) => {}; +} + +fn main() { + foo!(-2); + bar!(-2); +} From f98a4dd6d79bc02c45c97e74c7f4632d1144875b Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 21 Mar 2020 17:01:54 -0400 Subject: [PATCH 4/5] Use a non-dev-static toolchain --- src/stage0.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stage0.txt b/src/stage0.txt index ac7336631abca..e8759d9fbc1af 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2020-03-10 +date: 2020-03-12 rustc: 1.42.0 cargo: 0.43.0 @@ -40,4 +40,4 @@ cargo: 0.43.0 # looking at a beta source tarball and it's uncommented we'll shortly comment it # out. -dev: 1 +#dev: 1 From b81cfb25bcbff0bc201063f1e1cab5b7aa55380d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 18 Mar 2020 08:07:33 -0700 Subject: [PATCH 5/5] Beta: Update cargo, clippy --- Cargo.lock | 13 ++++++------- src/tools/cargo | 2 +- src/tools/clippy | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8505470a66306..d41517cd4f6b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,6 @@ dependencies = [ "clippy_lints", "compiletest_rs", "derive-new", - "git2", "lazy_static 1.4.0", "regex", "rustc-workspace-hack", @@ -1235,9 +1234,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26e07ef27260a78f7e8d218ebac2c72f2c4db50493741b190b6e8eade1da7c68" +checksum = "b7da16ceafe24cedd9ba02c4463a2b506b6493baf4317c79c5acb553134a3c15" dependencies = [ "bitflags", "libc", @@ -1250,9 +1249,9 @@ dependencies = [ [[package]] name = "git2-curl" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1754ec4170e7dcaf9bb43743bb16eddb8d827b2e0291deb6f220a6e16fe46a" +checksum = "502d532a2d06184beb3bc869d4d90236e60934e3382c921b203fa3c33e212bd7" dependencies = [ "curl", "git2", @@ -1770,9 +1769,9 @@ dependencies = [ [[package]] name = "libgit2-sys" -version = "0.11.0+0.99.0" +version = "0.12.0+0.99.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5d1459353d397a029fb18862166338de938e6be976606bd056cf8f1a912ecf" +checksum = "05dff41ac39e7b653f5f1550886cf00ba52f8e7f57210b633cdeedb3de5b236c" dependencies = [ "cc", "libc", diff --git a/src/tools/cargo b/src/tools/cargo index bda50510d1daf..3532cf738db00 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit bda50510d1daf6e9c53ad6ccf603da6e0fa8103f +Subproject commit 3532cf738db005a56d1fe81ade514f380d411360 diff --git a/src/tools/clippy b/src/tools/clippy index 329923edec41d..204bb9b54b17c 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 329923edec41d0ddbea7f30ab12fca0436d459ae +Subproject commit 204bb9b54b17cef5e5bfba4c4904ab745e6359ba