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
This commit is contained in:
bors 2024-09-22 07:48:56 +00:00
commit 80aa6fa731
30 changed files with 247 additions and 44 deletions

View File

@ -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 // current number of evaluated terminators is a power of 2. The latter gives us a cheap
// way to implement exponential backoff. // way to implement exponential backoff.
let span = ecx.cur_span(); 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,
});
} }
} }

View File

@ -209,6 +209,8 @@ pub struct LongRunningWarn {
pub span: Span, pub span: Span,
#[help] #[help]
pub item_span: Span, pub item_span: Span,
// Used for evading `-Z deduplicate-diagnostics`.
pub force_duplicate: usize,
} }
#[derive(Subdiagnostic)] #[derive(Subdiagnostic)]

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(1),
host_tools: Some(true), host_tools: Some(true),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 iOS".into()), description: Some("ARM64 Apple iOS".into()),
tier: Some(2), tier: Some(2),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("Apple Catalyst on ARM64".into()), description: Some("ARM64 Apple Mac Catalyst".into()),
tier: Some(2), tier: Some(2),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("Apple iOS Simulator on ARM64".into()), description: Some("ARM64 Apple iOS Simulator".into()),
tier: Some(2), tier: Some(2),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 tvOS".into()), description: Some("ARM64 Apple tvOS".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 tvOS Simulator".into()), description: Some("ARM64 Apple tvOS Simulator".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple WatchOS".into()), description: Some("ARM64 Apple watchOS".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Apple WatchOS Simulator".into()), description: Some("ARM64 Apple watchOS Simulator".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("32-bit x86 iOS".into()), description: Some("x86 Apple iOS Simulator".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(3),
host_tools: Some(true), host_tools: Some(true),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(1),
host_tools: Some(true), host_tools: Some(true),
std: Some(true), std: Some(true),

View File

@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("64-bit x86 iOS".into()), description: Some("x86_64 Apple iOS Simulator".into()),
tier: Some(2), tier: Some(2),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("Apple Catalyst on x86_64".into()), description: Some("x86_64 Apple Mac Catalyst".into()),
tier: Some(2), tier: Some(2),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("x86 64-bit tvOS".into()), description: Some("x86_64 Apple tvOS Simulator".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -6,7 +6,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("x86 64-bit Apple WatchOS simulator".into()), description: Some("x86_64 Apple watchOS Simulator".into()),
tier: Some(3), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(true), std: Some(true),

View File

@ -29,7 +29,7 @@ pub(crate) fn target() -> Target {
Target { Target {
llvm_target, llvm_target,
metadata: crate::spec::TargetMetadata { 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), tier: Some(3),
host_tools: Some(true), host_tools: Some(true),
std: Some(true), std: Some(true),

View File

@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
// killed, rather than having an error bubble up and cause a panic. // killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill"); 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 // We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
// and may just be a time sink. // and may just be a time sink.
if compiler.stage != 0 { if compiler.stage != 0 {

View File

@ -1592,12 +1592,6 @@ impl<'a> Builder<'a> {
rustflags.arg(sysroot_str); 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 { let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
Some(setting) => { Some(setting) => {
// If an explicit setting is given, use that // If an explicit setting is given, use that

View File

@ -261,7 +261,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
</pre>\ </pre>\
</div>", </div>",
added_classes = added_classes.join(" "), added_classes = added_classes.join(" "),
text = Escape(&original_text), text = Escape(
original_text.strip_suffix('\n').unwrap_or(&original_text)
),
) )
.into(), .into(),
)); ));

View File

@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() {
####.###..#....#....#..#. ####.###..#....#....#..#.
#..#.#....#....#....#..#. #..#.#....#....#....#..#.
#..#.#....#....#....#..#. #..#.#....#....#....#..#.
#..#.####.####.####..##.. #..#.####.####.####..##..</code></pre></div>",
</code></pre></div>",
); );
t( t(
r#"```markdown r#"```markdown
# hello # hello
```"#, ```"#,
"<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\ "<div class=\"example-wrap\"><pre class=\"language-markdown\"><code>\
# hello # hello</code></pre></div>",
</code></pre></div>",
); );
} }

View File

@ -986,7 +986,13 @@ function preLoadCss(cssUrl) {
}()); }());
window.rustdoc_add_line_numbers_to_examples = () => { 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 parent = x.parentNode;
const line_numbers = parent.querySelectorAll(".example-line-numbers"); const line_numbers = parent.querySelectorAll(".example-line-numbers");
if (line_numbers.length > 0) { if (line_numbers.length > 0) {
@ -1005,12 +1011,8 @@ function preLoadCss(cssUrl) {
}; };
window.rustdoc_remove_line_numbers_from_examples = () => { window.rustdoc_remove_line_numbers_from_examples = () => {
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => { onEachLazy(document.querySelectorAll(".example-wrap > .example-line-numbers"), x => {
const parent = x.parentNode; x.parentNode.removeChild(x);
const line_numbers = parent.querySelectorAll(".example-line-numbers");
for (const node of line_numbers) {
parent.removeChild(node);
}
}); });
}; };

View File

@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"})
// Then, click the toggle button. // Then, click the toggle button.
click: "input#line-numbers" 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-false: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "false" } assert-local-storage: {"rustdoc-line-numbers": "false" }
@ -107,6 +107,8 @@ assert-css: (
click: "input#line-numbers" click: "input#line-numbers"
wait-for: "pre.example-line-numbers" wait-for: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "true" } 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. // Same check with scraped examples line numbers.
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html" go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
@ -145,9 +147,6 @@ assert-css: (
ALL, ALL,
) )
// Checking line numbers on scraped code examples.
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
define-function: ( define-function: (
"check-padding", "check-padding",
[path, padding_bottom], [path, padding_bottom],
@ -157,19 +156,19 @@ define-function: (
"padding-bottom": "0px", "padding-bottom": "0px",
"padding-left": "0px", "padding-left": "0px",
"padding-right": "0px", "padding-right": "0px",
}) }, ALL)
assert-css: (|path| + " .src-line-numbers > pre", { assert-css: (|path| + " .src-line-numbers > pre", {
"padding-top": "14px", "padding-top": "14px",
"padding-bottom": |padding_bottom|, "padding-bottom": |padding_bottom|,
"padding-left": "0px", "padding-left": "0px",
"padding-right": "0px", "padding-right": "0px",
}) }, ALL)
assert-css: (|path| + " .src-line-numbers > pre > span", { assert-css: (|path| + " .src-line-numbers > pre > span", {
"padding-top": "0px", "padding-top": "0px",
"padding-bottom": "0px", "padding-bottom": "0px",
"padding-left": "8px", "padding-left": "8px",
"padding-right": "8px", "padding-right": "8px",
}) }, ALL)
}, },
) )
@ -188,6 +187,35 @@ call-function: ("check-padding", {
"padding_bottom": "14px", "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. // Now checking the line numbers in the source code page.
click: ".src" click: ".src"
assert-css: (".src-line-numbers", { assert-css: (".src-line-numbers", {
@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", {
"padding-left": "8px", "padding-left": "8px",
"padding-right": "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)

View File

@ -0,0 +1,24 @@
//@ check-pass
#![allow(long_running_const_eval)]
//@ compile-flags: -Z tiny-const-eval-limit -Z deduplicate-diagnostics=yes
const FOO: () = {
let mut i = 0;
loop {
//~^ WARN is taking a long time
//~| WARN is taking a long time
//~| WARN is taking a long time
//~| WARN is taking a long time
//~| WARN is taking a long time
if i == 1000 {
break;
} else {
i += 1;
}
}
};
fn main() {
FOO
}

View File

@ -0,0 +1,92 @@
warning: constant evaluation is taking a long time
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
LL | / loop {
LL | |
LL | |
LL | |
... |
LL | | }
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
LL | const FOO: () = {
| ^^^^^^^^^^^^^
warning: constant evaluation is taking a long time
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
LL | / loop {
LL | |
LL | |
LL | |
... |
LL | | }
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
LL | const FOO: () = {
| ^^^^^^^^^^^^^
warning: constant evaluation is taking a long time
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
LL | / loop {
LL | |
LL | |
LL | |
... |
LL | | }
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
LL | const FOO: () = {
| ^^^^^^^^^^^^^
warning: constant evaluation is taking a long time
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
LL | / loop {
LL | |
LL | |
LL | |
... |
LL | | }
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
LL | const FOO: () = {
| ^^^^^^^^^^^^^
warning: constant evaluation is taking a long time
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
LL | / loop {
LL | |
LL | |
LL | |
... |
LL | | }
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
LL | const FOO: () = {
| ^^^^^^^^^^^^^
warning: 5 warnings emitted

View File

@ -0,0 +1,9 @@
#[deny(improper_ctypes_definitions)]
// It's an improper ctype (a slice) arg in an extern "C" fnptr.
pub type F = extern "C" fn(&[u8]);
//~^ ERROR: `extern` fn uses type `[u8]`, which is not FFI-safe
fn main() {}

View File

@ -0,0 +1,16 @@
error: `extern` fn uses type `[u8]`, which is not FFI-safe
--> $DIR/extern-C-fnptr-lints-slices.rs:5:14
|
LL | pub type F = extern "C" fn(&[u8]);
| ^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider using a raw pointer instead
= note: slices have no C equivalent
note: the lint level is defined here
--> $DIR/extern-C-fnptr-lints-slices.rs:1:8
|
LL | #[deny(improper_ctypes_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error