Skip to content

Commit 4d76b4c

Browse files
committed
Auto merge of rust-lang#83067 - JohnTitor:rollup-0wo338i, r=JohnTitor
Rollup of 6 pull requests Successful merges: - rust-lang#82984 (Simplify ast block lowering) - rust-lang#83012 (Update Clippy) - rust-lang#83020 (Emit the enum range assumption if the range only contains one element) - rust-lang#83037 (Support merge_functions option in NewPM since LLVM >= 12) - rust-lang#83052 (updated vulnerable deps) - rust-lang#83059 (Allow configuring `rustdoc --disable-minification` in config.toml) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 46a934a + 684fa19 commit 4d76b4c

File tree

305 files changed

+15670
-12498
lines changed

Some content is hidden

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

305 files changed

+15670
-12498
lines changed

Cargo.lock

+9-15
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ version = "1.0.34"
9595
source = "registry+https://github.com/rust-lang/crates.io-index"
9696
checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
9797

98-
[[package]]
99-
name = "arc-swap"
100-
version = "0.4.7"
101-
source = "registry+https://github.com/rust-lang/crates.io-index"
102-
checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"
103-
10498
[[package]]
10599
name = "array_tool"
106100
version = "1.0.3"
@@ -177,7 +171,7 @@ dependencies = [
177171
"block-padding",
178172
"byte-tools",
179173
"byteorder",
180-
"generic-array 0.12.3",
174+
"generic-array 0.12.4",
181175
]
182176

183177
[[package]]
@@ -570,6 +564,7 @@ dependencies = [
570564
"clippy_lints",
571565
"compiletest_rs 0.6.0",
572566
"derive-new",
567+
"regex",
573568
"rustc-workspace-hack",
574569
"rustc_tools_util 0.2.0",
575570
"semver 0.11.0",
@@ -1006,7 +1001,7 @@ version = "0.8.1"
10061001
source = "registry+https://github.com/rust-lang/crates.io-index"
10071002
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
10081003
dependencies = [
1009-
"generic-array 0.12.3",
1004+
"generic-array 0.12.4",
10101005
]
10111006

10121007
[[package]]
@@ -1399,9 +1394,9 @@ dependencies = [
13991394

14001395
[[package]]
14011396
name = "generic-array"
1402-
version = "0.12.3"
1397+
version = "0.12.4"
14031398
source = "registry+https://github.com/rust-lang/crates.io-index"
1404-
checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
1399+
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
14051400
dependencies = [
14061401
"typenum",
14071402
]
@@ -4917,11 +4912,10 @@ checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d"
49174912

49184913
[[package]]
49194914
name = "signal-hook-registry"
4920-
version = "1.2.1"
4915+
version = "1.2.2"
49214916
source = "registry+https://github.com/rust-lang/crates.io-index"
4922-
checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035"
4917+
checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab"
49234918
dependencies = [
4924-
"arc-swap",
49254919
"libc",
49264920
]
49274921

@@ -4933,9 +4927,9 @@ checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7"
49334927

49344928
[[package]]
49354929
name = "sized-chunks"
4936-
version = "0.6.2"
4930+
version = "0.6.4"
49374931
source = "registry+https://github.com/rust-lang/crates.io-index"
4938-
checksum = "1ec31ceca5644fa6d444cc77548b88b67f46db6f7c71683b0f9336e671830d2f"
4932+
checksum = "65e65d6a9f13cd78f361ea5a2cf53a45d67cdda421ba0316b9be101560f3d207"
49394933
dependencies = [
49404934
"bitmaps",
49414935
"typenum",

compiler/rustc_ast_lowering/src/lib.rs

+6-20
Original file line numberDiff line numberDiff line change
@@ -2409,26 +2409,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24092409
}
24102410

24112411
fn lower_block_noalloc(&mut self, b: &Block, targeted_by_break: bool) -> hir::Block<'hir> {
2412-
let mut expr: Option<&'hir _> = None;
2413-
2414-
let stmts = self.arena.alloc_from_iter(
2415-
b.stmts
2416-
.iter()
2417-
.enumerate()
2418-
.filter_map(|(index, stmt)| {
2419-
if index == b.stmts.len() - 1 {
2420-
if let StmtKind::Expr(ref e) = stmt.kind {
2421-
expr = Some(self.lower_expr(e));
2422-
None
2423-
} else {
2424-
Some(self.lower_stmt(stmt))
2425-
}
2426-
} else {
2427-
Some(self.lower_stmt(stmt))
2428-
}
2429-
})
2430-
.flatten(),
2431-
);
2412+
let (stmts, expr) = match &*b.stmts {
2413+
[stmts @ .., Stmt { kind: StmtKind::Expr(e), .. }] => (stmts, Some(&*e)),
2414+
stmts => (stmts, None),
2415+
};
2416+
let stmts = self.arena.alloc_from_iter(stmts.iter().flat_map(|stmt| self.lower_stmt(stmt)));
2417+
let expr = expr.map(|e| self.lower_expr(e));
24322418
let rules = self.lower_block_check_mode(&b.rules);
24332419
let hir_id = self.lower_node_id(b.id);
24342420

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
325325

326326
let er = scalar.valid_range_exclusive(bx.cx());
327327
if er.end != er.start
328-
&& scalar.valid_range.end() > scalar.valid_range.start()
328+
&& scalar.valid_range.end() >= scalar.valid_range.start()
329329
{
330330
// We want `table[e as usize ± k]` to not
331331
// have bound checks, and this is the most

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -772,14 +772,18 @@ LLVMRustOptimizeWithNewPassManager(
772772
TargetMachine *TM = unwrap(TMRef);
773773
PassBuilder::OptimizationLevel OptLevel = fromRust(OptLevelRust);
774774

775-
// FIXME: MergeFunctions is not supported by NewPM yet.
776-
(void) MergeFunctions;
777775

778776
PipelineTuningOptions PTO;
779777
PTO.LoopUnrolling = UnrollLoops;
780778
PTO.LoopInterleaving = UnrollLoops;
781779
PTO.LoopVectorization = LoopVectorize;
782780
PTO.SLPVectorization = SLPVectorize;
781+
#if LLVM_VERSION_GE(12, 0)
782+
PTO.MergeFunctions = MergeFunctions;
783+
#else
784+
// MergeFunctions is not supported by NewPM in older LLVM versions.
785+
(void) MergeFunctions;
786+
#endif
783787

784788
// FIXME: We may want to expose this as an option.
785789
bool DebugPassManager = false;

config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ changelog-seen = 2
208208
# documentation.
209209
#docs = true
210210

211+
# Flag to specify whether CSS, JavaScript, and HTML are minified when
212+
# docs are generated. JSON is always minified, because it's enormous,
213+
# and generated in already-minified form from the beginning.
214+
#docs-minification = true
215+
211216
# Indicate whether the compiler should be documented in addition to the standard
212217
# library and facade crates.
213218
#compiler-docs = false

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct Config {
5151
pub submodules: bool,
5252
pub fast_submodules: bool,
5353
pub compiler_docs: bool,
54+
pub docs_minification: bool,
5455
pub docs: bool,
5556
pub locked_deps: bool,
5657
pub vendor: bool,
@@ -362,6 +363,7 @@ struct Build {
362363
rustfmt: Option<PathBuf>,
363364
docs: Option<bool>,
364365
compiler_docs: Option<bool>,
366+
docs_minification: Option<bool>,
365367
submodules: Option<bool>,
366368
fast_submodules: Option<bool>,
367369
gdb: Option<String>,
@@ -557,6 +559,7 @@ impl Config {
557559
config.submodules = true;
558560
config.fast_submodules = true;
559561
config.docs = true;
562+
config.docs_minification = true;
560563
config.rust_rpath = true;
561564
config.channel = "dev".to_string();
562565
config.codegen_tests = true;
@@ -663,6 +666,7 @@ impl Config {
663666
config.python = build.python.map(PathBuf::from);
664667
set(&mut config.low_priority, build.low_priority);
665668
set(&mut config.compiler_docs, build.compiler_docs);
669+
set(&mut config.docs_minification, build.docs_minification);
666670
set(&mut config.docs, build.docs);
667671
set(&mut config.submodules, build.submodules);
668672
set(&mut config.fast_submodules, build.fast_submodules);

src/bootstrap/doc.rs

+12
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ fn invoke_rustdoc(
270270
.arg("--markdown-css")
271271
.arg("../rust.css");
272272

273+
if !builder.config.docs_minification {
274+
cmd.arg("-Z").arg("unstable-options").arg("--disable-minification");
275+
}
276+
273277
builder.run(&mut cmd);
274278
}
275279

@@ -365,6 +369,10 @@ impl Step for Standalone {
365369
.arg(&out)
366370
.arg(&path);
367371

372+
if !builder.config.docs_minification {
373+
cmd.arg("--disable-minification");
374+
}
375+
368376
if filename == "not_found.md" {
369377
cmd.arg("--markdown-css").arg("https://doc.rust-lang.org/rust.css");
370378
} else {
@@ -437,6 +445,10 @@ impl Step for Std {
437445
.arg("--index-page")
438446
.arg(&builder.src.join("src/doc/index.md"));
439447

448+
if !builder.config.docs_minification {
449+
cargo.arg("--disable-minification");
450+
}
451+
440452
builder.run(&mut cargo.into());
441453
};
442454
// Only build the following crates. While we could just iterate over the
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// compile-flags: -O
2+
// min-llvm-version: 11.0
3+
4+
#![crate_type = "lib"]
5+
6+
#[repr(C)]
7+
pub enum E {
8+
A,
9+
}
10+
11+
// CHECK-LABEL: @index
12+
#[no_mangle]
13+
pub fn index(x: &[u32; 3], ind: E) -> u32{
14+
// CHECK-NOT: panic_bounds_check
15+
x[ind as usize]
16+
}

src/tools/clippy/.cargo/config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[alias]
22
uitest = "test --test compile-test"
33
dev = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
4-
dev-lintcheck = "run --target-dir clippy_dev/target --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --features lintcheck -- lintcheck"
4+
lintcheck = "run --target-dir lintcheck/target --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
55

66
[build]
77
rustflags = ["-Zunstable-options"]

src/tools/clippy/.github/workflows/clippy.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env:
2727

2828
jobs:
2929
base:
30+
# NOTE: If you modify this job, make sure you copy the changes to clippy_bors.yml
3031
runs-on: ubuntu-latest
3132

3233
steps:
@@ -50,11 +51,16 @@ jobs:
5051
- name: Build
5152
run: cargo build --features deny-warnings,internal-lints
5253

53-
- name: Test "--fix -Zunstable-options"
54-
run: cargo run --features deny-warnings,internal-lints --bin cargo-clippy -- clippy --fix -Zunstable-options
54+
- name: Test
55+
run: cargo test --features deny-warnings,internal-lints
5556

56-
- name: Test Workspace
57-
run: cargo test --all --features deny-warnings,internal-lints
57+
- name: Test clippy_lints
58+
run: cargo test --features deny-warnings,internal-lints
59+
working-directory: clippy_lints
60+
61+
- name: Test rustc_tools_util
62+
run: cargo test --features deny-warnings
63+
working-directory: rustc_tools_util
5864

5965
- name: Test clippy_dev
6066
run: cargo test --features deny-warnings
@@ -64,6 +70,10 @@ jobs:
6470
run: ../target/debug/cargo-clippy
6571
working-directory: clippy_workspace_tests
6672

73+
- name: Test cargo-clippy --fix
74+
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
75+
working-directory: clippy_workspace_tests
76+
6777
- name: Test clippy-driver
6878
run: bash .github/driver.sh
6979
env:

src/tools/clippy/.github/workflows/clippy_bors.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272

7373
runs-on: ${{ matrix.os }}
7474

75+
# NOTE: If you modify this job, make sure you copy the changes to clippy.yml
7576
steps:
7677
# Setup
7778
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
@@ -112,8 +113,16 @@ jobs:
112113
- name: Build
113114
run: cargo build --features deny-warnings,internal-lints
114115

115-
- name: Test Workspace
116-
run: cargo test --all --features deny-warnings,internal-lints
116+
- name: Test
117+
run: cargo test --features deny-warnings,internal-lints
118+
119+
- name: Test clippy_lints
120+
run: cargo test --features deny-warnings,internal-lints
121+
working-directory: clippy_lints
122+
123+
- name: Test rustc_tools_util
124+
run: cargo test --features deny-warnings
125+
working-directory: rustc_tools_util
117126

118127
- name: Test clippy_dev
119128
run: cargo test --features deny-warnings
@@ -123,11 +132,22 @@ jobs:
123132
run: ../target/debug/cargo-clippy
124133
working-directory: clippy_workspace_tests
125134

135+
- name: Test cargo-clippy --fix
136+
run: ../target/debug/cargo-clippy clippy --fix -Zunstable-options
137+
working-directory: clippy_workspace_tests
138+
126139
- name: Test clippy-driver
127140
run: bash .github/driver.sh
128141
env:
129142
OS: ${{ runner.os }}
130143

144+
- name: Test cargo dev new lint
145+
run: |
146+
cargo dev new_lint --name new_early_pass --pass early
147+
cargo dev new_lint --name new_late_pass --pass late
148+
cargo check
149+
git reset --hard HEAD
150+
131151
integration_build:
132152
needs: changelog
133153
runs-on: ubuntu-latest

src/tools/clippy/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ out
2121
/clippy_utils/target
2222
/clippy_workspace_tests/target
2323
/clippy_dev/target
24+
/lintcheck/target
2425
/rustc_tools_util/target
2526

2627
# Generated by dogfood

src/tools/clippy/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,7 @@ Released 2018-09-13
21042104
[`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_not_else
21052105
[`if_same_then_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else
21062106
[`ifs_same_cond`]: https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond
2107+
[`implicit_clone`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_clone
21072108
[`implicit_hasher`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher
21082109
[`implicit_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_return
21092110
[`implicit_saturating_sub`]: https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
@@ -2134,6 +2135,7 @@ Released 2018-09-13
21342135
[`invisible_characters`]: https://rust-lang.github.io/rust-clippy/master/index.html#invisible_characters
21352136
[`items_after_statements`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_statements
21362137
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
2138+
[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
21372139
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
21382140
[`iter_next_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_slice
21392141
[`iter_nth`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth

src/tools/clippy/Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
[package]
22
name = "clippy"
33
version = "0.1.52"
4-
authors = [
5-
"Manish Goregaokar <[email protected]>",
6-
"Andre Bogus <[email protected]>",
7-
"Georg Brandl <[email protected]>",
8-
"Martin Carton <[email protected]>",
9-
"Oliver Schneider <[email protected]>"
10-
]
4+
authors = ["The Rust Clippy Developers"]
115
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
126
repository = "https://github.com/rust-lang/rust-clippy"
137
readme = "README.md"
@@ -42,6 +36,7 @@ tester = "0.9"
4236
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
4337
serde = { version = "1.0", features = ["derive"] }
4438
derive-new = "0.5"
39+
regex = "1.4"
4540

4641
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
4742
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
@@ -55,3 +50,7 @@ rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
5550
deny-warnings = []
5651
integration = ["tempfile"]
5752
internal-lints = ["clippy_lints/internal-lints"]
53+
54+
[package.metadata.rust-analyzer]
55+
# This package uses #[feature(rustc_private)]
56+
rustc_private = true

src/tools/clippy/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ the lint(s) you are interested in:
202202
```terminal
203203
cargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...
204204
```
205-
Note that if you've run clippy before, this may only take effect after you've modified a file or ran `cargo clean`.
206205

207206
### Specifying the minimum supported Rust version
208207

0 commit comments

Comments
 (0)