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 @@ fn increment_const_eval_counter(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<
// 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,
});
}
}

View File

@ -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)]

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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),

View File

@ -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 {

View File

@ -1592,12 +1592,6 @@ fn cargo(
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

View File

@ -261,7 +261,9 @@ fn next(&mut self) -> Option<Self::Item> {
</pre>\
</div>",
added_classes = added_classes.join(" "),
text = Escape(&original_text),
text = Escape(
original_text.strip_suffix('\n').unwrap_or(&original_text)
),
)
.into(),
));

View File

@ -524,15 +524,13 @@ fn t(input: &str, expect: &str) {
####.###..#....#....#..#.
#..#.#....#....#....#..#.
#..#.#....#....#....#..#.
#..#.####.####.####..##..
</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>",
);
}

View File

@ -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) {
@ -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);
});
};

View File

@ -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" }
@ -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"
@ -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],
@ -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)
},
)
@ -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", {
@ -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)

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