Skip to content

Commit 80aa6fa

Browse files
committed
Auto merge of #130688 - workingjubilee:rollup-ovre6p7, r=workingjubilee
Rollup of 5 pull requests Successful merges: - #130648 (move enzyme flags from general cargo to rustc-specific cargo) - #130650 (Fixup Apple target's description strings) - #130664 (Generate line numbers for non-rust code examples as well) - #130665 (Prevent Deduplication of `LongRunningWarn`) - #130669 (tests: Test that `extern "C" fn` ptrs lint on slices) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1f9a018 + f314db6 commit 80aa6fa

30 files changed

+247
-44
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,14 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
641641
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
642642
// way to implement exponential backoff.
643643
let span = ecx.cur_span();
644-
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
644+
// We store a unique number in `force_duplicate` to evade `-Z deduplicate-diagnostics`.
645+
// `new_steps` is guaranteed to be unique because `ecx.machine.num_evaluated_steps` is
646+
// always increasing.
647+
ecx.tcx.dcx().emit_warn(LongRunningWarn {
648+
span,
649+
item_span: ecx.tcx.span,
650+
force_duplicate: new_steps,
651+
});
645652
}
646653
}
647654

Diff for: compiler/rustc_const_eval/src/errors.rs

+2
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ pub struct LongRunningWarn {
209209
pub span: Span,
210210
#[help]
211211
pub item_span: Span,
212+
// Used for evading `-Z deduplicate-diagnostics`.
213+
pub force_duplicate: usize,
212214
}
213215

214216
#[derive(Subdiagnostic)]

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 macOS (11.0+, Big Sur+)".into()),
9+
description: Some("ARM64 Apple macOS (11.0+, Big Sur+)".into()),
1010
tier: Some(1),
1111
host_tools: Some(true),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 iOS".into()),
9+
description: Some("ARM64 Apple iOS".into()),
1010
tier: Some(2),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("Apple Catalyst on ARM64".into()),
9+
description: Some("ARM64 Apple Mac Catalyst".into()),
1010
tier: Some(2),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("Apple iOS Simulator on ARM64".into()),
9+
description: Some("ARM64 Apple iOS Simulator".into()),
1010
tier: Some(2),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 tvOS".into()),
9+
description: Some("ARM64 Apple tvOS".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 tvOS Simulator".into()),
9+
description: Some("ARM64 Apple tvOS Simulator".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 Apple WatchOS".into()),
9+
description: Some("ARM64 Apple watchOS".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("ARM64 Apple WatchOS Simulator".into()),
9+
description: Some("ARM64 Apple watchOS Simulator".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("Arm Apple WatchOS 64-bit with 32-bit pointers".into()),
9+
description: Some("ARM64 Apple watchOS with 32-bit pointers".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("Armv7-A Apple-A6 Apple iOS".into()),
9+
description: Some("ARMv7-A Apple-A6 Apple iOS".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/i386_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
88
Target {
99
llvm_target,
1010
metadata: crate::spec::TargetMetadata {
11-
description: Some("32-bit x86 iOS".into()),
11+
description: Some("x86 Apple iOS Simulator".into()),
1212
tier: Some(3),
1313
host_tools: Some(false),
1414
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("32-bit macOS (10.12+, Sierra+)".into()),
9+
description: Some("x86 Apple macOS (10.12+, Sierra+)".into()),
1010
tier: Some(3),
1111
host_tools: Some(true),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("64-bit macOS (10.12+, Sierra+)".into()),
9+
description: Some("x86_64 Apple macOS (10.12+, Sierra+)".into()),
1010
tier: Some(1),
1111
host_tools: Some(true),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
88
Target {
99
llvm_target,
1010
metadata: crate::spec::TargetMetadata {
11-
description: Some("64-bit x86 iOS".into()),
11+
description: Some("x86_64 Apple iOS Simulator".into()),
1212
tier: Some(2),
1313
host_tools: Some(false),
1414
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("Apple Catalyst on x86_64".into()),
9+
description: Some("x86_64 Apple Mac Catalyst".into()),
1010
tier: Some(2),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64_apple_tvos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
88
Target {
99
llvm_target,
1010
metadata: crate::spec::TargetMetadata {
11-
description: Some("x86 64-bit tvOS".into()),
11+
description: Some("x86_64 Apple tvOS Simulator".into()),
1212
tier: Some(3),
1313
host_tools: Some(false),
1414
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64_apple_watchos_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
66
Target {
77
llvm_target,
88
metadata: crate::spec::TargetMetadata {
9-
description: Some("x86 64-bit Apple WatchOS simulator".into()),
9+
description: Some("x86_64 Apple watchOS Simulator".into()),
1010
tier: Some(3),
1111
host_tools: Some(false),
1212
std: Some(true),

Diff for: compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(crate) fn target() -> Target {
2929
Target {
3030
llvm_target,
3131
metadata: crate::spec::TargetMetadata {
32-
description: Some("macOS with late-gen Intel (at least Haswell)".into()),
32+
description: Some("x86_64 Apple macOS with Intel Haswell+".into()),
3333
tier: Some(3),
3434
host_tools: Some(true),
3535
std: Some(true),

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
10571057
// killed, rather than having an error bubble up and cause a panic.
10581058
cargo.rustflag("-Zon-broken-pipe=kill");
10591059

1060+
if builder.config.llvm_enzyme {
1061+
cargo.rustflag("-l").rustflag("Enzyme-19");
1062+
}
1063+
10601064
// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
10611065
// and may just be a time sink.
10621066
if compiler.stage != 0 {

Diff for: src/bootstrap/src/core/builder.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1592,12 +1592,6 @@ impl<'a> Builder<'a> {
15921592
rustflags.arg(sysroot_str);
15931593
}
15941594

1595-
// https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20link.20new.20library.20into.20stage1.2Frustc
1596-
if self.config.llvm_enzyme {
1597-
rustflags.arg("-l");
1598-
rustflags.arg("Enzyme-19");
1599-
}
1600-
16011595
let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
16021596
Some(setting) => {
16031597
// If an explicit setting is given, use that

Diff for: src/librustdoc/html/markdown.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
261261
</pre>\
262262
</div>",
263263
added_classes = added_classes.join(" "),
264-
text = Escape(&original_text),
264+
text = Escape(
265+
original_text.strip_suffix('\n').unwrap_or(&original_text)
266+
),
265267
)
266268
.into(),
267269
));

Diff for: src/librustdoc/html/markdown/tests.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() {
524524
####.###..#....#....#..#.
525525
#..#.#....#....#....#..#.
526526
#..#.#....#....#....#..#.
527-
#..#.####.####.####..##..
528-
</code></pre></div>",
527+
#..#.####.####.####..##..</code></pre></div>",
529528
);
530529
t(
531530
r#"```markdown
532531
# hello
533532
```"#,
534533
"<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\
535-
# hello
536-
</code></pre></div>",
534+
# hello</code></pre></div>",
537535
);
538536
}

Diff for: src/librustdoc/html/static/js/main.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,13 @@ function preLoadCss(cssUrl) {
986986
}());
987987

988988
window.rustdoc_add_line_numbers_to_examples = () => {
989-
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
989+
if (document.querySelector(".rustdoc.src")) {
990+
// We are in the source code page, nothing to be done here!
991+
return;
992+
}
993+
onEachLazy(document.querySelectorAll(
994+
":not(.scraped-example) > .example-wrap > pre:not(.example-line-numbers)",
995+
), x => {
990996
const parent = x.parentNode;
991997
const line_numbers = parent.querySelectorAll(".example-line-numbers");
992998
if (line_numbers.length > 0) {
@@ -1005,12 +1011,8 @@ function preLoadCss(cssUrl) {
10051011
};
10061012

10071013
window.rustdoc_remove_line_numbers_from_examples = () => {
1008-
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
1009-
const parent = x.parentNode;
1010-
const line_numbers = parent.querySelectorAll(".example-line-numbers");
1011-
for (const node of line_numbers) {
1012-
parent.removeChild(node);
1013-
}
1014+
onEachLazy(document.querySelectorAll(".example-wrap > .example-line-numbers"), x => {
1015+
x.parentNode.removeChild(x);
10141016
});
10151017
};
10161018

Diff for: tests/rustdoc-gui/docblock-code-block-line-number.goml

+60-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"})
8787

8888
// Then, click the toggle button.
8989
click: "input#line-numbers"
90-
wait-for: 100 // wait-for-false does not exist
90+
wait-for: 100 // FIXME: `wait-for-false` does not exist
9191
assert-false: "pre.example-line-numbers"
9292
assert-local-storage: {"rustdoc-line-numbers": "false" }
9393

@@ -107,6 +107,8 @@ assert-css: (
107107
click: "input#line-numbers"
108108
wait-for: "pre.example-line-numbers"
109109
assert-local-storage: {"rustdoc-line-numbers": "true" }
110+
wait-for: 100 // FIXME: `wait-for-false` does not exist
111+
assert: "pre.example-line-numbers"
110112

111113
// Same check with scraped examples line numbers.
112114
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
@@ -145,9 +147,6 @@ assert-css: (
145147
ALL,
146148
)
147149

148-
// Checking line numbers on scraped code examples.
149-
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
150-
151150
define-function: (
152151
"check-padding",
153152
[path, padding_bottom],
@@ -157,19 +156,19 @@ define-function: (
157156
"padding-bottom": "0px",
158157
"padding-left": "0px",
159158
"padding-right": "0px",
160-
})
159+
}, ALL)
161160
assert-css: (|path| + " .src-line-numbers > pre", {
162161
"padding-top": "14px",
163162
"padding-bottom": |padding_bottom|,
164163
"padding-left": "0px",
165164
"padding-right": "0px",
166-
})
165+
}, ALL)
167166
assert-css: (|path| + " .src-line-numbers > pre > span", {
168167
"padding-top": "0px",
169168
"padding-bottom": "0px",
170169
"padding-left": "8px",
171170
"padding-right": "8px",
172-
})
171+
}, ALL)
173172
},
174173
)
175174

@@ -188,6 +187,35 @@ call-function: ("check-padding", {
188187
"padding_bottom": "14px",
189188
})
190189

190+
define-function: ("check-line-numbers-existence", [], block {
191+
assert-local-storage: {"rustdoc-line-numbers": "true" }
192+
assert-false: ".example-line-numbers"
193+
click: "#settings-menu"
194+
wait-for: "#settings"
195+
196+
// Then, click the toggle button.
197+
click: "input#line-numbers"
198+
wait-for: 100 // FIXME: `wait-for-false` does not exist
199+
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
200+
assert-false: ".example-line-numbers"
201+
// Line numbers should still be there.
202+
assert: ".src-line-numbers"
203+
// Now disabling the setting.
204+
click: "input#line-numbers"
205+
wait-for: 100 // FIXME: `wait-for-false` does not exist
206+
assert-local-storage: {"rustdoc-line-numbers": "true" }
207+
assert-false: ".example-line-numbers"
208+
// Line numbers should still be there.
209+
assert: ".src-line-numbers"
210+
// Closing settings menu.
211+
click: "#settings-menu"
212+
wait-for-css: ("#settings", {"display": "none"})
213+
})
214+
215+
// Checking that turning off the line numbers setting won't remove line numbers from scraped
216+
// examples.
217+
call-function: ("check-line-numbers-existence", {})
218+
191219
// Now checking the line numbers in the source code page.
192220
click: ".src"
193221
assert-css: (".src-line-numbers", {
@@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", {
202230
"padding-left": "8px",
203231
"padding-right": "8px",
204232
})
233+
// Checking that turning off the line numbers setting won't remove line numbers.
234+
call-function: ("check-line-numbers-existence", {})
235+
236+
// Now checking that even non-rust code blocks have line numbers generated.
237+
go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
238+
assert-local-storage: {"rustdoc-line-numbers": "true" }
239+
assert: ".example-wrap > pre.language-txt"
240+
assert: ".example-wrap > pre.rust"
241+
assert-count: (".example-wrap", 2)
242+
assert-count: (".example-wrap > pre.example-line-numbers", 2)
243+
244+
click: "#settings-menu"
245+
wait-for: "#settings"
246+
247+
// Then, click the toggle button.
248+
click: "input#line-numbers"
249+
wait-for: 100 // FIXME: `wait-for-false` does not exist
250+
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
251+
assert-count: (".example-wrap > pre.example-line-numbers", 0)
252+
253+
// Now turning off the setting.
254+
click: "input#line-numbers"
255+
wait-for: 100 // FIXME: `wait-for-false` does not exist
256+
assert-local-storage: {"rustdoc-line-numbers": "true" }
257+
assert-count: (".example-wrap > pre.example-line-numbers", 2)

0 commit comments

Comments
 (0)