Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #87366

Merged
merged 17 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Lennart Kudling <[email protected]>
Léo Lanteri Thauvin <[email protected]>
Léo Lanteri Thauvin <[email protected]> <[email protected]>
Léo Testard <[email protected]>
Lily Ballard <[email protected]> <[email protected]>
Lindsey Kuper <[email protected]> <[email protected]>
Lindsey Kuper <[email protected]> <[email protected]>
Luke Metz <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ members = [
exclude = [
"build",
"compiler/rustc_codegen_cranelift",
"src/test/rustdoc-gui",
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
"obj",
# The `x` binary is a thin wrapper that calls `x.py`, which initializes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
let sub = var_data.normalize(self.tcx(), verify.region);

let verify_kind_ty = verify.kind.to_ty(self.tcx());
let verify_kind_ty = var_data.normalize(self.tcx(), verify_kind_ty);
if self.bound_is_met(&verify.bound, var_data, verify_kind_ty, sub) {
continue;
}
Expand Down
21 changes: 1 addition & 20 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::cgu_reuse_tracker::CguReuseTracker;
use crate::code_stats::CodeStats;
pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo};
use crate::config::{self, CrateType, OutputType, PrintRequest, SwitchWithOptPath};
use crate::config::{self, CrateType, OutputType, SwitchWithOptPath};
use crate::filesearch;
use crate::lint::{self, LintId};
use crate::parse::ParseSess;
Expand Down Expand Up @@ -1440,25 +1440,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
}
}

// PGO does not work reliably with panic=unwind on Windows. Let's make it
// an error to combine the two for now. It always runs into an assertions
// if LLVM is built with assertions, but without assertions it sometimes
// does not crash and will probably generate a corrupted binary.
// We should only display this error if we're actually going to run PGO.
// If we're just supposed to print out some data, don't show the error (#61002).
if sess.opts.cg.profile_generate.enabled()
&& sess.target.is_like_msvc
&& sess.panic_strategy() == PanicStrategy::Unwind
&& sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs)
{
sess.err(
"Profile-guided optimization does not yet work in conjunction \
with `-Cpanic=unwind` on Windows when targeting MSVC. \
See issue #61002 <https://github.com/rust-lang/rust/issues/61002> \
for more information.",
);
}

// Sanitizers can only be used on platforms that we know have working sanitizer codegen.
let supported_sanitizers = sess.target.options.supported_sanitizers;
let unsupported_sanitizers = sess.opts.debugging_opts.sanitizer - supported_sanitizers;
Expand Down
30 changes: 1 addition & 29 deletions library/alloc/src/collections/vec_deque/into_iter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::fmt;
use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess};
use core::iter::{FusedIterator, TrustedLen};

use super::VecDeque;

Expand Down Expand Up @@ -36,23 +36,6 @@ impl<T> Iterator for IntoIter<T> {
let len = self.inner.len();
(len, Some(len))
}

#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,
{
// Safety: The TrustedRandomAccess contract requires that callers only pass an index
// that is in bounds.
// Additionally Self: TrustedRandomAccess is only implemented for T: Copy which means even
// multiple repeated reads of the same index would be safe and the
// values are !Drop, thus won't suffer from double drops.
unsafe {
let idx = self.inner.wrap_add(self.inner.tail, idx);
self.inner.buffer_read(idx)
}
}
}

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

#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<T> TrustedLen for IntoIter<T> {}

#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
// T: Copy as approximation for !Drop since get_unchecked does not update the pointers
// and thus we can't implement drop-handling
unsafe impl<T> TrustedRandomAccess for IntoIter<T>
where
T: Copy,
{
const MAY_HAVE_SIDE_EFFECT: bool = false;
}
26 changes: 1 addition & 25 deletions library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
fmt,
iter::{self, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess},
iter::{self, ExactSizeIterator, FusedIterator, TrustedLen},
mem::{self, MaybeUninit},
ops::Range,
ptr,
Expand Down Expand Up @@ -130,19 +130,6 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
fn last(mut self) -> Option<Self::Item> {
self.next_back()
}

#[inline]
#[doc(hidden)]
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item
where
Self: TrustedRandomAccess,
{
// SAFETY: Callers are only allowed to pass an index that is in bounds
// Additionally Self: TrustedRandomAccess is only implemented for T: Copy which means even
// multiple repeated reads of the same index would be safe and the
// values are !Drop, thus won't suffer from double drops.
unsafe { self.data.get_unchecked(self.alive.start + idx).assume_init_read() }
}
}

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

#[doc(hidden)]
#[unstable(feature = "trusted_random_access", issue = "none")]
// T: Copy as approximation for !Drop since get_unchecked does not update the pointers
// and thus we can't implement drop-handling
unsafe impl<T, const N: usize> TrustedRandomAccess for IntoIter<T, N>
where
T: Copy,
{
const MAY_HAVE_SIDE_EFFECT: bool = false;
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T: Clone, const N: usize> Clone for IntoIter<T, N> {
fn clone(&self) -> Self {
Expand Down
31 changes: 20 additions & 11 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,18 +907,27 @@ impl Step for RustdocGUI {
// We remove existing folder to be sure there won't be artifacts remaining.
let _ = fs::remove_dir_all(&out_dir);

let src_path = "src/test/rustdoc-gui/src";
let src_path = builder.build.src.join("src/test/rustdoc-gui/src");
// We generate docs for the libraries present in the rustdoc-gui's src folder.
let mut cargo = Command::new(&builder.initial_cargo);
cargo
.arg("doc")
.arg("--workspace")
.arg("--target-dir")
.arg(&out_dir)
.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler))
.current_dir(&builder.build.src.join(src_path));
builder.run(&mut cargo);
for entry in src_path.read_dir().expect("read_dir call failed") {
if let Ok(entry) = entry {
let path = entry.path();

if !path.is_dir() {
continue;
}

let mut cargo = Command::new(&builder.initial_cargo);
cargo
.arg("doc")
.arg("--target-dir")
.arg(&out_dir)
.env("RUSTDOC", builder.rustdoc(self.compiler))
.env("RUSTC", builder.rustc(self.compiler))
.current_dir(path);
builder.run(&mut cargo);
}
}

// We now run GUI tests.
let mut command = Command::new(&nodejs);
Expand Down
26 changes: 25 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,31 @@ impl Options {
})
.collect(),
];
let default_settings = default_settings.into_iter().flatten().collect();
let default_settings = default_settings
.into_iter()
.flatten()
.map(
// The keys here become part of `data-` attribute names in the generated HTML. The
// browser does a strange mapping when converting them into attributes on the
// `dataset` property on the DOM HTML Node:
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
//
// The original key values we have are the same as the DOM storage API keys and the
// command line options, so contain `-`. Our Javascript needs to be able to look
// these values up both in `dataset` and in the storage API, so it needs to be able
// to convert the names back and forth. Despite doing this kebab-case to
// StudlyCaps transformation automatically, the JS DOM API does not provide a
// mechanism for doing the just transformation on a string. So we want to avoid
// the StudlyCaps representation in the `dataset` property.
//
// We solve this by replacing all the `-`s with `_`s. We do that here, when we
// generate the `data-` attributes, and in the JS, when we look them up. (See
// `getSettingValue` in `storage.js.`) Converting `-` to `_` is simple in JS.
//
// The values will be HTML-escaped by the default Tera escaping.
|(k, v)| (k.replace('-', "_"), v),
)
.collect();

let test_args = matches.opt_strs("test-args");
let test_args: Vec<String> =
Expand Down
15 changes: 11 additions & 4 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub(crate) fn opts() -> Options {

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

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

fn is_forbidden_tag(t: &Tag<'_>) -> bool {
matches!(t, Tag::CodeBlock(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell)
}

impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
type Item = Event<'a>;

Expand All @@ -535,14 +539,17 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
if let Some(event) = self.inner.next() {
let mut is_start = true;
let is_allowed_tag = match event {
Event::Start(Tag::CodeBlock(_)) | Event::End(Tag::CodeBlock(_)) => {
return None;
}
Event::Start(ref c) => {
if is_forbidden_tag(c) {
return None;
}
self.depth += 1;
check_if_allowed_tag(c)
}
Event::End(ref c) => {
if is_forbidden_tag(c) {
return None;
}
self.depth -= 1;
is_start = false;
check_if_allowed_tag(c)
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function getSettingValue(settingName) {
return current;
}
if (settingsDataset !== null) {
// See the comment for `default_settings.into_iter()` etc. in
// `Options::from_matches` in `librustdoc/config.rs`.
var def = settingsDataset[settingName.replace(/-/g,'_')];
if (def !== undefined) {
return def;
Expand Down
3 changes: 1 addition & 2 deletions src/test/codegen/pgo-instrumentation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Test that `-Cprofile-generate` creates expected instrumentation artifacts in LLVM IR.
// Compiling with `-Cpanic=abort` because PGO+unwinding isn't supported on all platforms.

// needs-profiler-support
// compile-flags: -Cprofile-generate -Ccodegen-units=1 -Cpanic=abort
// compile-flags: -Cprofile-generate -Ccodegen-units=1

// CHECK: @__llvm_profile_raw_version =
// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global
Expand Down
13 changes: 0 additions & 13 deletions src/test/run-make-fulldeps/pgo-branch-weights/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@

-include ../tools.mk

# This test makes sure that instrumented binaries record the right counts for
# functions being called and branches being taken. We run an instrumented binary
# with an argument that causes a know path through the program and then check
# that the expected counts get added to the use-phase LLVM IR.

# LLVM doesn't support instrumenting binaries that use SEH:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMMON_FLAGS=-Cpanic=abort
endif

# For some very small programs GNU ld seems to not properly handle
# instrumentation sections correctly. Neither Gold nor LLD have that problem.
ifeq ($(UNAME),Linux)
Expand Down
8 changes: 0 additions & 8 deletions src/test/run-make-fulldeps/pgo-gen-lto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@

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

# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMPILE_FLAGS+= -Cpanic=abort
endif

all:
$(RUSTC) $(COMPILE_FLAGS) test.rs
$(call RUN,test) || exit 1
Expand Down
8 changes: 0 additions & 8 deletions src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

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

# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMPILE_FLAGS+= -Cpanic=abort
endif

all:
$(RUSTC) $(COMPILE_FLAGS) --emit=llvm-ir test.rs
# We expect symbols starting with "__llvm_profile_".
Expand Down
8 changes: 0 additions & 8 deletions src/test/run-make-fulldeps/pgo-gen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@

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

# LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMPILE_FLAGS+= -Cpanic=abort
endif

all:
$(RUSTC) $(COMPILE_FLAGS) test.rs
$(call RUN,test) || exit 1
Expand Down
14 changes: 0 additions & 14 deletions src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@

-include ../tools.mk

# This test makes sure that indirect call promotion is performed. The test
# programs calls the same function a thousand times through a function pointer.
# Only PGO data provides the information that it actually always is the same
# function. We verify that the indirect call promotion pass inserts a check
# whether it can make a direct call instead of the indirect call.

# LLVM doesn't support instrumenting binaries that use SEH:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMMON_FLAGS=-Cpanic=abort
endif

all:
# We don't compile `opaque` with either optimizations or instrumentation.
# We don't compile `opaque` with either optimizations or instrumentation.
Expand Down
8 changes: 0 additions & 8 deletions src/test/run-make-fulldeps/pgo-use/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

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

# LLVM doesn't support instrumenting binaries that use SEH:
# https://github.com/rust-lang/rust/issues/61002
#
# Things work fine with -Cpanic=abort though.
ifdef IS_MSVC
COMMON_FLAGS+= -Cpanic=abort
endif

ifeq ($(UNAME),Darwin)
# macOS does not have the `tac` command, but `tail -r` does the same thing
TAC := tail -r
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc-gui/default-settings.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This test ensures that the default settings are correctly applied.
//
// The "settings" crate uses "ayu" as default setting, which is what we will
// check.
goto: file://|DOC_PATH|/settings/index.html
// Wait a bit to be sure the default theme is applied.
wait-for: 1000
assert-css: ("body", {"background-color": "rgb(15, 20, 25)"})
Loading