Skip to content

Commit 1eaaee9

Browse files
committed
Auto merge of #70244 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backport rollup This backports: * can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs. #70058 * ci: use python from the correct path #70116 * Update stdarch submodule #70151 (superseding and closing #70221) * Beta: Update cargo, clippy #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.
2 parents 4a71daf + b81cfb2 commit 1eaaee9

File tree

14 files changed

+69
-23
lines changed

14 files changed

+69
-23
lines changed

Cargo.lock

+6-7
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ dependencies = [
455455
"clippy_lints",
456456
"compiletest_rs",
457457
"derive-new",
458-
"git2",
459458
"lazy_static 1.4.0",
460459
"regex",
461460
"rustc-workspace-hack",
@@ -1235,9 +1234,9 @@ dependencies = [
12351234

12361235
[[package]]
12371236
name = "git2"
1238-
version = "0.12.0"
1237+
version = "0.13.0"
12391238
source = "registry+https://github.com/rust-lang/crates.io-index"
1240-
checksum = "26e07ef27260a78f7e8d218ebac2c72f2c4db50493741b190b6e8eade1da7c68"
1239+
checksum = "b7da16ceafe24cedd9ba02c4463a2b506b6493baf4317c79c5acb553134a3c15"
12411240
dependencies = [
12421241
"bitflags",
12431242
"libc",
@@ -1250,9 +1249,9 @@ dependencies = [
12501249

12511250
[[package]]
12521251
name = "git2-curl"
1253-
version = "0.13.0"
1252+
version = "0.14.0"
12541253
source = "registry+https://github.com/rust-lang/crates.io-index"
1255-
checksum = "af1754ec4170e7dcaf9bb43743bb16eddb8d827b2e0291deb6f220a6e16fe46a"
1254+
checksum = "502d532a2d06184beb3bc869d4d90236e60934e3382c921b203fa3c33e212bd7"
12561255
dependencies = [
12571256
"curl",
12581257
"git2",
@@ -1770,9 +1769,9 @@ dependencies = [
17701769

17711770
[[package]]
17721771
name = "libgit2-sys"
1773-
version = "0.11.0+0.99.0"
1772+
version = "0.12.0+0.99.0"
17741773
source = "registry+https://github.com/rust-lang/crates.io-index"
1775-
checksum = "4d5d1459353d397a029fb18862166338de938e6be976606bd056cf8f1a912ecf"
1774+
checksum = "05dff41ac39e7b653f5f1550886cf00ba52f8e7f57210b633cdeedb3de5b236c"
17761775
dependencies = [
17771776
"cc",
17781777
"libc",

src/ci/scripts/install-msys2-packages.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ if isWindows; then
1313
# one way or another. The msys interpreters seem to have weird path conversions
1414
# baked in which break LLVM's build system one way or another, so let's use the
1515
# native version which keeps everything as native as possible.
16-
cp C:/Python27amd64/python.exe C:/Python27amd64/python2.7.exe
17-
ciCommandAddPath "C:\\Python27amd64"
16+
python_home="C:/hostedtoolcache/windows/Python/2.7.17/x64"
17+
cp "${python_home}/python.exe" "${python_home}/python2.7.exe"
18+
ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\2.7.17\\x64"
1819
fi

src/librustc_ast/token.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl Token {
424424
NtExpr(..) | NtBlock(..) | NtLiteral(..) => true,
425425
_ => false,
426426
},
427-
_ => self.can_begin_literal_or_bool(),
427+
_ => self.can_begin_literal_maybe_minus(),
428428
}
429429
}
430430

@@ -448,13 +448,22 @@ impl Token {
448448
/// Returns `true` if the token is any literal, a minus (which can prefix a literal,
449449
/// for example a '-42', or one of the boolean idents).
450450
///
451-
/// Keep this in sync with `Lit::from_token`.
452-
pub fn can_begin_literal_or_bool(&self) -> bool {
451+
/// In other words, would this token be a valid start of `parse_literal_maybe_minus`?
452+
///
453+
/// Keep this in sync with and `Lit::from_token`, excluding unary negation.
454+
pub fn can_begin_literal_maybe_minus(&self) -> bool {
453455
match self.uninterpolate().kind {
454456
Literal(..) | BinOp(Minus) => true,
455457
Ident(name, false) if name.is_bool_lit() => true,
456458
Interpolated(ref nt) => match &**nt {
457-
NtExpr(e) | NtLiteral(e) => matches!(e.kind, ast::ExprKind::Lit(_)),
459+
NtLiteral(_) => true,
460+
NtExpr(e) => match &e.kind {
461+
ast::ExprKind::Lit(_) => true,
462+
ast::ExprKind::Unary(ast::UnOp::Neg, e) => {
463+
matches!(&e.kind, ast::ExprKind::Lit(_))
464+
}
465+
_ => false,
466+
},
458467
_ => false,
459468
},
460469
_ => false,

src/librustc_ast/util/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Lit {
189189

190190
/// Converts arbitrary token into an AST literal.
191191
///
192-
/// Keep this in sync with `Token::can_begin_literal_or_bool`.
192+
/// Keep this in sync with `Token::can_begin_literal_or_bool` excluding unary negation.
193193
pub fn from_token(token: &Token) -> Result<Lit, LitError> {
194194
let lit = match token.uninterpolate().kind {
195195
token::Ident(name, false) if name.is_bool_lit() => {

src/librustc_expand/mbe/macro_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ fn may_begin_with(token: &Token, name: Name) -> bool {
775775
}
776776
sym::ty => token.can_begin_type(),
777777
sym::ident => get_macro_ident(token).is_some(),
778-
sym::literal => token.can_begin_literal_or_bool(),
778+
sym::literal => token.can_begin_literal_maybe_minus(),
779779
sym::vis => match token.kind {
780780
// The follow-set of :vis + "priv" keyword + interpolated
781781
token::Comma | token::Ident(..) | token::Interpolated(_) => true,

src/librustc_parse/parser/expr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ impl<'a> Parser<'a> {
13381338
}
13391339

13401340
/// Matches `'-' lit | lit` (cf. `ast_validation::AstValidator::check_expr_within_pat`).
1341+
/// Keep this in sync with `Token::can_begin_literal_maybe_minus`.
13411342
pub fn parse_literal_maybe_minus(&mut self) -> PResult<'a, P<Expr>> {
13421343
maybe_whole_expr!(self);
13431344

src/librustc_parse/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ impl<'a> Parser<'a> {
14491449
})
14501450
// `extern ABI fn`
14511451
|| self.check_keyword(kw::Extern)
1452-
&& self.look_ahead(1, |t| t.can_begin_literal_or_bool())
1452+
&& self.look_ahead(1, |t| t.can_begin_literal_maybe_minus())
14531453
&& self.look_ahead(2, |t| t.is_keyword(kw::Fn))
14541454
}
14551455

src/librustc_parse/parser/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ impl<'a> Parser<'a> {
698698
self.look_ahead(dist, |t| {
699699
t.is_path_start() // e.g. `MY_CONST`;
700700
|| t.kind == token::Dot // e.g. `.5` for recovery;
701-
|| t.can_begin_literal_or_bool() // e.g. `42`.
701+
|| t.can_begin_literal_maybe_minus() // e.g. `42`.
702702
|| t.is_whole_expr()
703703
})
704704
}

src/stage0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
1313
# `0.x.0` for Cargo where they were released on `date`.
1414

15-
date: 2020-03-10
15+
date: 2020-03-12
1616
rustc: 1.42.0
1717
cargo: 0.43.0
1818

@@ -40,4 +40,4 @@ cargo: 0.43.0
4040
# looking at a beta source tarball and it's uncommented we'll shortly comment it
4141
# out.
4242

43-
dev: 1
43+
#dev: 1

src/test/ui/parser/extern-abi-from-mac-literal-frag.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// check-pass
22

33
// In this test we check that the parser accepts an ABI string when it
4-
// comes from a macro `literal` fragment as opposed to a hardcoded string.
4+
// comes from a macro `literal` or `expr` fragment as opposed to a hardcoded string.
55

66
fn main() {}
77

@@ -17,10 +17,30 @@ macro_rules! abi_from_lit_frag {
1717
}
1818
}
1919

20+
macro_rules! abi_from_expr_frag {
21+
($abi:expr) => {
22+
extern $abi {
23+
fn _import();
24+
}
25+
26+
extern $abi fn _export() {}
27+
28+
type _PTR = extern $abi fn();
29+
};
30+
}
31+
2032
mod rust {
2133
abi_from_lit_frag!("Rust");
2234
}
2335

2436
mod c {
2537
abi_from_lit_frag!("C");
2638
}
39+
40+
mod rust_expr {
41+
abi_from_expr_frag!("Rust");
42+
}
43+
44+
mod c_expr {
45+
abi_from_expr_frag!("C");
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
3+
macro_rules! foo {
4+
($a:literal) => {
5+
bar!($a)
6+
};
7+
}
8+
9+
macro_rules! bar {
10+
($b:literal) => {};
11+
}
12+
13+
fn main() {
14+
foo!(-2);
15+
bar!(-2);
16+
}

0 commit comments

Comments
 (0)