From e5c92bc2b6f0bd69856ad3c4d3056c7f0c0ad72d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 19 Dec 2022 14:48:45 +0000 Subject: [PATCH 1/5] Don't panic on stable since miri is not available there --- src/bootstrap/install.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index c53d0d7e4cb7c..1815a0973072b 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -200,10 +200,14 @@ install!((self, builder, _config), install_sh(builder, "clippy", self.compiler.stage, Some(self.target), &tarball); }; Miri, alias = "miri", Self::should_build(_config), only_hosts: true, { - let tarball = builder - .ensure(dist::Miri { compiler: self.compiler, target: self.target }) - .expect("missing miri"); - install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball); + if let Some(tarball) = builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }) { + install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball); + } else { + // Miri is only available on nightly + builder.info( + &format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target), + ); + } }; LlvmTools, alias = "llvm-tools", Self::should_build(_config), only_hosts: true, { let tarball = builder From f24c04c3f8f4ac0ef318fa1c415aded1f781ebdf Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 19 Dec 2022 10:18:10 -0700 Subject: [PATCH 2/5] rustdoc: force pre tags to have the default line height Fixes #105906 --- src/librustdoc/html/static/css/rustdoc.css | 1 + src/test/rustdoc-gui/codeblock-sub.goml | 5 +++++ src/test/rustdoc-gui/src/test_docs/lib.rs | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/test/rustdoc-gui/codeblock-sub.goml diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 022ed606cc3b8..d392cc5ad5df2 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -342,6 +342,7 @@ code, pre, a.test-arrow, .code-header { } pre { padding: 14px; + line-height: 1.5; /* https://github.com/rust-lang/rust/issues/105906 */ } .item-decl pre { overflow-x: auto; diff --git a/src/test/rustdoc-gui/codeblock-sub.goml b/src/test/rustdoc-gui/codeblock-sub.goml new file mode 100644 index 0000000000000..cbd314d27915e --- /dev/null +++ b/src/test/rustdoc-gui/codeblock-sub.goml @@ -0,0 +1,5 @@ +// Test that code blocks nested within do not have a line height of 0. +goto: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html" + +store-property: (codeblock_sub_1, "#codeblock-sub-1", "offsetHeight") +assert-property-false: ("#codeblock-sub-3", { "offsetHeight": |codeblock_sub_1| }) diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs index f1b69d4dc1d40..51250439694b0 100644 --- a/src/test/rustdoc-gui/src/test_docs/lib.rs +++ b/src/test/rustdoc-gui/src/test_docs/lib.rs @@ -455,3 +455,22 @@ impl TypeWithImplDoc { /// fn doc pub fn test_fn() {} } + +/// +/// +/// ``` +/// one +/// ``` +/// +/// +/// +/// +/// +/// ``` +/// one +/// two +/// three +/// ``` +/// +/// +pub mod codeblock_sub {} From ecc8d007e46b6d981b2c6494698be8226c24f605 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Dec 2022 19:53:09 +0100 Subject: [PATCH 3/5] Simplify CSS for code examples code blocks --- src/librustdoc/html/static/css/rustdoc.css | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 022ed606cc3b8..f376258105ae3 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1976,10 +1976,7 @@ in storage.js } .scraped-example .code-wrapper .example-wrap { - display: grid; - grid-template-columns: max-content auto; width: 100%; - overflow-x: auto; overflow-y: hidden; margin-bottom: 0; } @@ -1988,13 +1985,6 @@ in storage.js overflow-x: hidden; } -.scraped-example .code-wrapper .example-wrap pre.rust { - overflow-x: inherit; - width: inherit; - overflow-y: hidden; -} - - .more-examples-toggle { max-width: calc(100% + 25px); margin-top: 10px; From 1b11ce26fa08b7f2a200fe1f4a21c7f580f354a5 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 20 Dec 2022 12:42:12 +0900 Subject: [PATCH 4/5] Add readable rustdoc display for tvOS and watchOS --- src/librustdoc/clean/cfg.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 1843a21205cfa..f1853f3697df2 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -507,7 +507,9 @@ impl<'a> fmt::Display for Display<'a> { "openbsd" => "OpenBSD", "redox" => "Redox", "solaris" => "Solaris", + "tvos" => "tvOS", "wasi" => "WASI", + "watchos" => "watchOS", "windows" => "Windows", _ => "", }, From e798fdf7befc40255ce46caa37a0e6c1e8756b6c Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Tue, 20 Dec 2022 18:31:15 +1300 Subject: [PATCH 5/5] docs/test: add UI test and long-form error docs for `E0377` --- compiler/rustc_error_codes/src/error_codes.rs | 3 +- .../src/error_codes/E0377.md | 29 +++++++++++++++++++ src/test/ui/error-codes/E0377.rs | 14 +++++++++ src/test/ui/error-codes/E0377.stderr | 9 ++++++ src/tools/tidy/src/error_codes_check.rs | 4 +-- 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0377.md create mode 100644 src/test/ui/error-codes/E0377.rs create mode 100644 src/test/ui/error-codes/E0377.stderr diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 883a4bbe8e823..4e149fc2b9973 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -184,6 +184,7 @@ E0373: include_str!("./error_codes/E0373.md"), E0374: include_str!("./error_codes/E0374.md"), E0375: include_str!("./error_codes/E0375.md"), E0376: include_str!("./error_codes/E0376.md"), +E0377: include_str!("./error_codes/E0377.md"), E0378: include_str!("./error_codes/E0378.md"), E0379: include_str!("./error_codes/E0379.md"), E0380: include_str!("./error_codes/E0380.md"), @@ -579,8 +580,6 @@ E0791: include_str!("./error_codes/E0791.md"), // E0315, // cannot invoke closure outside of its lifetime // E0319, // trait impls for defaulted traits allowed just for structs/enums // E0372, // coherence not object safe - E0377, // the trait `CoerceUnsized` may only be implemented for a coercion - // between structures with the same definition // E0385, // {} in an aliasable location // E0402, // cannot use an outer type parameter in this context // E0406, // merged into 420 diff --git a/compiler/rustc_error_codes/src/error_codes/E0377.md b/compiler/rustc_error_codes/src/error_codes/E0377.md new file mode 100644 index 0000000000000..b1d36406332bd --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0377.md @@ -0,0 +1,29 @@ +The trait `CoerceUnsized` may only be implemented for a coercion between +structures with the same definition. + +Example of erroneous code: + +```compile_fail,E0377 +#![feature(coerce_unsized)] +use std::ops::CoerceUnsized; + +pub struct Foo { + field_with_unsized_type: T, +} + +pub struct Bar { + field_with_unsized_type: T, +} + +// error: the trait `CoerceUnsized` may only be implemented for a coercion +// between structures with the same definition +impl CoerceUnsized> for Foo where T: CoerceUnsized {} +``` + +When attempting to implement `CoerceUnsized`, the `impl` signature must look +like: `impl CoerceUnsized> for Type where T: CoerceUnsized`; +the *implementer* and *`CoerceUnsized` type parameter* must be the same +type. In this example, `Bar` and `Foo` (even though structurally identical) +are *not* the same type and are rejected. Learn more about the `CoerceUnsized` +trait and DST coercion in +[the `CoerceUnsized` docs](../std/ops/trait.CoerceUnsized.html). diff --git a/src/test/ui/error-codes/E0377.rs b/src/test/ui/error-codes/E0377.rs new file mode 100644 index 0000000000000..6da2c20956adb --- /dev/null +++ b/src/test/ui/error-codes/E0377.rs @@ -0,0 +1,14 @@ +#![feature(coerce_unsized)] +use std::ops::CoerceUnsized; + +pub struct Foo { + field_with_unsized_type: T, +} + +pub struct Bar { + field_with_unsized_type: T, +} + +impl CoerceUnsized> for Foo where T: CoerceUnsized {} //~ ERROR E0377 + +fn main() {} diff --git a/src/test/ui/error-codes/E0377.stderr b/src/test/ui/error-codes/E0377.stderr new file mode 100644 index 0000000000000..bf7d8c8d39d2a --- /dev/null +++ b/src/test/ui/error-codes/E0377.stderr @@ -0,0 +1,9 @@ +error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with the same definition; expected `Foo`, found `Bar` + --> $DIR/E0377.rs:12:1 + | +LL | impl CoerceUnsized> for Foo where T: CoerceUnsized {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0377`. diff --git a/src/tools/tidy/src/error_codes_check.rs b/src/tools/tidy/src/error_codes_check.rs index 610e322e12963..1b119e4113e32 100644 --- a/src/tools/tidy/src/error_codes_check.rs +++ b/src/tools/tidy/src/error_codes_check.rs @@ -11,8 +11,8 @@ use regex::Regex; // A few of those error codes can't be tested but all the others can and *should* be tested! const EXEMPTED_FROM_TEST: &[&str] = &[ - "E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523", - "E0554", "E0640", "E0717", "E0729", "E0789", + "E0313", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523", "E0554", + "E0640", "E0717", "E0729", "E0789", ]; // Some error codes don't have any tests apparently...