Skip to content

Commit 26df93a

Browse files
committed
Auto merge of rust-lang#134896 - matthiaskrgr:rollup-4u56z7j, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#134865 (bootstrap: Don't apply -Ztls-model=initial-exec to deps of proc-macros) - rust-lang#134884 (Fix typos) - rust-lang#134892 (Added codegen test for elidings bounds check when indexes are manually checked) - rust-lang#134894 (Document how to run the split Docker pipelines) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5c0a6e6 + 9598b20 commit 26df93a

File tree

12 files changed

+218
-16
lines changed

12 files changed

+218
-16
lines changed

Cargo.lock

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ dependencies = [
367367
name = "cargo-miri"
368368
version = "0.1.0"
369369
dependencies = [
370-
"cargo_metadata",
370+
"cargo_metadata 0.18.1",
371371
"directories",
372372
"rustc-build-sysroot",
373373
"rustc_tools_util",
@@ -399,6 +399,20 @@ dependencies = [
399399
"thiserror 1.0.69",
400400
]
401401

402+
[[package]]
403+
name = "cargo_metadata"
404+
version = "0.19.1"
405+
source = "registry+https://github.com/rust-lang/crates.io-index"
406+
checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924"
407+
dependencies = [
408+
"camino",
409+
"cargo-platform",
410+
"semver",
411+
"serde",
412+
"serde_json",
413+
"thiserror 2.0.9",
414+
]
415+
402416
[[package]]
403417
name = "cargotest2"
404418
version = "0.1.0"
@@ -533,7 +547,7 @@ name = "clippy"
533547
version = "0.1.85"
534548
dependencies = [
535549
"anstream",
536-
"cargo_metadata",
550+
"cargo_metadata 0.18.1",
537551
"clippy_config",
538552
"clippy_lints",
539553
"clippy_utils",
@@ -589,7 +603,7 @@ name = "clippy_lints"
589603
version = "0.1.85"
590604
dependencies = [
591605
"arrayvec",
592-
"cargo_metadata",
606+
"cargo_metadata 0.18.1",
593607
"clippy_config",
594608
"clippy_utils",
595609
"itertools",
@@ -1389,7 +1403,7 @@ name = "generate-copyright"
13891403
version = "0.1.0"
13901404
dependencies = [
13911405
"anyhow",
1392-
"cargo_metadata",
1406+
"cargo_metadata 0.18.1",
13931407
"rinja",
13941408
"serde",
13951409
"serde_json",
@@ -4750,7 +4764,7 @@ dependencies = [
47504764
"annotate-snippets 0.9.2",
47514765
"anyhow",
47524766
"bytecount",
4753-
"cargo_metadata",
4767+
"cargo_metadata 0.18.1",
47544768
"clap",
47554769
"clap-cargo",
47564770
"diff",
@@ -5344,7 +5358,7 @@ name = "tidy"
53445358
version = "0.1.0"
53455359
dependencies = [
53465360
"build_helper",
5347-
"cargo_metadata",
5361+
"cargo_metadata 0.19.1",
53485362
"fluent-syntax",
53495363
"ignore",
53505364
"miropt-test-tools",
@@ -5622,7 +5636,7 @@ dependencies = [
56225636
"anyhow",
56235637
"bstr",
56245638
"cargo-platform",
5625-
"cargo_metadata",
5639+
"cargo_metadata 0.18.1",
56265640
"color-eyre",
56275641
"colored",
56285642
"comma",

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl<'a> Parser<'a> {
755755
// When there are a few keywords in the last ten elements of `self.expected_token_types`
756756
// and the current token is an identifier, it's probably a misspelled keyword. This handles
757757
// code like `async Move {}`, misspelled `if` in match guard, misspelled `else` in
758-
// `if`-`else` and mispelled `where` in a where clause.
758+
// `if`-`else` and misspelled `where` in a where clause.
759759
if !expected_keywords.is_empty()
760760
&& !curr_ident.is_used_keyword()
761761
&& let Some(misspelled_kw) = find_similar_kw(curr_ident, &expected_keywords)

library/alloc/src/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl<A: Allocator> RawVecInner<A> {
420420
match Self::try_allocate_in(capacity, AllocInit::Uninitialized, alloc, elem_layout) {
421421
Ok(this) => {
422422
unsafe {
423-
// Make it more obvious that a subsquent Vec::reserve(capacity) will not allocate.
423+
// Make it more obvious that a subsequent Vec::reserve(capacity) will not allocate.
424424
hint::assert_unchecked(!this.needs_to_grow(0, capacity, elem_layout));
425425
}
426426
this

library/std/src/thread/current.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub(crate) fn set_current(thread: Thread) -> Result<(), Thread> {
136136
/// one thread and is guaranteed not to call the global allocator.
137137
#[inline]
138138
pub(crate) fn current_id() -> ThreadId {
139-
// If accessing the persistant thread ID takes multiple TLS accesses, try
139+
// If accessing the persistent thread ID takes multiple TLS accesses, try
140140
// to retrieve it from the current thread handle, which will only take one
141141
// TLS access.
142142
if !id::CHEAP {

src/bootstrap/src/bin/rustc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ use shared_helpers::{
2828
#[path = "../utils/shared_helpers.rs"]
2929
mod shared_helpers;
3030

31+
#[path = "../utils/proc_macro_deps.rs"]
32+
mod proc_macro_deps;
33+
3134
fn main() {
3235
let orig_args = env::args_os().skip(1).collect::<Vec<_>>();
3336
let mut args = orig_args.clone();
@@ -167,7 +170,7 @@ fn main() {
167170
// issue https://github.com/rust-lang/rust/issues/100530
168171
if env::var("RUSTC_TLS_MODEL_INITIAL_EXEC").is_ok()
169172
&& crate_type != Some("proc-macro")
170-
&& !matches!(crate_name, Some("proc_macro2" | "quote" | "syn" | "synstructure"))
173+
&& proc_macro_deps::CRATES.binary_search(&crate_name.unwrap_or_default()).is_err()
171174
{
172175
cmd.arg("-Ztls-model=initial-exec");
173176
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/// Do not update manually - use `./x.py test tidy --bless`
2+
/// Holds all direct and indirect dependencies of proc-macro crates in tree.
3+
/// See https://github.com/rust-lang/rust/issues/134863
4+
pub static CRATES: &[&str] = &[
5+
// tidy-alphabetical-start
6+
"annotate-snippets",
7+
"anstyle",
8+
"basic-toml",
9+
"block-buffer",
10+
"bumpalo",
11+
"cfg-if",
12+
"cpufeatures",
13+
"crypto-common",
14+
"darling",
15+
"darling_core",
16+
"derive_builder_core",
17+
"digest",
18+
"fluent-bundle",
19+
"fluent-langneg",
20+
"fluent-syntax",
21+
"fnv",
22+
"generic-array",
23+
"heck",
24+
"ident_case",
25+
"intl-memoizer",
26+
"intl_pluralrules",
27+
"libc",
28+
"log",
29+
"memchr",
30+
"mime",
31+
"mime_guess",
32+
"minimal-lexical",
33+
"nom",
34+
"num-conv",
35+
"once_cell",
36+
"pest",
37+
"pest_generator",
38+
"pest_meta",
39+
"proc-macro2",
40+
"quote",
41+
"rinja_parser",
42+
"rustc-hash",
43+
"self_cell",
44+
"serde",
45+
"sha2",
46+
"smallvec",
47+
"stable_deref_trait",
48+
"strsim",
49+
"syn",
50+
"synstructure",
51+
"thiserror",
52+
"time-core",
53+
"tinystr",
54+
"type-map",
55+
"typenum",
56+
"ucd-trie",
57+
"unic-langid",
58+
"unic-langid-impl",
59+
"unic-langid-macros",
60+
"unicase",
61+
"unicode-ident",
62+
"unicode-width",
63+
"version_check",
64+
"wasm-bindgen-backend",
65+
"wasm-bindgen-macro-support",
66+
"wasm-bindgen-shared",
67+
"yoke",
68+
"zerofrom",
69+
"zerovec",
70+
// tidy-alphabetical-end
71+
];

src/ci/docker/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ DEPLOY=1 ./src/ci/docker/run.sh x86_64-gnu
2626
while locally, to the `obj/$image_name` directory. This is primarily to prevent
2727
strange linker errors when using multiple Docker images.
2828

29+
For some Linux workflows (for example `x86_64-gnu-llvm-18-N`), the process is more involved. You will need to see which script is executed for the given workflow inside the [`jobs.yml`](../github-actions/jobs.yml) file and pass it through the `DOCKER_SCRIPT` environment variable. For example, to reproduce the `x86_64-gnu-llvm-18-3` workflow, you can run the following script:
30+
31+
```
32+
DOCKER_SCRIPT=x86_64-gnu-llvm3.sh ./src/ci/docker/run.sh x86_64-gnu-llvm-18
33+
```
34+
2935
## Local Development
3036

3137
Refer to the [dev guide](https://rustc-dev-guide.rust-lang.org/tests/docker.html) for more information on testing locally.

src/doc/rustc/src/platform-support/android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ Currently the `riscv64-linux-android` target requires the following architecture
6565
### aarch64-linux-android on Nightly compilers
6666

6767
As soon as `-Zfixed-x18` compiler flag is supplied, the [`ShadowCallStack` sanitizer](https://releases.llvm.org/7.0.1/tools/clang/docs/ShadowCallStack.html)
68-
instrumentation is also made avaiable by supplying the second compiler flag `-Zsanitizer=shadow-call-stack`.
68+
instrumentation is also made available by supplying the second compiler flag `-Zsanitizer=shadow-call-stack`.

src/tools/tidy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ autobins = false
66

77
[dependencies]
88
build_helper = { path = "../../build_helper" }
9-
cargo_metadata = "0.18"
9+
cargo_metadata = "0.19"
1010
regex = "1"
1111
miropt-test-tools = { path = "../miropt-test-tools" }
1212
walkdir = "2"

src/tools/tidy/src/deps.rs

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
//! Checks the licenses of third-party dependencies.
22
33
use std::collections::HashSet;
4-
use std::fs::read_dir;
4+
use std::fs::{File, read_dir};
5+
use std::io::Write;
56
use std::path::Path;
67

78
use build_helper::ci::CiEnv;
89
use cargo_metadata::{Metadata, Package, PackageId};
910

11+
#[path = "../../../bootstrap/src/utils/proc_macro_deps.rs"]
12+
mod proc_macro_deps;
13+
1014
/// These are licenses that are allowed for all crates, including the runtime,
1115
/// rustc, tools, etc.
1216
#[rustfmt::skip]
@@ -564,9 +568,11 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
564568
///
565569
/// `root` is path to the directory with the root `Cargo.toml` (for the workspace). `cargo` is path
566570
/// to the cargo executable.
567-
pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
571+
pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
568572
let mut checked_runtime_licenses = false;
569573

574+
check_proc_macro_dep_list(root, cargo, bless, bad);
575+
570576
for &(workspace, exceptions, permitted_deps, submodules) in WORKSPACES {
571577
if has_missing_submodule(root, submodules) {
572578
continue;
@@ -600,6 +606,71 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
600606
assert!(checked_runtime_licenses);
601607
}
602608

609+
/// Ensure the list of proc-macro crate transitive dependencies is up to date
610+
fn check_proc_macro_dep_list(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
611+
let mut cmd = cargo_metadata::MetadataCommand::new();
612+
cmd.cargo_path(cargo)
613+
.manifest_path(root.join("Cargo.toml"))
614+
.features(cargo_metadata::CargoOpt::AllFeatures)
615+
.other_options(vec!["--locked".to_owned()]);
616+
let metadata = t!(cmd.exec());
617+
let is_proc_macro_pkg = |pkg: &Package| pkg.targets.iter().any(|target| target.is_proc_macro());
618+
619+
let mut proc_macro_deps = HashSet::new();
620+
for pkg in metadata.packages.iter().filter(|pkg| is_proc_macro_pkg(*pkg)) {
621+
deps_of(&metadata, &pkg.id, &mut proc_macro_deps);
622+
}
623+
// Remove the proc-macro crates themselves
624+
proc_macro_deps.retain(|pkg| !is_proc_macro_pkg(&metadata[pkg]));
625+
let proc_macro_deps_iter = proc_macro_deps.into_iter().map(|dep| metadata[dep].name.clone());
626+
627+
if bless {
628+
let mut proc_macro_deps: Vec<_> = proc_macro_deps_iter.collect();
629+
proc_macro_deps.sort();
630+
proc_macro_deps.dedup();
631+
let mut file = File::create(root.join("src/bootstrap/src/utils/proc_macro_deps.rs"))
632+
.expect("`proc_macro_deps` should exist");
633+
writeln!(
634+
&mut file,
635+
"/// Do not update manually - use `./x.py test tidy --bless`
636+
/// Holds all direct and indirect dependencies of proc-macro crates in tree.
637+
/// See https://github.com/rust-lang/rust/issues/134863
638+
pub static CRATES: &[&str] = &[
639+
// tidy-alphabetical-start"
640+
)
641+
.unwrap();
642+
for dep in proc_macro_deps {
643+
writeln!(&mut file, " {dep:?},").unwrap();
644+
}
645+
writeln!(
646+
&mut file,
647+
" // tidy-alphabetical-end
648+
];"
649+
)
650+
.unwrap();
651+
} else {
652+
let proc_macro_deps: HashSet<_> = proc_macro_deps_iter.collect();
653+
let expected =
654+
proc_macro_deps::CRATES.iter().map(|s| s.to_string()).collect::<HashSet<_>>();
655+
let old_bad = *bad;
656+
for missing in proc_macro_deps.difference(&expected) {
657+
tidy_error!(
658+
bad,
659+
"proc-macro crate dependency `{missing}` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`",
660+
);
661+
}
662+
for extra in expected.difference(&proc_macro_deps) {
663+
tidy_error!(
664+
bad,
665+
"`{extra}` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency",
666+
);
667+
}
668+
if *bad != old_bad {
669+
eprintln!("Run `./x.py test tidy --bless` to regenerate the list");
670+
}
671+
}
672+
}
673+
603674
/// Used to skip a check if a submodule is not checked out, and not in a CI environment.
604675
///
605676
/// This helps prevent enforcing developers to fetch submodules for tidy.

src/tools/tidy/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn main() {
9595
check!(target_specific_tests, &tests_path);
9696

9797
// Checks that are done on the cargo workspace.
98-
check!(deps, &root_path, &cargo);
98+
check!(deps, &root_path, &cargo, bless);
9999
check!(extdeps, &root_path);
100100

101101
// Checks over tests.

tests/codegen/slice-indexing.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,40 @@ pub unsafe fn str_get_unchecked_mut_by_range(x: &mut str, r: Range<usize>) -> &m
6060
// CHECK: sub nuw i64
6161
x.get_unchecked_mut(r)
6262
}
63+
64+
// CHECK-LABEL: @slice_repeated_indexing(
65+
#[no_mangle]
66+
pub fn slice_repeated_indexing(dst: &mut [u8], offset: usize) {
67+
let mut i = offset;
68+
// CHECK: panic_bounds_check
69+
dst[i] = 1;
70+
i += 1;
71+
// CHECK: panic_bounds_check
72+
dst[i] = 2;
73+
i += 1;
74+
// CHECK: panic_bounds_check
75+
dst[i] = 3;
76+
i += 1;
77+
// CHECK: panic_bounds_check
78+
dst[i] = 4;
79+
}
80+
81+
// CHECK-LABEL: @slice_repeated_indexing_coalesced(
82+
#[no_mangle]
83+
pub fn slice_repeated_indexing_coalesced(dst: &mut [u8], offset: usize) {
84+
let mut i = offset;
85+
if i.checked_add(4).unwrap() <= dst.len() {
86+
// CHECK-NOT: panic_bounds_check
87+
dst[i] = 1;
88+
i += 1;
89+
// CHECK-NOT: panic_bounds_check
90+
dst[i] = 2;
91+
i += 1;
92+
// CHECK-NOT: panic_bounds_check
93+
dst[i] = 3;
94+
i += 1;
95+
// CHECK-NOT: panic_bounds_check
96+
dst[i] = 4;
97+
}
98+
// CHECK: ret
99+
}

0 commit comments

Comments
 (0)