Skip to content

Commit 0571516

Browse files
Merge branch 'rust-lang:master' into master
2 parents 02277f1 + 4c6c629 commit 0571516

File tree

228 files changed

+2857
-829
lines changed

Some content is hidden

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

228 files changed

+2857
-829
lines changed

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_ast/src/ast.rs

Lines changed: 3 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,
@@ -3341,7 +3342,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
33413342
pub type ForeignItem = Item<ForeignItemKind>;
33423343

33433344
// 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"))]
3345+
#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))]
33453346
mod size_asserts {
33463347
use super::*;
33473348
use rustc_data_structures::static_assert_size;

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: 5 additions & 3 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};
@@ -31,7 +31,7 @@ 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);
34+
let zero_id = ItemLocalId::ZERO;
3535
let err_node = ParentedNode { parent: zero_id, node: Node::Err(item.span()) };
3636
let mut nodes = IndexVec::from_elem_n(err_node, num_nodes);
3737
// This node's parent should never be accessed: the owner's parent is computed by the
@@ -112,7 +112,9 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
112112
}
113113

114114
fn insert_nested(&mut self, item: LocalDefId) {
115-
self.parenting.insert(item, self.parent_node);
115+
if self.parent_node.as_u32() != 0 {
116+
self.parenting.insert(item, self.parent_node);
117+
}
116118
}
117119
}
118120

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 {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
157157
attrs: SortedMap::default(),
158158
children: Vec::default(),
159159
current_hir_id_owner: hir::CRATE_OWNER_ID,
160-
item_local_id_counter: hir::ItemLocalId::new(0),
160+
item_local_id_counter: hir::ItemLocalId::ZERO,
161161
node_id_to_local_id: Default::default(),
162162
trait_map: Default::default(),
163163

@@ -583,7 +583,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
583583
// and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
584584

585585
// Always allocate the first `HirId` for the owner itself.
586-
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::new(0));
586+
let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::ZERO);
587587
debug_assert_eq!(_old, None);
588588

589589
let item = f(self);
@@ -677,7 +677,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
677677
v.insert(local_id);
678678
self.item_local_id_counter.increment_by(1);
679679

680-
assert_ne!(local_id, hir::ItemLocalId::new(0));
680+
assert_ne!(local_id, hir::ItemLocalId::ZERO);
681681
if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
682682
self.children.push((def_id, hir::MaybeOwner::NonOwner(hir_id)));
683683
}
@@ -696,7 +696,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
696696
fn next_id(&mut self) -> hir::HirId {
697697
let owner = self.current_hir_id_owner;
698698
let local_id = self.item_local_id_counter;
699-
assert_ne!(local_id, hir::ItemLocalId::new(0));
699+
assert_ne!(local_id, hir::ItemLocalId::ZERO);
700700
self.item_local_id_counter.increment_by(1);
701701
hir::HirId { owner, local_id }
702702
}

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> BorrowSet<'tcx> {
159159
}
160160

161161
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
162-
BorrowIndex::from_usize(0)..BorrowIndex::from_usize(self.len())
162+
BorrowIndex::ZERO..BorrowIndex::from_usize(self.len())
163163
}
164164

165165
pub(crate) fn iter_enumerated(&self) -> impl Iterator<Item = (BorrowIndex, &BorrowData<'tcx>)> {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22612261
}
22622262
}
22632263

2264-
CastKind::PointerExposeAddress => {
2264+
CastKind::PointerExposeProvenance => {
22652265
let ty_from = op.ty(body, tcx);
22662266
let cast_ty_from = CastTy::from_ty(ty_from);
22672267
let cast_ty_to = CastTy::from_ty(*ty);
@@ -2271,7 +2271,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22712271
span_mirbug!(
22722272
self,
22732273
rvalue,
2274-
"Invalid PointerExposeAddress cast {:?} -> {:?}",
2274+
"Invalid PointerExposeProvenance cast {:?} -> {:?}",
22752275
ty_from,
22762276
ty
22772277
)

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ fn codegen_stmt<'tcx>(
649649
| CastKind::IntToFloat
650650
| CastKind::FnPtrToPtr
651651
| CastKind::PtrToPtr
652-
| CastKind::PointerExposeAddress
652+
| CastKind::PointerExposeProvenance
653653
| CastKind::PointerWithExposedProvenance,
654654
ref operand,
655655
to_ty,

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ fn llvm_add_sub<'tcx>(
13931393

13941394
// c + carry -> c + first intermediate carry or borrow respectively
13951395
let int0 = crate::num::codegen_checked_int_binop(fx, bin_op, a, b);
1396-
let c = int0.value_field(fx, FieldIdx::new(0));
1396+
let c = int0.value_field(fx, FieldIdx::ZERO);
13971397
let cb0 = int0.value_field(fx, FieldIdx::new(1)).load_scalar(fx);
13981398

13991399
// c + carry -> c + second intermediate carry or borrow respectively

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
965965
});
966966
}
967967

968-
sym::simd_expose_addr | sym::simd_with_exposed_provenance | sym::simd_cast_ptr => {
968+
sym::simd_expose_provenance | sym::simd_with_exposed_provenance | sym::simd_cast_ptr => {
969969
intrinsic_args!(fx, args => (arg); intrinsic);
970970
ret.write_cvalue_transmute(fx, arg);
971971
}

compiler/rustc_codegen_cranelift/src/vtable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
6161
if ty.is_dyn_star() {
6262
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
6363
let dyn_star = CPlace::for_ptr(Pointer::new(arg.load_scalar(fx)), inner_layout);
64-
let ptr = dyn_star.place_field(fx, FieldIdx::new(0)).to_ptr();
64+
let ptr = dyn_star.place_field(fx, FieldIdx::ZERO).to_ptr();
6565
let vtable =
6666
dyn_star.place_field(fx, FieldIdx::new(1)).to_cvalue(fx).load_scalar(fx);
6767
break 'block (ptr, vtable);

0 commit comments

Comments
 (0)