Skip to content

Commit

Permalink
Auto merge of rust-lang#70244 - Mark-Simulacrum:beta-next, r=Mark-Sim…
Browse files Browse the repository at this point in the history
…ulacrum

[beta] backport rollup

This backports:
* can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs. rust-lang#70058
* ci: use python from the correct path rust-lang#70116
* Update stdarch submodule rust-lang#70151 (superseding and closing rust-lang#70221)
* Beta: Update cargo, clippy rust-lang#70105 (also closing that beta-targeted PR)

It also switches the bootstrap compiler to download from static.rust-lang.org from dev-static.rust-lang.org.
  • Loading branch information
bors committed Mar 22, 2020
2 parents 4a71daf + b81cfb2 commit 1eaaee9
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 23 deletions.
13 changes: 6 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ dependencies = [
"clippy_lints",
"compiletest_rs",
"derive-new",
"git2",
"lazy_static 1.4.0",
"regex",
"rustc-workspace-hack",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions src/ci/scripts/install-msys2-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 13 additions & 4 deletions src/librustc_ast/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl Token {
NtExpr(..) | NtBlock(..) | NtLiteral(..) => true,
_ => false,
},
_ => self.can_begin_literal_or_bool(),
_ => self.can_begin_literal_maybe_minus(),
}
}

Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Lit, LitError> {
let lit = match token.uninterpolate().kind {
token::Ident(name, false) if name.is_bool_lit() => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_expand/mbe/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/librustc_parse/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expr>> {
maybe_whole_expr!(self);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/stage0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/stdarch
22 changes: 21 additions & 1 deletion src/test/ui/parser/extern-abi-from-mac-literal-frag.rs
Original file line number Diff line number Diff line change
@@ -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() {}

Expand All @@ -17,10 +17,30 @@ 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");
}

mod c {
abi_from_lit_frag!("C");
}

mod rust_expr {
abi_from_expr_frag!("Rust");
}

mod c_expr {
abi_from_expr_frag!("C");
}
16 changes: 16 additions & 0 deletions src/test/ui/parser/issue-70050-ntliteral-accepts-negated-lit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass

macro_rules! foo {
($a:literal) => {
bar!($a)
};
}

macro_rules! bar {
($b:literal) => {};
}

fn main() {
foo!(-2);
bar!(-2);
}
2 changes: 1 addition & 1 deletion src/tools/clippy
Submodule clippy updated 2 files
+1 −2 Cargo.toml
+5 −3 tests/integration.rs

0 comments on commit 1eaaee9

Please sign in to comment.