Skip to content

Commit 5bdc632

Browse files
authored
Merge branch 'rust-lang:master' into master
2 parents de45417 + 4563f70 commit 5bdc632

File tree

1,546 files changed

+22738
-14276
lines changed

Some content is hidden

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

1,546 files changed

+22738
-14276
lines changed

Cargo.lock

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ dependencies = [
593593
"syn 2.0.55",
594594
"tempfile",
595595
"termize",
596-
"tester",
597596
"tokio",
598597
"toml 0.7.8",
599598
"ui_test 0.22.2",
@@ -2590,6 +2589,15 @@ dependencies = [
25902589
"winapi",
25912590
]
25922591

2592+
[[package]]
2593+
name = "nu-ansi-term"
2594+
version = "0.49.0"
2595+
source = "registry+https://github.com/rust-lang/crates.io-index"
2596+
checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68"
2597+
dependencies = [
2598+
"windows-sys 0.48.0",
2599+
]
2600+
25932601
[[package]]
25942602
name = "num-conv"
25952603
version = "0.1.0"
@@ -3560,6 +3568,7 @@ dependencies = [
35603568
name = "rustc_attr"
35613569
version = "0.0.0"
35623570
dependencies = [
3571+
"rustc_abi",
35633572
"rustc_ast",
35643573
"rustc_ast_pretty",
35653574
"rustc_data_structures",
@@ -4773,6 +4782,8 @@ version = "0.0.0"
47734782
dependencies = [
47744783
"arrayvec",
47754784
"askama",
4785+
"base64",
4786+
"byteorder",
47764787
"expect-test",
47774788
"indexmap",
47784789
"itertools 0.12.1",
@@ -5358,9 +5369,9 @@ dependencies = [
53585369

53595370
[[package]]
53605371
name = "sysinfo"
5361-
version = "0.30.7"
5372+
version = "0.30.8"
53625373
source = "registry+https://github.com/rust-lang/crates.io-index"
5363-
checksum = "0c385888ef380a852a16209afc8cfad22795dd8873d69c9a14d2e2088f118d18"
5374+
checksum = "4b1a378e48fb3ce3a5cf04359c456c9c98ff689bcf1c1bc6e6a31f247686f275"
53645375
dependencies = [
53655376
"cfg-if",
53665377
"core-foundation-sys",
@@ -5496,19 +5507,6 @@ dependencies = [
54965507
"std",
54975508
]
54985509

5499-
[[package]]
5500-
name = "tester"
5501-
version = "0.9.1"
5502-
source = "registry+https://github.com/rust-lang/crates.io-index"
5503-
checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f"
5504-
dependencies = [
5505-
"cfg-if",
5506-
"getopts",
5507-
"libc",
5508-
"num_cpus",
5509-
"term",
5510-
]
5511-
55125510
[[package]]
55135511
name = "thin-vec"
55145512
version = "0.2.13"
@@ -5778,17 +5776,6 @@ dependencies = [
57785776
"tracing-subscriber",
57795777
]
57805778

5781-
[[package]]
5782-
name = "tracing-log"
5783-
version = "0.1.4"
5784-
source = "registry+https://github.com/rust-lang/crates.io-index"
5785-
checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2"
5786-
dependencies = [
5787-
"log",
5788-
"once_cell",
5789-
"tracing-core",
5790-
]
5791-
57925779
[[package]]
57935780
name = "tracing-log"
57945781
version = "0.2.0"
@@ -5807,7 +5794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
58075794
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
58085795
dependencies = [
58095796
"matchers",
5810-
"nu-ansi-term",
5797+
"nu-ansi-term 0.46.0",
58115798
"once_cell",
58125799
"parking_lot",
58135800
"regex",
@@ -5816,18 +5803,18 @@ dependencies = [
58165803
"thread_local",
58175804
"tracing",
58185805
"tracing-core",
5819-
"tracing-log 0.2.0",
5806+
"tracing-log",
58205807
]
58215808

58225809
[[package]]
58235810
name = "tracing-tree"
5824-
version = "0.2.5"
5811+
version = "0.3.0"
58255812
source = "registry+https://github.com/rust-lang/crates.io-index"
5826-
checksum = "2ec6adcab41b1391b08a308cc6302b79f8095d1673f6947c2dc65ffb028b0b2d"
5813+
checksum = "65139ecd2c3f6484c3b99bc01c77afe21e95473630747c7aca525e78b0666675"
58275814
dependencies = [
5828-
"nu-ansi-term",
5815+
"nu-ansi-term 0.49.0",
58295816
"tracing-core",
5830-
"tracing-log 0.1.4",
5817+
"tracing-log",
58315818
"tracing-subscriber",
58325819
]
58335820

README.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
1-
# The Rust Programming Language
2-
3-
[![Rust Community](https://img.shields.io/badge/Rust_Community%20-Join_us-brightgreen?style=plastic&logo=rust)](https://www.rust-lang.org/community)
1+
<div align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-dark.svg">
4+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg">
5+
<img alt="The Rust Programming Language: A language empowering everyone to build reliable and efficient software"
6+
src="https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-light.svg"
7+
width="50%">
8+
</picture>
9+
10+
[Website][Rust] | [Getting started] | [Learn] | [Documentation] | [Contributing]
11+
</div>
412

513
This is the main source code repository for [Rust]. It contains the compiler,
614
standard library, and documentation.
715

816
[Rust]: https://www.rust-lang.org/
17+
[Getting Started]: https://www.rust-lang.org/learn/get-started
18+
[Learn]: https://www.rust-lang.org/learn
19+
[Documentation]: https://www.rust-lang.org/learn#learn-use
20+
[Contributing]: CONTRIBUTING.md
21+
22+
## Why Rust?
923

10-
**Note: this README is for _users_ rather than _contributors_.**
11-
If you wish to _contribute_ to the compiler, you should read
12-
[CONTRIBUTING.md](CONTRIBUTING.md) instead.
24+
- **Performance:** Fast and memory-efficient, suitable for critical services, embedded devices, and easily integrate with other languages.
1325

14-
<details>
15-
<summary>Table of Contents</summary>
26+
- **Reliability:** Our rich type system and ownership model ensure memory and thread safety, reducing bugs at compile-time.
1627

17-
- [Quick Start](#quick-start)
18-
- [Installing from Source](#installing-from-source)
19-
- [Getting Help](#getting-help)
20-
- [Contributing](#contributing)
21-
- [License](#license)
22-
- [Trademark](#trademark)
28+
- **Productivity:** Comprehensive documentation, a compiler committed to providing great diagnostics, and advanced tooling including package manager and build tool ([Cargo]), auto-formatter ([rustfmt]), linter ([Clippy]) and editor support ([rust-analyzer]).
2329

24-
</details>
30+
[Cargo]: https://github.com/rust-lang/cargo
31+
[rustfmt]: https://github.com/rust-lang/rustfmt
32+
[Clippy]: https://github.com/rust-lang/rust-clippy
33+
[rust-analyzer]: https://github.com/rust-lang/rust-analyzer
2534

2635
## Quick Start
2736

compiler/rustc_abi/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ impl fmt::Display for AlignFromBytesError {
698698

699699
impl Align {
700700
pub const ONE: Align = Align { pow2: 0 };
701+
pub const EIGHT: Align = Align { pow2: 3 };
701702
// LLVM has a maximal supported alignment of 2^29, we inherit that.
702703
pub const MAX: Align = Align { pow2: 29 };
703704

@@ -707,19 +708,19 @@ impl Align {
707708
}
708709

709710
#[inline]
710-
pub fn from_bytes(align: u64) -> Result<Align, AlignFromBytesError> {
711+
pub const fn from_bytes(align: u64) -> Result<Align, AlignFromBytesError> {
711712
// Treat an alignment of 0 bytes like 1-byte alignment.
712713
if align == 0 {
713714
return Ok(Align::ONE);
714715
}
715716

716717
#[cold]
717-
fn not_power_of_2(align: u64) -> AlignFromBytesError {
718+
const fn not_power_of_2(align: u64) -> AlignFromBytesError {
718719
AlignFromBytesError::NotPowerOfTwo(align)
719720
}
720721

721722
#[cold]
722-
fn too_large(align: u64) -> AlignFromBytesError {
723+
const fn too_large(align: u64) -> AlignFromBytesError {
723724
AlignFromBytesError::TooLarge(align)
724725
}
725726

compiler/rustc_ast/src/ast.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,8 @@ impl Expr {
12761276
ExprKind::While(..) => ExprPrecedence::While,
12771277
ExprKind::ForLoop { .. } => ExprPrecedence::ForLoop,
12781278
ExprKind::Loop(..) => ExprPrecedence::Loop,
1279-
ExprKind::Match(..) => ExprPrecedence::Match,
1279+
ExprKind::Match(_, _, MatchKind::Prefix) => ExprPrecedence::Match,
1280+
ExprKind::Match(_, _, MatchKind::Postfix) => ExprPrecedence::PostfixMatch,
12801281
ExprKind::Closure(..) => ExprPrecedence::Closure,
12811282
ExprKind::Block(..) => ExprPrecedence::Block,
12821283
ExprKind::TryBlock(..) => ExprPrecedence::TryBlock,
@@ -2483,6 +2484,14 @@ pub enum CoroutineKind {
24832484
}
24842485

24852486
impl CoroutineKind {
2487+
pub fn span(self) -> Span {
2488+
match self {
2489+
CoroutineKind::Async { span, .. } => span,
2490+
CoroutineKind::Gen { span, .. } => span,
2491+
CoroutineKind::AsyncGen { span, .. } => span,
2492+
}
2493+
}
2494+
24862495
pub fn is_async(self) -> bool {
24872496
matches!(self, CoroutineKind::Async { .. })
24882497
}
@@ -3341,7 +3350,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
33413350
pub type ForeignItem = Item<ForeignItemKind>;
33423351

33433352
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
3344-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
3353+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
33453354
mod size_asserts {
33463355
use super::*;
33473356
use rustc_data_structures::static_assert_size;

compiler/rustc_ast/src/ptr.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
//! The AST pointer.
22
//!
3-
//! Provides `P<T>`, a frozen owned smart pointer.
3+
//! Provides [`P<T>`][struct@P], an owned smart pointer.
44
//!
55
//! # Motivations and benefits
66
//!
77
//! * **Identity**: sharing AST nodes is problematic for the various analysis
88
//! passes (e.g., one may be able to bypass the borrow checker with a shared
99
//! `ExprKind::AddrOf` node taking a mutable borrow).
1010
//!
11-
//! * **Immutability**: `P<T>` disallows mutating its inner `T`, unlike `Box<T>`
12-
//! (unless it contains an `Unsafe` interior, but that may be denied later).
13-
//! This mainly prevents mistakes, but also enforces a kind of "purity".
14-
//!
1511
//! * **Efficiency**: folding can reuse allocation space for `P<T>` and `Vec<T>`,
1612
//! the latter even when the input and output types differ (as it would be the
1713
//! case with arenas or a GADT AST using type parameters to toggle features).
1814
//!
19-
//! * **Maintainability**: `P<T>` provides a fixed interface - `Deref`,
20-
//! `and_then` and `map` - which can remain fully functional even if the
21-
//! implementation changes (using a special thread-local heap, for example).
22-
//! Moreover, a switch to, e.g., `P<'a, T>` would be easy and mostly automated.
15+
//! * **Maintainability**: `P<T>` provides an interface, which can remain fully
16+
//! functional even if the implementation changes (using a special thread-local
17+
//! heap, for example). Moreover, a switch to, e.g., `P<'a, T>` would be easy
18+
//! and mostly automated.
2319
2420
use std::fmt::{self, Debug, Display};
2521
use std::ops::{Deref, DerefMut};
@@ -29,6 +25,8 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
2925

3026
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3127
/// An owned smart pointer.
28+
///
29+
/// See the [module level documentation][crate::ptr] for details.
3230
pub struct P<T: ?Sized> {
3331
ptr: Box<T>,
3432
}

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ where
10211021
}
10221022

10231023
// Some types are used a lot. Make sure they don't unintentionally get bigger.
1024-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1024+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
10251025
mod size_asserts {
10261026
use super::*;
10271027
use rustc_data_structures::static_assert_size;

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ impl DelimSpacing {
768768
}
769769

770770
// Some types are used a lot. Make sure they don't unintentionally get bigger.
771-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
771+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
772772
mod size_asserts {
773773
use super::*;
774774
use rustc_data_structures::static_assert_size;

compiler/rustc_ast/src/util/parser.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ pub enum ExprPrecedence {
281281
ForLoop,
282282
Loop,
283283
Match,
284+
PostfixMatch,
284285
ConstBlock,
285286
Block,
286287
TryBlock,
@@ -334,7 +335,8 @@ impl ExprPrecedence {
334335
| ExprPrecedence::InlineAsm
335336
| ExprPrecedence::Mac
336337
| ExprPrecedence::FormatArgs
337-
| ExprPrecedence::OffsetOf => PREC_POSTFIX,
338+
| ExprPrecedence::OffsetOf
339+
| ExprPrecedence::PostfixMatch => PREC_POSTFIX,
338340

339341
// Never need parens
340342
ExprPrecedence::Array
@@ -390,7 +392,8 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
390392
| ast::ExprKind::Cast(x, _)
391393
| ast::ExprKind::Type(x, _)
392394
| ast::ExprKind::Field(x, _)
393-
| ast::ExprKind::Index(x, _, _) => {
395+
| ast::ExprKind::Index(x, _, _)
396+
| ast::ExprKind::Match(x, _, ast::MatchKind::Postfix) => {
394397
// &X { y: 1 }, X { y: 1 }.y
395398
contains_exterior_struct_lit(x)
396399
}

compiler/rustc_ast_lowering/src/index.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_hir as hir;
33
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
44
use rustc_hir::intravisit::Visitor;
55
use rustc_hir::*;
6-
use rustc_index::{Idx, IndexVec};
6+
use rustc_index::IndexVec;
77
use rustc_middle::span_bug;
88
use rustc_middle::ty::TyCtxt;
99
use rustc_span::{Span, DUMMY_SP};
@@ -19,7 +19,7 @@ struct NodeCollector<'a, 'hir> {
1919
parenting: LocalDefIdMap<ItemLocalId>,
2020

2121
/// The parent of this node
22-
parent_node: hir::ItemLocalId,
22+
parent_node: ItemLocalId,
2323

2424
owner: OwnerId,
2525
}
@@ -31,17 +31,16 @@ pub(super) fn index_hir<'hir>(
3131
bodies: &SortedMap<ItemLocalId, &'hir Body<'hir>>,
3232
num_nodes: usize,
3333
) -> (IndexVec<ItemLocalId, ParentedNode<'hir>>, LocalDefIdMap<ItemLocalId>) {
34-
let zero_id = ItemLocalId::new(0);
35-
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
34+
let err_node = ParentedNode { parent: ItemLocalId::ZERO, node: Node::Err(item.span()) };
3635
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
3736
// This node's parent should never be accessed: the owner's parent is computed by the
3837
// hir_owner_parent query. Make it invalid (= ItemLocalId::MAX) to force an ICE whenever it is
3938
// used.
40-
nodes[zero_id] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
39+
nodes[ItemLocalId::ZERO] = ParentedNode { parent: ItemLocalId::INVALID, node: item.into() };
4140
let mut collector = NodeCollector {
4241
tcx,
4342
owner: item.def_id(),
44-
parent_node: zero_id,
43+
parent_node: ItemLocalId::ZERO,
4544
nodes,
4645
bodies,
4746
parenting: Default::default(),
@@ -112,7 +111,9 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
112111
}
113112

114113
fn insert_nested(&mut self, item: LocalDefId) {
115-
self.parenting.insert(item, self.parent_node);
114+
if self.parent_node != ItemLocalId::ZERO {
115+
self.parenting.insert(item, self.parent_node);
116+
}
116117
}
117118
}
118119

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir as hir;
1111
use rustc_hir::def::{DefKind, Res};
1212
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1313
use rustc_hir::PredicateOrigin;
14-
use rustc_index::{Idx, IndexSlice, IndexVec};
14+
use rustc_index::{IndexSlice, IndexVec};
1515
use rustc_middle::span_bug;
1616
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
1717
use rustc_span::edit_distance::find_best_match_for_name;
@@ -563,7 +563,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
563563
let kind =
564564
this.lower_use_tree(use_tree, &prefix, id, vis_span, &mut ident, attrs);
565565
if let Some(attrs) = attrs {
566-
this.attrs.insert(hir::ItemLocalId::new(0), attrs);
566+
this.attrs.insert(hir::ItemLocalId::ZERO, attrs);
567567
}
568568

569569
let item = hir::Item {

0 commit comments

Comments
 (0)