From 3d464947d421744017b9709215f14911ea25947e Mon Sep 17 00:00:00 2001 From: jackh726 Date: Mon, 19 Jul 2021 10:25:20 -0400 Subject: [PATCH 01/11] Normalize generic_ty before checking if bound is met --- .../src/infer/lexical_region_resolve/mod.rs | 1 + .../generic-associated-types/issue-81487.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/ui/generic-associated-types/issue-81487.rs diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index ab34cda8cc18f..869fd225d5114 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -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; } diff --git a/src/test/ui/generic-associated-types/issue-81487.rs b/src/test/ui/generic-associated-types/issue-81487.rs new file mode 100644 index 0000000000000..7f399c4f9a2db --- /dev/null +++ b/src/test/ui/generic-associated-types/issue-81487.rs @@ -0,0 +1,19 @@ +// build-pass + +#![feature(generic_associated_types)] + +trait Trait { + type Ref<'a>; +} + +impl Trait for () { + type Ref<'a> = &'a i8; +} + +struct RefRef<'a, T: Trait>(&'a ::Ref<'a>); + +fn wrap<'a, T: Trait>(reff: &'a ::Ref<'a>) -> RefRef<'a, T> { + RefRef(reff) +} + +fn main() {} From d56c02d7e9d2ad9b563ad3695c65b976f1099ec7 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 19 Jul 2021 17:14:58 +0200 Subject: [PATCH 02/11] Allow combining -Cprofile-generate and -Cpanic=unwind when targeting MSVC. The LLVM limitation that previously prevented this has been fixed in LLVM 9 which is older than the oldest LLVM version we currently support. See https://github.com/rust-lang/rust/issues/61002. --- compiler/rustc_session/src/session.rs | 21 +------------------ src/test/codegen/pgo-instrumentation.rs | 3 +-- .../pgo-branch-weights/Makefile | 13 ------------ .../run-make-fulldeps/pgo-gen-lto/Makefile | 8 ------- .../pgo-gen-no-imp-symbols/Makefile | 8 ------- src/test/run-make-fulldeps/pgo-gen/Makefile | 8 ------- .../pgo-indirect-call-promotion/Makefile | 14 ------------- src/test/run-make-fulldeps/pgo-use/Makefile | 8 ------- 8 files changed, 2 insertions(+), 81 deletions(-) diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index f3ce78d2d78f8..86d495c3353b3 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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; @@ -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 \ - 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; diff --git a/src/test/codegen/pgo-instrumentation.rs b/src/test/codegen/pgo-instrumentation.rs index c085f3c829ea4..05c2d2fc0d8c1 100644 --- a/src/test/codegen/pgo-instrumentation.rs +++ b/src/test/codegen/pgo-instrumentation.rs @@ -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 diff --git a/src/test/run-make-fulldeps/pgo-branch-weights/Makefile b/src/test/run-make-fulldeps/pgo-branch-weights/Makefile index 18828b66ce874..9773e3f1fdfc4 100644 --- a/src/test/run-make-fulldeps/pgo-branch-weights/Makefile +++ b/src/test/run-make-fulldeps/pgo-branch-weights/Makefile @@ -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) diff --git a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile index f1ac39aa0ea8a..a7d5c56163257 100644 --- a/src/test/run-make-fulldeps/pgo-gen-lto/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-lto/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile index 3fbfeb09eb373..425bfc28a9766 100644 --- a/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile @@ -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_". diff --git a/src/test/run-make-fulldeps/pgo-gen/Makefile b/src/test/run-make-fulldeps/pgo-gen/Makefile index 69b19801bf091..6533355be3418 100644 --- a/src/test/run-make-fulldeps/pgo-gen/Makefile +++ b/src/test/run-make-fulldeps/pgo-gen/Makefile @@ -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 diff --git a/src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile b/src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile index 876a9b2c43991..c0195dcbb31be 100644 --- a/src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile +++ b/src/test/run-make-fulldeps/pgo-indirect-call-promotion/Makefile @@ -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. diff --git a/src/test/run-make-fulldeps/pgo-use/Makefile b/src/test/run-make-fulldeps/pgo-use/Makefile index 01bc211df1616..d7863c9c587a5 100644 --- a/src/test/run-make-fulldeps/pgo-use/Makefile +++ b/src/test/run-make-fulldeps/pgo-use/Makefile @@ -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 From 1b66a799c7ef707d2cd4b325b654e69bf536c30f Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Tue, 1 Jun 2021 02:21:26 +0200 Subject: [PATCH 03/11] Remove unsound TrustedRandomAccess implementations Removes the implementations that depend on the user-definable trait `Copy`. Only fix regressions to ensure merge in 1.55: Does not modify `vec::IntoIter`. --- .../src/collections/vec_deque/into_iter.rs | 30 +------------------ library/core/src/array/iter.rs | 26 +--------------- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/into_iter.rs b/library/alloc/src/collections/vec_deque/into_iter.rs index 46a769a722a8b..612f7e6eb4da8 100644 --- a/library/alloc/src/collections/vec_deque/into_iter.rs +++ b/library/alloc/src/collections/vec_deque/into_iter.rs @@ -1,5 +1,5 @@ use core::fmt; -use core::iter::{FusedIterator, TrustedLen, TrustedRandomAccess}; +use core::iter::{FusedIterator, TrustedLen}; use super::VecDeque; @@ -36,23 +36,6 @@ impl Iterator for IntoIter { 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")] @@ -75,14 +58,3 @@ impl FusedIterator for IntoIter {} #[unstable(feature = "trusted_len", issue = "37572")] unsafe impl TrustedLen for IntoIter {} - -#[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 TrustedRandomAccess for IntoIter -where - T: Copy, -{ - const MAY_HAVE_SIDE_EFFECT: bool = false; -} diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs index 931ea77eca4dc..61ab1b1faff89 100644 --- a/library/core/src/array/iter.rs +++ b/library/core/src/array/iter.rs @@ -2,7 +2,7 @@ use crate::{ fmt, - iter::{self, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess}, + iter::{self, ExactSizeIterator, FusedIterator, TrustedLen}, mem::{self, MaybeUninit}, ops::Range, ptr, @@ -130,19 +130,6 @@ impl Iterator for IntoIter { fn last(mut self) -> Option { 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")] @@ -197,17 +184,6 @@ impl FusedIterator for IntoIter {} #[stable(feature = "array_value_iter_impls", since = "1.40.0")] unsafe impl TrustedLen for IntoIter {} -#[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 TrustedRandomAccess for IntoIter -where - T: Copy, -{ - const MAY_HAVE_SIDE_EFFECT: bool = false; -} - #[stable(feature = "array_value_iter_impls", since = "1.40.0")] impl Clone for IntoIter { fn clone(&self) -> Self { From 155b055478eead93f70aa51994e2c56da948cc40 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 19 Jul 2021 17:13:22 +0100 Subject: [PATCH 04/11] rustdoc: Restore --default-theme, etc, by restoring varname escaping In #86157 cd0f93193c84ddc6698f9b65909da71c084dcb74 Use Tera templates for rustdoc. dropped the following transformation from the keys of the default settings element's `data-` attribute names: .map(|(k, v)| format!(r#" data-{}="{}""#, k.replace('-', "_"), Escape(v))) The `Escape` part is indeed no longer needed, because Tera does that for us. But the massaging of `-` to `_` is needed, for the (bizarre) reasons explained in the new comments. I have tested that the default theme function works again for me. I have also verified that passing --default-theme="zork&" escapes the value in the HTML. Closes #87263. CC: Jacob Hoffman-Andrews Signed-off-by: Ian Jackson --- src/librustdoc/config.rs | 24 +++++++++++++++++++++++- src/librustdoc/html/static/js/storage.js | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index e552542464082..cae68447815a5 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -459,7 +459,29 @@ 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 = diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 2eaa81a97d8c5..78ed17e6899e9 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -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; From 1bf8a839d32dfbc03c383319e463f3e1ab877646 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 20 Jul 2021 16:12:11 +0100 Subject: [PATCH 05/11] Run rustfmt Signed-off-by: Ian Jackson --- src/librustdoc/config.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index cae68447815a5..abd1fd2bf39a2 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -459,7 +459,9 @@ impl Options { }) .collect(), ]; - let default_settings = default_settings.into_iter().flatten() + 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 @@ -479,7 +481,7 @@ impl Options { // `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) + |(k, v)| (k.replace('-', "_"), v), ) .collect(); From f423ef51d3219e3fe1a09d0eb06795e435017047 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Jul 2021 11:50:14 +0200 Subject: [PATCH 06/11] Don't render in items' summary --- src/librustdoc/html/markdown.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index e21469dc9c343..908e292d968ef 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -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 @@ -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>> Iterator for SummaryLine<'a, I> { type Item = Event<'a>; @@ -535,14 +539,17 @@ impl<'a, I: Iterator>> 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) From de25b1c7407c5b9d2214b891523d332c3435d02c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Jul 2021 12:02:41 +0200 Subject: [PATCH 07/11] Add test to ensure tables are not inside items summary --- src/test/rustdoc-gui/item-summary-table.goml | 6 ++++++ src/test/rustdoc-gui/src/lib2/lib.rs | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 src/test/rustdoc-gui/item-summary-table.goml diff --git a/src/test/rustdoc-gui/item-summary-table.goml b/src/test/rustdoc-gui/item-summary-table.goml new file mode 100644 index 0000000000000..6bf4e288c4377 --- /dev/null +++ b/src/test/rustdoc-gui/item-summary-table.goml @@ -0,0 +1,6 @@ +// This test ensures that
elements aren't display in items summary. +goto: file://|DOC_PATH|/lib2/summary_table/index.html +// We check that we picked the right item first. +assert-text: (".item-table .item-left", "Foo") +// Then we check that its summary is empty. +assert-text: (".item-table .item-right", "") diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 86ae330e0098f..36373d24971c9 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -66,3 +66,10 @@ pub mod long_table { /// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq pub struct Foo; } + +pub mod summary_table { + /// | header 1 | header 2 | + /// | -------- | -------- | + /// | content | content | + pub struct Foo; +} From 3bafcf87aaaf3785873b637a67d7b49dafbb0a69 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Jul 2021 17:55:44 +0200 Subject: [PATCH 08/11] Remove cargo workspace to build rustdoc-gui test crates because of cargo config not being applied --- Cargo.toml | 1 + src/bootstrap/test.rs | 31 +++++++++++++++++++---------- src/test/rustdoc-gui/src/Cargo.lock | 18 ----------------- src/test/rustdoc-gui/src/Cargo.toml | 6 ------ 4 files changed, 21 insertions(+), 35 deletions(-) delete mode 100644 src/test/rustdoc-gui/src/Cargo.lock delete mode 100644 src/test/rustdoc-gui/src/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 4c00a7dc99ea9..dedfe45aca49b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 50980d25cb288..31f18d81c7c0f 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -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); diff --git a/src/test/rustdoc-gui/src/Cargo.lock b/src/test/rustdoc-gui/src/Cargo.lock deleted file mode 100644 index a72ccffc6ddf9..0000000000000 --- a/src/test/rustdoc-gui/src/Cargo.lock +++ /dev/null @@ -1,18 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "implementors" -version = "0.1.0" - -[[package]] -name = "lib2" -version = "0.1.0" -dependencies = [ - "implementors", -] - -[[package]] -name = "test_docs" -version = "0.1.0" diff --git a/src/test/rustdoc-gui/src/Cargo.toml b/src/test/rustdoc-gui/src/Cargo.toml deleted file mode 100644 index 9c8c0c636f07f..0000000000000 --- a/src/test/rustdoc-gui/src/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[workspace] -members = [ - "test_docs", - "lib2", - "implementors", -] From 4f98d51f98724be86e41890bc58ddb1ff2520410 Mon Sep 17 00:00:00 2001 From: Lily Ballard Date: Wed, 21 Jul 2021 16:53:19 -0700 Subject: [PATCH 09/11] Update my name/email in .mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index d6b7ab51a48c6..3b8d19dc4e2ba 100644 --- a/.mailmap +++ b/.mailmap @@ -175,6 +175,7 @@ Lennart Kudling Léo Lanteri Thauvin Léo Lanteri Thauvin <38361244+LeSeulArtichaut@users.noreply.github.com> Léo Testard +Lily Ballard Lindsey Kuper Lindsey Kuper Luke Metz From 174728d045bedae764c38b703839eb6ac244a4e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Jul 2021 17:56:41 +0200 Subject: [PATCH 10/11] Add tests for default-settings --- src/test/rustdoc-gui/default-settings.goml | 8 ++++++++ src/test/rustdoc-gui/src/implementors/Cargo.lock | 7 +++++++ src/test/rustdoc-gui/src/lib2/Cargo.lock | 14 ++++++++++++++ .../rustdoc-gui/src/settings/.cargo/config.toml | 2 ++ src/test/rustdoc-gui/src/settings/Cargo.lock | 7 +++++++ src/test/rustdoc-gui/src/settings/Cargo.toml | 7 +++++++ src/test/rustdoc-gui/src/settings/lib.rs | 1 + src/test/rustdoc-gui/src/test_docs/Cargo.lock | 7 +++++++ src/test/rustdoc/default-theme.rs | 7 +++++++ 9 files changed, 60 insertions(+) create mode 100644 src/test/rustdoc-gui/default-settings.goml create mode 100644 src/test/rustdoc-gui/src/implementors/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/lib2/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/settings/.cargo/config.toml create mode 100644 src/test/rustdoc-gui/src/settings/Cargo.lock create mode 100644 src/test/rustdoc-gui/src/settings/Cargo.toml create mode 100644 src/test/rustdoc-gui/src/settings/lib.rs create mode 100644 src/test/rustdoc-gui/src/test_docs/Cargo.lock create mode 100644 src/test/rustdoc/default-theme.rs diff --git a/src/test/rustdoc-gui/default-settings.goml b/src/test/rustdoc-gui/default-settings.goml new file mode 100644 index 0000000000000..68b674a11f2f5 --- /dev/null +++ b/src/test/rustdoc-gui/default-settings.goml @@ -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)"}) diff --git a/src/test/rustdoc-gui/src/implementors/Cargo.lock b/src/test/rustdoc-gui/src/implementors/Cargo.lock new file mode 100644 index 0000000000000..cad99a991a2c8 --- /dev/null +++ b/src/test/rustdoc-gui/src/implementors/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "implementors" +version = "0.1.0" diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.lock b/src/test/rustdoc-gui/src/lib2/Cargo.lock new file mode 100644 index 0000000000000..a5873ceb3256a --- /dev/null +++ b/src/test/rustdoc-gui/src/lib2/Cargo.lock @@ -0,0 +1,14 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "implementors" +version = "0.1.0" + +[[package]] +name = "lib2" +version = "0.1.0" +dependencies = [ + "implementors", +] diff --git a/src/test/rustdoc-gui/src/settings/.cargo/config.toml b/src/test/rustdoc-gui/src/settings/.cargo/config.toml new file mode 100644 index 0000000000000..bbb8d11a2ede8 --- /dev/null +++ b/src/test/rustdoc-gui/src/settings/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustdocflags = ["--default-theme", "ayu"] diff --git a/src/test/rustdoc-gui/src/settings/Cargo.lock b/src/test/rustdoc-gui/src/settings/Cargo.lock new file mode 100644 index 0000000000000..6f0de1ac1e85b --- /dev/null +++ b/src/test/rustdoc-gui/src/settings/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "settings" +version = "0.1.0" diff --git a/src/test/rustdoc-gui/src/settings/Cargo.toml b/src/test/rustdoc-gui/src/settings/Cargo.toml new file mode 100644 index 0000000000000..c8a211a47cafc --- /dev/null +++ b/src/test/rustdoc-gui/src/settings/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "settings" +version = "0.1.0" +edition = "2018" + +[lib] +path = "lib.rs" diff --git a/src/test/rustdoc-gui/src/settings/lib.rs b/src/test/rustdoc-gui/src/settings/lib.rs new file mode 100644 index 0000000000000..b76b4321d62aa --- /dev/null +++ b/src/test/rustdoc-gui/src/settings/lib.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/src/test/rustdoc-gui/src/test_docs/Cargo.lock b/src/test/rustdoc-gui/src/test_docs/Cargo.lock new file mode 100644 index 0000000000000..6b80f6e88ef13 --- /dev/null +++ b/src/test/rustdoc-gui/src/test_docs/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "test_docs" +version = "0.1.0" diff --git a/src/test/rustdoc/default-theme.rs b/src/test/rustdoc/default-theme.rs new file mode 100644 index 0000000000000..ecb8f0b3b4876 --- /dev/null +++ b/src/test/rustdoc/default-theme.rs @@ -0,0 +1,7 @@ +// compile-flags: --default-theme ayu + +// @has default_theme/index.html +// @has - '//script[@id="default-settings"]/@data-theme' 'ayu' +// @has - '//script[@id="default-settings"]/@data-use_system_theme' 'false' + +pub fn whatever() {} From df6bdd764a6b3bbef2f59f1dda37cfa81972d4fd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 21 Jul 2021 22:30:12 +0200 Subject: [PATCH 11/11] Move implementors directly into lib2 --- src/test/rustdoc-gui/src/lib2/Cargo.toml | 2 +- src/test/rustdoc-gui/src/{ => lib2}/implementors/Cargo.lock | 0 src/test/rustdoc-gui/src/{ => lib2}/implementors/Cargo.toml | 0 src/test/rustdoc-gui/src/{ => lib2}/implementors/lib.rs | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename src/test/rustdoc-gui/src/{ => lib2}/implementors/Cargo.lock (100%) rename src/test/rustdoc-gui/src/{ => lib2}/implementors/Cargo.toml (100%) rename src/test/rustdoc-gui/src/{ => lib2}/implementors/lib.rs (100%) diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.toml b/src/test/rustdoc-gui/src/lib2/Cargo.toml index 6041a793f08da..2e37f3f667a02 100644 --- a/src/test/rustdoc-gui/src/lib2/Cargo.toml +++ b/src/test/rustdoc-gui/src/lib2/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" path = "lib.rs" [dependencies] -implementors = { path = "../implementors" } +implementors = { path = "./implementors" } diff --git a/src/test/rustdoc-gui/src/implementors/Cargo.lock b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock similarity index 100% rename from src/test/rustdoc-gui/src/implementors/Cargo.lock rename to src/test/rustdoc-gui/src/lib2/implementors/Cargo.lock diff --git a/src/test/rustdoc-gui/src/implementors/Cargo.toml b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml similarity index 100% rename from src/test/rustdoc-gui/src/implementors/Cargo.toml rename to src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml diff --git a/src/test/rustdoc-gui/src/implementors/lib.rs b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs similarity index 100% rename from src/test/rustdoc-gui/src/implementors/lib.rs rename to src/test/rustdoc-gui/src/lib2/implementors/lib.rs