Skip to content

Commit

Permalink
Auto merge of rust-lang#130688 - workingjubilee:rollup-ovre6p7, r=wor…
Browse files Browse the repository at this point in the history
…kingjubilee

Rollup of 5 pull requests

Successful merges:

 - rust-lang#130648 (move enzyme flags from general cargo to rustc-specific cargo)
 - rust-lang#130650 (Fixup Apple target's description strings)
 - rust-lang#130664 (Generate line numbers for non-rust code examples as well)
 - rust-lang#130665 (Prevent Deduplication of `LongRunningWarn`)
 - rust-lang#130669 (tests: Test that `extern "C" fn` ptrs lint on slices)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Sep 22, 2024
2 parents 1f9a018 + f314db6 commit 80aa6fa
Show file tree
Hide file tree
Showing 30 changed files with 247 additions and 44 deletions.
9 changes: 8 additions & 1 deletion compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,14 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
// way to implement exponential backoff.
let span = ecx.cur_span();
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
// We store a unique number in `force_duplicate` to evade `-Z deduplicate-diagnostics`.
// `new_steps` is guaranteed to be unique because `ecx.machine.num_evaluated_steps` is
// always increasing.
ecx.tcx.dcx().emit_warn(LongRunningWarn {
span,
item_span: ecx.tcx.span,
force_duplicate: new_steps,
});
}
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_const_eval/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ pub struct LongRunningWarn {
pub span: Span,
#[help]
pub item_span: Span,
// Used for evading `-Z deduplicate-diagnostics`.
pub force_duplicate: usize,
}

#[derive(Subdiagnostic)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 macOS (11.0+, Big Sur+)".into()),
description: Some("ARM64 Apple macOS (11.0+, Big Sur+)".into()),
tier: Some(1),
host_tools: Some(true),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 iOS".into()),
description: Some("ARM64 Apple iOS".into()),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("Apple Catalyst on ARM64".into()),
description: Some("ARM64 Apple Mac Catalyst".into()),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("Apple iOS Simulator on ARM64".into()),
description: Some("ARM64 Apple iOS Simulator".into()),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 tvOS".into()),
description: Some("ARM64 Apple tvOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 tvOS Simulator".into()),
description: Some("ARM64 Apple tvOS Simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple WatchOS".into()),
description: Some("ARM64 Apple watchOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple WatchOS Simulator".into()),
description: Some("ARM64 Apple watchOS Simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("Arm Apple WatchOS 64-bit with 32-bit pointers".into()),
description: Some("ARM64 Apple watchOS with 32-bit pointers".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/armv7s_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("Armv7-A Apple-A6 Apple iOS".into()),
description: Some("ARMv7-A Apple-A6 Apple iOS".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/i386_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("32-bit x86 iOS".into()),
description: Some("x86 Apple iOS Simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("32-bit macOS (10.12+, Sierra+)".into()),
description: Some("x86 Apple macOS (10.12+, Sierra+)".into()),
tier: Some(3),
host_tools: Some(true),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("64-bit macOS (10.12+, Sierra+)".into()),
description: Some("x86_64 Apple macOS (10.12+, Sierra+)".into()),
tier: Some(1),
host_tools: Some(true),
std: Some(true),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("64-bit x86 iOS".into()),
description: Some("x86_64 Apple iOS Simulator".into()),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("Apple Catalyst on x86_64".into()),
description: Some("x86_64 Apple Mac Catalyst".into()),
tier: Some(2),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("x86 64-bit tvOS".into()),
description: Some("x86_64 Apple tvOS Simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("x86 64-bit Apple WatchOS simulator".into()),
description: Some("x86_64 Apple watchOS Simulator".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn target() -> Target {
Target {
llvm_target,
metadata: crate::spec::TargetMetadata {
description: Some("macOS with late-gen Intel (at least Haswell)".into()),
description: Some("x86_64 Apple macOS with Intel Haswell+".into()),
tier: Some(3),
host_tools: Some(true),
std: Some(true),
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");

if builder.config.llvm_enzyme {
cargo.rustflag("-l").rustflag("Enzyme-19");
}

// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
// and may just be a time sink.
if compiler.stage != 0 {
Expand Down
6 changes: 0 additions & 6 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,12 +1592,6 @@ impl<'a> Builder<'a> {
rustflags.arg(sysroot_str);
}

// https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20link.20new.20library.20into.20stage1.2Frustc
if self.config.llvm_enzyme {
rustflags.arg("-l");
rustflags.arg("Enzyme-19");
}

let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
Some(setting) => {
// If an explicit setting is given, use that
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
</pre>\
</div>",
added_classes = added_classes.join(" "),
text = Escape(&original_text),
text = Escape(
original_text.strip_suffix('\n').unwrap_or(&original_text)
),
)
.into(),
));
Expand Down
6 changes: 2 additions & 4 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() {
####.###..#....#....#..#.
#..#.#....#....#....#..#.
#..#.#....#....#....#..#.
#..#.####.####.####..##..
</code></pre></div>",
#..#.####.####.####..##..</code></pre></div>",
);
t(
r#"```markdown
# hello
```"#,
"<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\
# hello
</code></pre></div>",
# hello</code></pre></div>",
);
}
16 changes: 9 additions & 7 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,13 @@ function preLoadCss(cssUrl) {
}());

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

window.rustdoc_remove_line_numbers_from_examples = () => {
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
const parent = x.parentNode;
const line_numbers = parent.querySelectorAll(".example-line-numbers");
for (const node of line_numbers) {
parent.removeChild(node);
}
onEachLazy(document.querySelectorAll(".example-wrap > .example-line-numbers"), x => {
x.parentNode.removeChild(x);
});
};

Expand Down
67 changes: 60 additions & 7 deletions tests/rustdoc-gui/docblock-code-block-line-number.goml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"})

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

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

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

// Checking line numbers on scraped code examples.
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

define-function: (
"check-padding",
[path, padding_bottom],
Expand All @@ -157,19 +156,19 @@ define-function: (
"padding-bottom": "0px",
"padding-left": "0px",
"padding-right": "0px",
})
}, ALL)
assert-css: (|path| + " .src-line-numbers > pre", {
"padding-top": "14px",
"padding-bottom": |padding_bottom|,
"padding-left": "0px",
"padding-right": "0px",
})
}, ALL)
assert-css: (|path| + " .src-line-numbers > pre > span", {
"padding-top": "0px",
"padding-bottom": "0px",
"padding-left": "8px",
"padding-right": "8px",
})
}, ALL)
},
)

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

define-function: ("check-line-numbers-existence", [], block {
assert-local-storage: {"rustdoc-line-numbers": "true" }
assert-false: ".example-line-numbers"
click: "#settings-menu"
wait-for: "#settings"

// Then, click the toggle button.
click: "input#line-numbers"
wait-for: 100 // FIXME: `wait-for-false` does not exist
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
assert-false: ".example-line-numbers"
// Line numbers should still be there.
assert: ".src-line-numbers"
// Now disabling the setting.
click: "input#line-numbers"
wait-for: 100 // FIXME: `wait-for-false` does not exist
assert-local-storage: {"rustdoc-line-numbers": "true" }
assert-false: ".example-line-numbers"
// Line numbers should still be there.
assert: ".src-line-numbers"
// Closing settings menu.
click: "#settings-menu"
wait-for-css: ("#settings", {"display": "none"})
})

// Checking that turning off the line numbers setting won't remove line numbers from scraped
// examples.
call-function: ("check-line-numbers-existence", {})

// Now checking the line numbers in the source code page.
click: ".src"
assert-css: (".src-line-numbers", {
Expand All @@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", {
"padding-left": "8px",
"padding-right": "8px",
})
// Checking that turning off the line numbers setting won't remove line numbers.
call-function: ("check-line-numbers-existence", {})

// Now checking that even non-rust code blocks have line numbers generated.
go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
assert-local-storage: {"rustdoc-line-numbers": "true" }
assert: ".example-wrap > pre.language-txt"
assert: ".example-wrap > pre.rust"
assert-count: (".example-wrap", 2)
assert-count: (".example-wrap > pre.example-line-numbers", 2)

click: "#settings-menu"
wait-for: "#settings"

// Then, click the toggle button.
click: "input#line-numbers"
wait-for: 100 // FIXME: `wait-for-false` does not exist
assert-local-storage-false: {"rustdoc-line-numbers": "true" }
assert-count: (".example-wrap > pre.example-line-numbers", 0)

// Now turning off the setting.
click: "input#line-numbers"
wait-for: 100 // FIXME: `wait-for-false` does not exist
assert-local-storage: {"rustdoc-line-numbers": "true" }
assert-count: (".example-wrap > pre.example-line-numbers", 2)
Loading

0 comments on commit 80aa6fa

Please sign in to comment.