Skip to content

Commit 1158367

Browse files
committed
Auto merge of #87366 - GuillaumeGomez:rollup-7muueab, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - #87270 (Don't display <table> in item summary) - #87281 (Normalize generic_ty before checking if bound is met) - #87288 (rustdoc: Restore --default-theme, etc, by restoring varname escaping) - #87307 (Allow combining -Cprofile-generate and -Cpanic=unwind when targeting MSVC.) - #87343 (Regression fix to avoid further beta backports: Remove unsound TrustedRandomAccess implementations) - #87357 (Update my name/email in .mailmap) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents f913a4f + ab9ea54 commit 1158367

File tree

33 files changed

+144
-162
lines changed

33 files changed

+144
-162
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ Lennart Kudling <[email protected]>
175175
Léo Lanteri Thauvin <[email protected]>
176176
Léo Lanteri Thauvin <[email protected]> <[email protected]>
177177
Léo Testard <[email protected]>
178+
178179
179180
180181
Luke Metz <[email protected]>

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ members = [
4040
exclude = [
4141
"build",
4242
"compiler/rustc_codegen_cranelift",
43+
"src/test/rustdoc-gui",
4344
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
4445
"obj",
4546
# The `x` binary is a thin wrapper that calls `x.py`, which initializes

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
638638
let sub = var_data.normalize(self.tcx(), verify.region);
639639

640640
let verify_kind_ty = verify.kind.to_ty(self.tcx());
641+
let verify_kind_ty = var_data.normalize(self.tcx(), verify_kind_ty);
641642
if self.bound_is_met(&verify.bound, var_data, verify_kind_ty, sub) {
642643
continue;
643644
}

compiler/rustc_session/src/session.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::cgu_reuse_tracker::CguReuseTracker;
22
use crate::code_stats::CodeStats;
33
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
4-
use crate::config::{self, CrateType, OutputType, PrintRequest, SwitchWithOptPath};
4+
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
55
use crate::filesearch;
66
use crate::lint::{self, LintId};
77
use crate::parse::ParseSess;
@@ -1440,25 +1440,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
14401440
}
14411441
}
14421442

1443-
// PGO does not work reliably with panic=unwind on Windows. Let's make it
1444-
// an error to combine the two for now. It always runs into an assertions
1445-
// if LLVM is built with assertions, but without assertions it sometimes
1446-
// does not crash and will probably generate a corrupted binary.
1447-
// We should only display this error if we're actually going to run PGO.
1448-
// If we're just supposed to print out some data, don't show the error (#61002).
1449-
if sess.opts.cg.profile_generate.enabled()
1450-
&& sess.target.is_like_msvc
1451-
&& sess.panic_strategy() == PanicStrategy::Unwind
1452-
&& sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs)
1453-
{
1454-
sess.err(
1455-
"Profile-guided optimization does not yet work in conjunction \
1456-
with `-Cpanic=unwind` on Windows when targeting MSVC. \
1457-
See issue #61002 <https://github.com/rust-lang/rust/issues/61002> \
1458-
for more information.",
1459-
);
1460-
}
1461-
14621443
// Sanitizers can only be used on platforms that we know have working sanitizer codegen.
14631444
let supported_sanitizers = sess.target.options.supported_sanitizers;
14641445
let unsupported_sanitizers = sess.opts.debugging_opts.sanitizer - supported_sanitizers;

library/alloc/src/collections/vec_deque/into_iter.rs

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::fmt;
2-
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess};
2+
use core::iter::{FusedIterator, TrustedLen};
33

44
use super::VecDeque;
55

@@ -36,23 +36,6 @@ impl<T> Iterator for IntoIter<T> {
3636
let len = self.inner.len();
3737
(len, Some(len))
3838
}
39-
40-
#[inline]
41-
#[doc(hidden)]
42-
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
43-
where
44-
Self: TrustedRandomAccess,
45-
{
46-
// Safety: The TrustedRandomAccess contract requires that callers only pass an index
47-
// that is in bounds.
48-
// Additionally Self: TrustedRandomAccess is only implemented for T: Copy which means even
49-
// multiple repeated reads of the same index would be safe and the
50-
// values are !Drop, thus won't suffer from double drops.
51-
unsafe {
52-
let idx = self.inner.wrap_add(self.inner.tail, idx);
53-
self.inner.buffer_read(idx)
54-
}
55-
}
5639
}
5740

5841
#[stable(feature = "rust1", since = "1.0.0")]
@@ -75,14 +58,3 @@ impl<T> FusedIterator for IntoIter<T> {}
7558

7659
#[unstable(feature = "trusted_len", issue = "37572")]
7760
unsafe impl<T> TrustedLen for IntoIter<T> {}
78-
79-
#[doc(hidden)]
80-
#[unstable(feature = "trusted_random_access", issue = "none")]
81-
// T: Copy as approximation for !Drop since get_unchecked does not update the pointers
82-
// and thus we can't implement drop-handling
83-
unsafe impl<T> TrustedRandomAccess for IntoIter<T>
84-
where
85-
T: Copy,
86-
{
87-
const MAY_HAVE_SIDE_EFFECT: bool = false;
88-
}

library/core/src/array/iter.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::{
44
fmt,
5-
iter::{self, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess},
5+
iter::{self, ExactSizeIterator, FusedIterator, TrustedLen},
66
mem::{self, MaybeUninit},
77
ops::Range,
88
ptr,
@@ -130,19 +130,6 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
130130
fn last(mut self) -> Option<Self::Item> {
131131
self.next_back()
132132
}
133-
134-
#[inline]
135-
#[doc(hidden)]
136-
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
137-
where
138-
Self: TrustedRandomAccess,
139-
{
140-
// SAFETY: Callers are only allowed to pass an index that is in bounds
141-
// Additionally Self: TrustedRandomAccess is only implemented for T: Copy which means even
142-
// multiple repeated reads of the same index would be safe and the
143-
// values are !Drop, thus won't suffer from double drops.
144-
unsafe { self.data.get_unchecked(self.alive.start + idx).assume_init_read() }
145-
}
146133
}
147134

148135
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
@@ -197,17 +184,6 @@ impl<T, const N: usize> FusedIterator for IntoIter<T, N> {}
197184
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
198185
unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, N> {}
199186

200-
#[doc(hidden)]
201-
#[unstable(feature = "trusted_random_access", issue = "none")]
202-
// T: Copy as approximation for !Drop since get_unchecked does not update the pointers
203-
// and thus we can't implement drop-handling
204-
unsafe impl<T, const N: usize> TrustedRandomAccess for IntoIter<T, N>
205-
where
206-
T: Copy,
207-
{
208-
const MAY_HAVE_SIDE_EFFECT: bool = false;
209-
}
210-
211187
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
212188
impl<T: Clone, const N: usize> Clone for IntoIter<T, N> {
213189
fn clone(&self) -> Self {

src/bootstrap/test.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -907,18 +907,27 @@ impl Step for RustdocGUI {
907907
// We remove existing folder to be sure there won't be artifacts remaining.
908908
let _ = fs::remove_dir_all(&out_dir);
909909

910-
let src_path = "src/test/rustdoc-gui/src";
910+
let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
911911
// We generate docs for the libraries present in the rustdoc-gui's src folder.
912-
let mut cargo = Command::new(&builder.initial_cargo);
913-
cargo
914-
.arg("doc")
915-
.arg("--workspace")
916-
.arg("--target-dir")
917-
.arg(&out_dir)
918-
.env("RUSTDOC", builder.rustdoc(self.compiler))
919-
.env("RUSTC", builder.rustc(self.compiler))
920-
.current_dir(&builder.build.src.join(src_path));
921-
builder.run(&mut cargo);
912+
for entry in src_path.read_dir().expect("read_dir call failed") {
913+
if let Ok(entry) = entry {
914+
let path = entry.path();
915+
916+
if !path.is_dir() {
917+
continue;
918+
}
919+
920+
let mut cargo = Command::new(&builder.initial_cargo);
921+
cargo
922+
.arg("doc")
923+
.arg("--target-dir")
924+
.arg(&out_dir)
925+
.env("RUSTDOC", builder.rustdoc(self.compiler))
926+
.env("RUSTC", builder.rustc(self.compiler))
927+
.current_dir(path);
928+
builder.run(&mut cargo);
929+
}
930+
}
922931

923932
// We now run GUI tests.
924933
let mut command = Command::new(&nodejs);

src/librustdoc/config.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,31 @@ impl Options {
459459
})
460460
.collect(),
461461
];
462-
let default_settings = default_settings.into_iter().flatten().collect();
462+
let default_settings = default_settings
463+
.into_iter()
464+
.flatten()
465+
.map(
466+
// The keys here become part of `data-` attribute names in the generated HTML. The
467+
// browser does a strange mapping when converting them into attributes on the
468+
// `dataset` property on the DOM HTML Node:
469+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
470+
//
471+
// The original key values we have are the same as the DOM storage API keys and the
472+
// command line options, so contain `-`. Our Javascript needs to be able to look
473+
// these values up both in `dataset` and in the storage API, so it needs to be able
474+
// to convert the names back and forth. Despite doing this kebab-case to
475+
// StudlyCaps transformation automatically, the JS DOM API does not provide a
476+
// mechanism for doing the just transformation on a string. So we want to avoid
477+
// the StudlyCaps representation in the `dataset` property.
478+
//
479+
// We solve this by replacing all the `-`s with `_`s. We do that here, when we
480+
// generate the `data-` attributes, and in the JS, when we look them up. (See
481+
// `getSettingValue` in `storage.js.`) Converting `-` to `_` is simple in JS.
482+
//
483+
// The values will be HTML-escaped by the default Tera escaping.
484+
|(k, v)| (k.replace('-', "_"), v),
485+
)
486+
.collect();
463487

464488
let test_args = matches.opt_strs("test-args");
465489
let test_args: Vec<String> =

src/librustdoc/html/markdown.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) fn opts() -> Options {
5757

5858
/// A subset of [`opts()`] used for rendering summaries.
5959
pub(crate) fn summary_opts() -> Options {
60-
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_SMART_PUNCTUATION
60+
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_SMART_PUNCTUATION | Options::ENABLE_TABLES
6161
}
6262

6363
/// When `to_string` is called, this struct will emit the HTML corresponding to
@@ -522,6 +522,10 @@ fn check_if_allowed_tag(t: &Tag<'_>) -> bool {
522522
)
523523
}
524524

525+
fn is_forbidden_tag(t: &Tag<'_>) -> bool {
526+
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
527+
}
528+
525529
impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
526530
type Item = Event<'a>;
527531

@@ -535,14 +539,17 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
535539
if let Some(event) = self.inner.next() {
536540
let mut is_start = true;
537541
let is_allowed_tag = match event {
538-
Event::Start(Tag::CodeBlock(_)) | Event::End(Tag::CodeBlock(_)) => {
539-
return None;
540-
}
541542
Event::Start(ref c) => {
543+
if is_forbidden_tag(c) {
544+
return None;
545+
}
542546
self.depth += 1;
543547
check_if_allowed_tag(c)
544548
}
545549
Event::End(ref c) => {
550+
if is_forbidden_tag(c) {
551+
return None;
552+
}
546553
self.depth -= 1;
547554
is_start = false;
548555
check_if_allowed_tag(c)

src/librustdoc/html/static/js/storage.js

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ function getSettingValue(settingName) {
2222
return current;
2323
}
2424
if (settingsDataset !== null) {
25+
// See the comment for `default_settings.into_iter()` etc. in
26+
// `Options::from_matches` in `librustdoc/config.rs`.
2527
var def = settingsDataset[settingName.replace(/-/g,'_')];
2628
if (def !== undefined) {
2729
return def;

src/test/codegen/pgo-instrumentation.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Test that `-Cprofile-generate` creates expected instrumentation artifacts in LLVM IR.
2-
// Compiling with `-Cpanic=abort` because PGO+unwinding isn't supported on all platforms.
32

43
// needs-profiler-support
5-
// compile-flags: -Cprofile-generate -Ccodegen-units=1 -Cpanic=abort
4+
// compile-flags: -Cprofile-generate -Ccodegen-units=1
65

76
// CHECK: @__llvm_profile_raw_version =
87
// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global

src/test/run-make-fulldeps/pgo-branch-weights/Makefile

-13
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@
66

77
-include ../tools.mk
88

9-
# This test makes sure that instrumented binaries record the right counts for
10-
# functions being called and branches being taken. We run an instrumented binary
11-
# with an argument that causes a know path through the program and then check
12-
# that the expected counts get added to the use-phase LLVM IR.
13-
14-
# LLVM doesn't support instrumenting binaries that use SEH:
15-
# https://github.com/rust-lang/rust/issues/61002
16-
#
17-
# Things work fine with -Cpanic=abort though.
18-
ifdef IS_MSVC
19-
COMMON_FLAGS=-Cpanic=abort
20-
endif
21-
229
# For some very small programs GNU ld seems to not properly handle
2310
# instrumentation sections correctly. Neither Gold nor LLD have that problem.
2411
ifeq ($(UNAME),Linux)

src/test/run-make-fulldeps/pgo-gen-lto/Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88

99
COMPILE_FLAGS=-Copt-level=3 -Clto=fat -Cprofile-generate="$(TMPDIR)"
1010

11-
# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
12-
# https://github.com/rust-lang/rust/issues/61002
13-
#
14-
# Things work fine with -Cpanic=abort though.
15-
ifdef IS_MSVC
16-
COMPILE_FLAGS+= -Cpanic=abort
17-
endif
18-
1911
all:
2012
$(RUSTC) $(COMPILE_FLAGS) test.rs
2113
$(call RUN,test) || exit 1

src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44

55
COMPILE_FLAGS=-O -Ccodegen-units=1 -Cprofile-generate="$(TMPDIR)"
66

7-
# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
8-
# https://github.com/rust-lang/rust/issues/61002
9-
#
10-
# Things work fine with -Cpanic=abort though.
11-
ifdef IS_MSVC
12-
COMPILE_FLAGS+= -Cpanic=abort
13-
endif
14-
157
all:
168
$(RUSTC) $(COMPILE_FLAGS) --emit=llvm-ir test.rs
179
# We expect symbols starting with "__llvm_profile_".

src/test/run-make-fulldeps/pgo-gen/Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88

99
COMPILE_FLAGS=-g -Cprofile-generate="$(TMPDIR)"
1010

11-
# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
12-
# https://github.com/rust-lang/rust/issues/61002
13-
#
14-
# Things work fine with -Cpanic=abort though.
15-
ifdef IS_MSVC
16-
COMPILE_FLAGS+= -Cpanic=abort
17-
endif
18-
1911
all:
2012
$(RUSTC) $(COMPILE_FLAGS) test.rs
2113
$(call RUN,test) || exit 1

src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile

-14
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@
66

77
-include ../tools.mk
88

9-
# This test makes sure that indirect call promotion is performed. The test
10-
# programs calls the same function a thousand times through a function pointer.
11-
# Only PGO data provides the information that it actually always is the same
12-
# function. We verify that the indirect call promotion pass inserts a check
13-
# whether it can make a direct call instead of the indirect call.
14-
15-
# LLVM doesn't support instrumenting binaries that use SEH:
16-
# https://github.com/rust-lang/rust/issues/61002
17-
#
18-
# Things work fine with -Cpanic=abort though.
19-
ifdef IS_MSVC
20-
COMMON_FLAGS=-Cpanic=abort
21-
endif
22-
239
all:
2410
# We don't compile `opaque` with either optimizations or instrumentation.
2511
# We don't compile `opaque` with either optimizations or instrumentation.

src/test/run-make-fulldeps/pgo-use/Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818

1919
COMMON_FLAGS=-Copt-level=2 -Ccodegen-units=1 -Cllvm-args=-disable-preinline
2020

21-
# LLVM doesn't support instrumenting binaries that use SEH:
22-
# https://github.com/rust-lang/rust/issues/61002
23-
#
24-
# Things work fine with -Cpanic=abort though.
25-
ifdef IS_MSVC
26-
COMMON_FLAGS+= -Cpanic=abort
27-
endif
28-
2921
ifeq ($(UNAME),Darwin)
3022
# macOS does not have the `tac` command, but `tail -r` does the same thing
3123
TAC := tail -r
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This test ensures that the default settings are correctly applied.
2+
//
3+
// The "settings" crate uses "ayu" as default setting, which is what we will
4+
// check.
5+
goto: file://|DOC_PATH|/settings/index.html
6+
// Wait a bit to be sure the default theme is applied.
7+
wait-for: 1000
8+
assert-css: ("body", {"background-color": "rgb(15, 20, 25)"})

0 commit comments

Comments
 (0)