Skip to content

Commit 2987785

Browse files
committed
Auto merge of #80439 - Dylan-DPC:rollup-rdxcvon, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #79662 (Move some more code out of CodegenBackend::{codegen_crate,link}) - #79815 (Update RELEASES.md for 1.49.0) - #80284 (Suggest fn ptr rather than fn item and suggest to use `Fn` trait bounds rather than the unique closure type in E0121) - #80331 (Add more comments to trait queries) - #80344 (use matches!() macro in more places) - #80353 (BTreeMap: test split_off (and append) more thoroughly) - #80362 (Document rustc_macros on nightly-rustc) - #80399 (Remove FIXME in rustc_privacy) - #80408 (Sync rustc_codegen_cranelift) - #80411 (rustc_span: Remove `Symbol::with`) - #80434 (bootstrap: put the component name in the tarball temp dir path) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 76aca66 + a4a59a0 commit 2987785

File tree

79 files changed

+943
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+943
-623
lines changed

RELEASES.md

+131-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,131 @@
1+
Version 1.49.0 (2020-12-31)
2+
============================
3+
4+
Language
5+
-----------------------
6+
7+
- [Unions can now implement `Drop`, and you can now have a field in a union
8+
with `ManuallyDrop<T>`.][77547]
9+
- [You can now cast uninhabited enums to integers.][76199]
10+
- [You can now bind by reference and by move in patterns.][76119] This
11+
allows you to selectively borrow individual components of a type. E.g.
12+
```rust
13+
#[derive(Debug)]
14+
struct Person {
15+
name: String,
16+
age: u8,
17+
}
18+
19+
let person = Person {
20+
name: String::from("Alice"),
21+
age: 20,
22+
};
23+
24+
// `name` is moved out of person, but `age` is referenced.
25+
let Person { name, ref age } = person;
26+
println!("{} {}", name, age);
27+
```
28+
29+
Compiler
30+
-----------------------
31+
32+
- [Added tier 1\* support for `aarch64-unknown-linux-gnu`.][78228]
33+
- [Added tier 2 support for `aarch64-apple-darwin`.][75991]
34+
- [Added tier 2 support for `aarch64-pc-windows-msvc`.][75914]
35+
- [Added tier 3 support for `mipsel-unknown-none`.][78676]
36+
- [Raised the minimum supported LLVM version to LLVM 9.][78848]
37+
- [Output from threads spawned in tests is now captured.][78227]
38+
- [Change os and vendor values to "none" and "unknown" for some targets][78951]
39+
40+
\* Refer to Rust's [platform support page][forge-platform-support] for more
41+
information on Rust's tiered platform support.
42+
43+
Libraries
44+
-----------------------
45+
46+
- [`RangeInclusive` now checks for exhaustion when calling `contains` and indexing.][78109]
47+
- [`ToString::to_string` now no longer shrinks the internal buffer in the default implementation.][77997]
48+
- [`ops::{Index, IndexMut}` are now implemented for fixed sized arrays of any length.][74989]
49+
50+
Stabilized APIs
51+
---------------
52+
53+
- [`slice::select_nth_unstable`]
54+
- [`slice::select_nth_unstable_by`]
55+
- [`slice::select_nth_unstable_by_key`]
56+
57+
The following previously stable methods are now `const`.
58+
59+
- [`Poll::is_ready`]
60+
- [`Poll::is_pending`]
61+
62+
Cargo
63+
-----------------------
64+
- [Building a crate with `cargo-package` should now be independently reproducible.][cargo/8864]
65+
- [`cargo-tree` now marks proc-macro crates.][cargo/8765]
66+
- [Added `CARGO_PRIMARY_PACKAGE` build-time environment variable.][cargo/8758] This
67+
variable will be set if the crate being built is one the user selected to build, either
68+
with `-p` or through defaults.
69+
- [You can now use glob patterns when specifying packages & targets.][cargo/8752]
70+
71+
72+
Compatibility Notes
73+
-------------------
74+
75+
- [Demoted `i686-unknown-freebsd` from host tier 2 to target tier 2 support.][78746]
76+
- [Macros that end with a semi-colon are now treated as statements even if they expand to nothing.][78376]
77+
- [Rustc will now check for the validity of some built-in attributes on enum variants.][77015]
78+
Previously such invalid or unused attributes could be ignored.
79+
- Leading whitespace is stripped more uniformly in documentation comments, which may change behavior. You
80+
read [this post about the changes][rustdoc-ws-post] for more details.
81+
- [Trait bounds are no longer inferred for associated types.][79904]
82+
83+
Internal Only
84+
-------------
85+
These changes provide no direct user facing benefits, but represent significant
86+
improvements to the internals and overall performance of rustc and
87+
related tools.
88+
89+
- [rustc's internal crates are now compiled using the `initial-exec` Thread
90+
Local Storage model.][78201]
91+
- [Calculate visibilities once in resolve.][78077]
92+
- [Added `system` to the `llvm-libunwind` bootstrap config option.][77703]
93+
- [Added `--color` for configuring terminal color support to bootstrap.][79004]
94+
95+
96+
[75991]: https://github.com/rust-lang/rust/pull/75991
97+
[78951]: https://github.com/rust-lang/rust/pull/78951
98+
[78848]: https://github.com/rust-lang/rust/pull/78848
99+
[78746]: https://github.com/rust-lang/rust/pull/78746
100+
[78376]: https://github.com/rust-lang/rust/pull/78376
101+
[78228]: https://github.com/rust-lang/rust/pull/78228
102+
[78227]: https://github.com/rust-lang/rust/pull/78227
103+
[78201]: https://github.com/rust-lang/rust/pull/78201
104+
[78109]: https://github.com/rust-lang/rust/pull/78109
105+
[78077]: https://github.com/rust-lang/rust/pull/78077
106+
[77997]: https://github.com/rust-lang/rust/pull/77997
107+
[77703]: https://github.com/rust-lang/rust/pull/77703
108+
[77547]: https://github.com/rust-lang/rust/pull/77547
109+
[77015]: https://github.com/rust-lang/rust/pull/77015
110+
[76199]: https://github.com/rust-lang/rust/pull/76199
111+
[76119]: https://github.com/rust-lang/rust/pull/76119
112+
[75914]: https://github.com/rust-lang/rust/pull/75914
113+
[74989]: https://github.com/rust-lang/rust/pull/74989
114+
[79004]: https://github.com/rust-lang/rust/pull/79004
115+
[78676]: https://github.com/rust-lang/rust/pull/78676
116+
[79904]: https://github.com/rust-lang/rust/issues/79904
117+
[cargo/8864]: https://github.com/rust-lang/cargo/pull/8864
118+
[cargo/8765]: https://github.com/rust-lang/cargo/pull/8765
119+
[cargo/8758]: https://github.com/rust-lang/cargo/pull/8758
120+
[cargo/8752]: https://github.com/rust-lang/cargo/pull/8752
121+
[`slice::select_nth_unstable`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable
122+
[`slice::select_nth_unstable_by`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable_by
123+
[`slice::select_nth_unstable_by_key`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.select_nth_unstable_by_key
124+
[`hint::spin_loop`]: https://doc.rust-lang.org/stable/std/hint/fn.spin_loop.html
125+
[`Poll::is_ready`]: https://doc.rust-lang.org/stable/std/task/enum.Poll.html#method.is_ready
126+
[`Poll::is_pending`]: https://doc.rust-lang.org/stable/std/task/enum.Poll.html#method.is_pending
127+
[rustdoc-ws-post]: https://blog.guillaume-gomez.fr/articles/2020-11-11+New+doc+comment+handling+in+rustdoc
128+
1129
Version 1.48.0 (2020-11-19)
2130
==========================
3131

@@ -10,7 +138,7 @@ Language
10138
Compiler
11139
--------
12140
- [Stabilised the `-C link-self-contained=<yes|no>` compiler flag.][76158] This tells
13-
`rustc` whether to link its own C runtime and libraries or to rely on a external
141+
`rustc` whether to link its own C runtime and libraries or to rely on a external
14142
linker to find them. (Supported only on `windows-gnu`, `linux-musl`, and `wasi` platforms.)
15143
- [You can now use `-C target-feature=+crt-static` on `linux-gnu` targets.][77386]
16144
Note: If you're using cargo you must explicitly pass the `--target` flag.
@@ -82,7 +210,7 @@ Compatibility Notes
82210
- [Foreign exceptions are now caught by `catch_unwind` and will cause an abort.][70212]
83211
Note: This behaviour is not guaranteed and is still considered undefined behaviour,
84212
see the [`catch_unwind`] documentation for further information.
85-
213+
86214

87215

88216
Internal Only
@@ -102,7 +230,7 @@ related tools.
102230
[76030]: https://github.com/rust-lang/rust/pull/76030/
103231
[70212]: https://github.com/rust-lang/rust/pull/70212/
104232
[27675]: https://github.com/rust-lang/rust/issues/27675/
105-
[54121]: https://github.com/rust-lang/rust/issues/54121/
233+
[54121]: https://github.com/rust-lang/rust/issues/54121/
106234
[71274]: https://github.com/rust-lang/rust/pull/71274/
107235
[77386]: https://github.com/rust-lang/rust/pull/77386/
108236
[77153]: https://github.com/rust-lang/rust/pull/77153/

compiler/rustc_ast/src/ast.rs

+9-36
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,7 @@ pub enum GenericArgs {
167167

168168
impl GenericArgs {
169169
pub fn is_angle_bracketed(&self) -> bool {
170-
match *self {
171-
AngleBracketed(..) => true,
172-
_ => false,
173-
}
170+
matches!(self, AngleBracketed(..))
174171
}
175172

176173
pub fn span(&self) -> Span {
@@ -629,10 +626,7 @@ impl Pat {
629626

630627
/// Is this a `..` pattern?
631628
pub fn is_rest(&self) -> bool {
632-
match self.kind {
633-
PatKind::Rest => true,
634-
_ => false,
635-
}
629+
matches!(self.kind, PatKind::Rest)
636630
}
637631
}
638632

@@ -852,10 +846,7 @@ impl BinOpKind {
852846
}
853847
}
854848
pub fn lazy(&self) -> bool {
855-
match *self {
856-
BinOpKind::And | BinOpKind::Or => true,
857-
_ => false,
858-
}
849+
matches!(self, BinOpKind::And | BinOpKind::Or)
859850
}
860851

861852
pub fn is_comparison(&self) -> bool {
@@ -963,17 +954,11 @@ impl Stmt {
963954
}
964955

965956
pub fn is_item(&self) -> bool {
966-
match self.kind {
967-
StmtKind::Item(_) => true,
968-
_ => false,
969-
}
957+
matches!(self.kind, StmtKind::Item(_))
970958
}
971959

972960
pub fn is_expr(&self) -> bool {
973-
match self.kind {
974-
StmtKind::Expr(_) => true,
975-
_ => false,
976-
}
961+
matches!(self.kind, StmtKind::Expr(_))
977962
}
978963
}
979964

@@ -1652,26 +1637,17 @@ pub enum LitKind {
16521637
impl LitKind {
16531638
/// Returns `true` if this literal is a string.
16541639
pub fn is_str(&self) -> bool {
1655-
match *self {
1656-
LitKind::Str(..) => true,
1657-
_ => false,
1658-
}
1640+
matches!(self, LitKind::Str(..))
16591641
}
16601642

16611643
/// Returns `true` if this literal is byte literal string.
16621644
pub fn is_bytestr(&self) -> bool {
1663-
match self {
1664-
LitKind::ByteStr(_) => true,
1665-
_ => false,
1666-
}
1645+
matches!(self, LitKind::ByteStr(_))
16671646
}
16681647

16691648
/// Returns `true` if this is a numeric literal.
16701649
pub fn is_numeric(&self) -> bool {
1671-
match *self {
1672-
LitKind::Int(..) | LitKind::Float(..) => true,
1673-
_ => false,
1674-
}
1650+
matches!(self, LitKind::Int(..) | LitKind::Float(..))
16751651
}
16761652

16771653
/// Returns `true` if this literal has no suffix.
@@ -2237,10 +2213,7 @@ impl FnDecl {
22372213
self.inputs.get(0).map_or(false, Param::is_self)
22382214
}
22392215
pub fn c_variadic(&self) -> bool {
2240-
self.inputs.last().map_or(false, |arg| match arg.ty.kind {
2241-
TyKind::CVarArgs => true,
2242-
_ => false,
2243-
})
2216+
self.inputs.last().map_or(false, |arg| matches!(arg.ty.kind, TyKind::CVarArgs))
22442217
}
22452218
}
22462219

compiler/rustc_ast/src/attr/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ impl MetaItem {
234234
}
235235

236236
pub fn is_word(&self) -> bool {
237-
match self.kind {
238-
MetaItemKind::Word => true,
239-
_ => false,
240-
}
237+
matches!(self.kind, MetaItemKind::Word)
241238
}
242239

243240
pub fn has_name(&self, name: Symbol) -> bool {

compiler/rustc_ast/src/token.rs

+19-34
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ impl LitKind {
130130
}
131131

132132
crate fn may_have_suffix(self) -> bool {
133-
match self {
134-
Integer | Float | Err => true,
135-
_ => false,
136-
}
133+
matches!(self, Integer | Float | Err)
137134
}
138135
}
139136

@@ -305,10 +302,7 @@ impl TokenKind {
305302
}
306303

307304
pub fn should_end_const_arg(&self) -> bool {
308-
match self {
309-
Gt | Ge | BinOp(Shr) | BinOpEq(Shr) => true,
310-
_ => false,
311-
}
305+
matches!(self, Gt | Ge | BinOp(Shr) | BinOpEq(Shr))
312306
}
313307
}
314308

@@ -346,18 +340,21 @@ impl Token {
346340
}
347341

348342
pub fn is_op(&self) -> bool {
349-
match self.kind {
350-
OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) | Ident(..)
351-
| Lifetime(..) | Interpolated(..) | Eof => false,
352-
_ => true,
353-
}
343+
!matches!(
344+
self.kind,
345+
OpenDelim(..)
346+
| CloseDelim(..)
347+
| Literal(..)
348+
| DocComment(..)
349+
| Ident(..)
350+
| Lifetime(..)
351+
| Interpolated(..)
352+
| Eof
353+
)
354354
}
355355

356356
pub fn is_like_plus(&self) -> bool {
357-
match self.kind {
358-
BinOp(Plus) | BinOpEq(Plus) => true,
359-
_ => false,
360-
}
357+
matches!(self.kind, BinOp(Plus) | BinOpEq(Plus))
361358
}
362359

363360
/// Returns `true` if the token can appear at the start of an expression.
@@ -379,13 +376,10 @@ impl Token {
379376
ModSep | // global path
380377
Lifetime(..) | // labeled loop
381378
Pound => true, // expression attributes
382-
Interpolated(ref nt) => match **nt {
383-
NtLiteral(..) |
379+
Interpolated(ref nt) => matches!(**nt, NtLiteral(..) |
384380
NtExpr(..) |
385381
NtBlock(..) |
386-
NtPath(..) => true,
387-
_ => false,
388-
},
382+
NtPath(..)),
389383
_ => false,
390384
}
391385
}
@@ -405,10 +399,7 @@ impl Token {
405399
Lifetime(..) | // lifetime bound in trait object
406400
Lt | BinOp(Shl) | // associated path
407401
ModSep => true, // global path
408-
Interpolated(ref nt) => match **nt {
409-
NtTy(..) | NtPath(..) => true,
410-
_ => false,
411-
},
402+
Interpolated(ref nt) => matches!(**nt, NtTy(..) | NtPath(..)),
412403
_ => false,
413404
}
414405
}
@@ -417,10 +408,7 @@ impl Token {
417408
pub fn can_begin_const_arg(&self) -> bool {
418409
match self.kind {
419410
OpenDelim(Brace) => true,
420-
Interpolated(ref nt) => match **nt {
421-
NtExpr(..) | NtBlock(..) | NtLiteral(..) => true,
422-
_ => false,
423-
},
411+
Interpolated(ref nt) => matches!(**nt, NtExpr(..) | NtBlock(..) | NtLiteral(..)),
424412
_ => self.can_begin_literal_maybe_minus(),
425413
}
426414
}
@@ -436,10 +424,7 @@ impl Token {
436424

437425
/// Returns `true` if the token is any literal.
438426
pub fn is_lit(&self) -> bool {
439-
match self.kind {
440-
Literal(..) => true,
441-
_ => false,
442-
}
427+
matches!(self.kind, Literal(..))
443428
}
444429

445430
/// Returns `true` if the token is any literal, a minus (which can prefix a literal,

compiler/rustc_ast/src/util/classify.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use crate::ast;
1212
/// |x| 5
1313
/// isn't parsed as (if true {...} else {...} | x) | 5
1414
pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
15-
match e.kind {
15+
!matches!(
16+
e.kind,
1617
ast::ExprKind::If(..)
17-
| ast::ExprKind::Match(..)
18-
| ast::ExprKind::Block(..)
19-
| ast::ExprKind::While(..)
20-
| ast::ExprKind::Loop(..)
21-
| ast::ExprKind::ForLoop(..)
22-
| ast::ExprKind::TryBlock(..) => false,
23-
_ => true,
24-
}
18+
| ast::ExprKind::Match(..)
19+
| ast::ExprKind::Block(..)
20+
| ast::ExprKind::While(..)
21+
| ast::ExprKind::Loop(..)
22+
| ast::ExprKind::ForLoop(..)
23+
| ast::ExprKind::TryBlock(..)
24+
)
2525
}

0 commit comments

Comments
 (0)