Skip to content

Commit bfaf6b0

Browse files
committed
Auto merge of #3453 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 81cab97 + e999fe8 commit bfaf6b0

File tree

806 files changed

+11272
-4148
lines changed

Some content is hidden

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

806 files changed

+11272
-4148
lines changed

Cargo.lock

-14
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",
@@ -5508,19 +5507,6 @@ dependencies = [
55085507
"std",
55095508
]
55105509

5511-
[[package]]
5512-
name = "tester"
5513-
version = "0.9.1"
5514-
source = "registry+https://github.com/rust-lang/crates.io-index"
5515-
checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f"
5516-
dependencies = [
5517-
"cfg-if",
5518-
"getopts",
5519-
"libc",
5520-
"num_cpus",
5521-
"term",
5522-
]
5523-
55245510
[[package]]
55255511
name = "thin-vec"
55265512
version = "0.2.13"

README.md

+24-15
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

+8
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,14 @@ pub enum CoroutineKind {
24842484
}
24852485

24862486
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+
24872495
pub fn is_async(self) -> bool {
24882496
matches!(self, CoroutineKind::Async { .. })
24892497
}

compiler/rustc_ast_lowering/src/index.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -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::ZERO;
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,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
112111
}
113112

114113
fn insert_nested(&mut self, item: LocalDefId) {
115-
if self.parent_node.as_u32() != 0 {
114+
if self.parent_node != ItemLocalId::ZERO {
116115
self.parenting.insert(item, self.parent_node);
117116
}
118117
}

compiler/rustc_ast_passes/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ast_passes_extern_block_suggestion = if you meant to declare an externally defin
6868
6969
ast_passes_extern_fn_qualifiers = functions in `extern` blocks cannot have qualifiers
7070
.label = in this `extern` block
71-
.suggestion = remove the qualifiers
71+
.suggestion = remove this qualifier
7272
7373
ast_passes_extern_item_ascii = items in `extern` blocks cannot use non-ascii identifiers
7474
.label = in this `extern` block

compiler/rustc_ast_passes/src/ast_validation.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,32 @@ impl<'a> AstValidator<'a> {
514514
}
515515

516516
/// An `fn` in `extern { ... }` cannot have qualifiers, e.g. `async fn`.
517-
fn check_foreign_fn_headerless(&self, ident: Ident, span: Span, header: FnHeader) {
518-
if header.has_qualifiers() {
517+
fn check_foreign_fn_headerless(
518+
&self,
519+
// Deconstruct to ensure exhaustiveness
520+
FnHeader { unsafety, coroutine_kind, constness, ext }: FnHeader,
521+
) {
522+
let report_err = |span| {
519523
self.dcx().emit_err(errors::FnQualifierInExtern {
520-
span: ident.span,
524+
span: span,
521525
block: self.current_extern_span(),
522-
sugg_span: span.until(ident.span.shrink_to_lo()),
523526
});
527+
};
528+
match unsafety {
529+
Unsafe::Yes(span) => report_err(span),
530+
Unsafe::No => (),
531+
}
532+
match coroutine_kind {
533+
Some(knd) => report_err(knd.span()),
534+
None => (),
535+
}
536+
match constness {
537+
Const::Yes(span) => report_err(span),
538+
Const::No => (),
539+
}
540+
match ext {
541+
Extern::None => (),
542+
Extern::Implicit(span) | Extern::Explicit(_, span) => report_err(span),
524543
}
525544
}
526545

@@ -1145,7 +1164,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11451164
ForeignItemKind::Fn(box Fn { defaultness, sig, body, .. }) => {
11461165
self.check_defaultness(fi.span, *defaultness);
11471166
self.check_foreign_fn_bodyless(fi.ident, body.as_deref());
1148-
self.check_foreign_fn_headerless(fi.ident, fi.span, sig.header);
1167+
self.check_foreign_fn_headerless(sig.header);
11491168
self.check_foreign_item_ascii_only(fi.ident);
11501169
}
11511170
ForeignItemKind::TyAlias(box TyAlias {

compiler/rustc_ast_passes/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,10 @@ pub struct FnBodyInExtern {
270270
#[diag(ast_passes_extern_fn_qualifiers)]
271271
pub struct FnQualifierInExtern {
272272
#[primary_span]
273+
#[suggestion(code = "", applicability = "maybe-incorrect")]
273274
pub span: Span,
274275
#[label]
275276
pub block: Span,
276-
#[suggestion(code = "fn ", applicability = "maybe-incorrect", style = "verbose")]
277-
pub sugg_span: Span,
278277
}
279278

280279
#[derive(Diagnostic)]

compiler/rustc_codegen_cranelift/.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ task:
1313
- ./y.sh prepare
1414
test_script:
1515
- . $HOME/.cargo/env
16+
# Disabling incr comp reduces cache size and incr comp doesn't save as much
17+
# on CI anyway.
18+
- export CARGO_BUILD_INCREMENTAL=false
1619
- ./y.sh test

compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Abi-cafe
33
on:
44
- push
55

6+
permissions: {}
7+
68
jobs:
79
abi_cafe:
810
runs-on: ${{ matrix.os }}

compiler/rustc_codegen_cranelift/.github/workflows/main.yml

+28-40
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ on:
44
- push
55
- pull_request
66

7+
defaults:
8+
run:
9+
shell: bash
10+
11+
permissions: {}
12+
13+
env:
14+
# Disabling incr comp reduces cache size and incr comp doesn't save as much
15+
# on CI anyway.
16+
CARGO_BUILD_INCREMENTAL: false
17+
# Rust's CI denies warnings. Deny them here too to ensure subtree syncs don't
18+
# fail because of warnings.
19+
RUSTFLAGS: "-Dwarnings"
20+
721
jobs:
822
rustfmt:
923
runs-on: ubuntu-latest
@@ -23,15 +37,15 @@ jobs:
2337
cargo fmt --check
2438
rustfmt --check build_system/main.rs
2539
rustfmt --check example/*
40+
rustfmt --check scripts/*.rs
2641
2742
2843
test:
2944
runs-on: ${{ matrix.os }}
3045
timeout-minutes: 60
3146

32-
defaults:
33-
run:
34-
shell: bash
47+
env:
48+
CG_CLIF_EXPENSIVE_CHECKS: 1
3549

3650
strategy:
3751
fail-fast: false
@@ -47,15 +61,19 @@ jobs:
4761
- os: ubuntu-latest
4862
env:
4963
TARGET_TRIPLE: x86_64-pc-windows-gnu
64+
apt_deps: gcc-mingw-w64-x86-64 wine-stable
5065
- os: ubuntu-latest
5166
env:
5267
TARGET_TRIPLE: aarch64-unknown-linux-gnu
68+
apt_deps: gcc-aarch64-linux-gnu qemu-user
5369
- os: ubuntu-latest
5470
env:
5571
TARGET_TRIPLE: s390x-unknown-linux-gnu
72+
apt_deps: gcc-s390x-linux-gnu qemu-user
5673
- os: ubuntu-latest
5774
env:
5875
TARGET_TRIPLE: riscv64gc-unknown-linux-gnu
76+
apt_deps: gcc-riscv64-linux-gnu qemu-user
5977
- os: windows-latest
6078
env:
6179
TARGET_TRIPLE: x86_64-pc-windows-msvc
@@ -80,29 +98,11 @@ jobs:
8098
if: matrix.os == 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
8199
run: rustup set default-host x86_64-pc-windows-gnu
82100

83-
- name: Install MinGW toolchain and wine
84-
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
85-
run: |
86-
sudo apt-get update
87-
sudo apt-get install -y gcc-mingw-w64-x86-64 wine-stable
88-
89-
- name: Install AArch64 toolchain and qemu
90-
if: matrix.os == 'ubuntu-latest' && matrix.env.TARGET_TRIPLE == 'aarch64-unknown-linux-gnu'
91-
run: |
92-
sudo apt-get update
93-
sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user
94-
95-
- name: Install s390x toolchain and qemu
96-
if: matrix.env.TARGET_TRIPLE == 's390x-unknown-linux-gnu'
101+
- name: Install toolchain and emulator
102+
if: matrix.apt_deps != null
97103
run: |
98104
sudo apt-get update
99-
sudo apt-get install -y gcc-s390x-linux-gnu qemu-user
100-
101-
- name: Install riscv64gc toolchain and qemu
102-
if: matrix.env.TARGET_TRIPLE == 'riscv64gc-unknown-linux-gnu'
103-
run: |
104-
sudo apt-get update
105-
sudo apt-get install -y gcc-riscv64-linux-gnu qemu-user
105+
sudo apt-get install -y ${{ matrix.apt_deps }}
106106
107107
- name: Prepare dependencies
108108
run: ./y.sh prepare
@@ -142,10 +142,6 @@ jobs:
142142
runs-on: ubuntu-latest
143143
timeout-minutes: 60
144144

145-
defaults:
146-
run:
147-
shell: bash
148-
149145
steps:
150146
- uses: actions/checkout@v4
151147

@@ -168,10 +164,6 @@ jobs:
168164
runs-on: ubuntu-latest
169165
timeout-minutes: 60
170166

171-
defaults:
172-
run:
173-
shell: bash
174-
175167
steps:
176168
- uses: actions/checkout@v4
177169

@@ -193,20 +185,16 @@ jobs:
193185
run: ./y.sh prepare
194186

195187
- name: Build
196-
run: CI_OPT=1 ./y.sh build --sysroot none
188+
run: ./y.sh build --sysroot none
197189

198190
- name: Benchmark
199-
run: CI_OPT=1 ./y.sh bench
191+
run: ./y.sh bench
200192

201193

202194
dist:
203195
runs-on: ${{ matrix.os }}
204196
timeout-minutes: 60
205197

206-
defaults:
207-
run:
208-
shell: bash
209-
210198
strategy:
211199
fail-fast: false
212200
matrix:
@@ -252,10 +240,10 @@ jobs:
252240
run: ./y.sh prepare
253241

254242
- name: Build backend
255-
run: CI_OPT=1 ./y.sh build --sysroot none
243+
run: ./y.sh build --sysroot none
256244

257245
- name: Build sysroot
258-
run: CI_OPT=1 ./y.sh build
246+
run: ./y.sh build
259247

260248
- name: Package prebuilt cg_clif
261249
run: tar cvfJ cg_clif.tar.xz dist

compiler/rustc_codegen_cranelift/.github/workflows/rustc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Various rustc tests
33
on:
44
- push
55

6+
permissions: {}
7+
68
jobs:
79
bootstrap_rustc:
810
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)