Skip to content

Commit 8a746f4

Browse files
committed
Auto merge of #105940 - matthiaskrgr:rollup-ho4po1t, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #105901 (Don't panic on stable since miri is not available there) - #105912 (rustdoc: force pre tags to have the default line height) - #105914 (rustdoc: Simplify CSS for scraped code examples code blocks) - #105933 (Add readable rustdoc display for tvOS and watchOS) - #105935 (docs/test: add UI test and long-form error docs for `E0377`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb9e5e7 + 051c52a commit 8a746f4

File tree

10 files changed

+90
-18
lines changed

10 files changed

+90
-18
lines changed

compiler/rustc_error_codes/src/error_codes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ E0373: include_str!("./error_codes/E0373.md"),
184184
E0374: include_str!("./error_codes/E0374.md"),
185185
E0375: include_str!("./error_codes/E0375.md"),
186186
E0376: include_str!("./error_codes/E0376.md"),
187+
E0377: include_str!("./error_codes/E0377.md"),
187188
E0378: include_str!("./error_codes/E0378.md"),
188189
E0379: include_str!("./error_codes/E0379.md"),
189190
E0380: include_str!("./error_codes/E0380.md"),
@@ -579,8 +580,6 @@ E0791: include_str!("./error_codes/E0791.md"),
579580
// E0315, // cannot invoke closure outside of its lifetime
580581
// E0319, // trait impls for defaulted traits allowed just for structs/enums
581582
// E0372, // coherence not object safe
582-
E0377, // the trait `CoerceUnsized` may only be implemented for a coercion
583-
// between structures with the same definition
584583
// E0385, // {} in an aliasable location
585584
// E0402, // cannot use an outer type parameter in this context
586585
// E0406, // merged into 420
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
The trait `CoerceUnsized` may only be implemented for a coercion between
2+
structures with the same definition.
3+
4+
Example of erroneous code:
5+
6+
```compile_fail,E0377
7+
#![feature(coerce_unsized)]
8+
use std::ops::CoerceUnsized;
9+
10+
pub struct Foo<T: ?Sized> {
11+
field_with_unsized_type: T,
12+
}
13+
14+
pub struct Bar<T: ?Sized> {
15+
field_with_unsized_type: T,
16+
}
17+
18+
// error: the trait `CoerceUnsized` may only be implemented for a coercion
19+
// between structures with the same definition
20+
impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {}
21+
```
22+
23+
When attempting to implement `CoerceUnsized`, the `impl` signature must look
24+
like: `impl CoerceUnsized<Type<U>> for Type<T> where T: CoerceUnsized<U>`;
25+
the *implementer* and *`CoerceUnsized` type parameter* must be the same
26+
type. In this example, `Bar` and `Foo` (even though structurally identical)
27+
are *not* the same type and are rejected. Learn more about the `CoerceUnsized`
28+
trait and DST coercion in
29+
[the `CoerceUnsized` docs](../std/ops/trait.CoerceUnsized.html).

src/bootstrap/install.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,14 @@ install!((self, builder, _config),
200200
install_sh(builder, "clippy", self.compiler.stage, Some(self.target), &tarball);
201201
};
202202
Miri, alias = "miri", Self::should_build(_config), only_hosts: true, {
203-
let tarball = builder
204-
.ensure(dist::Miri { compiler: self.compiler, target: self.target })
205-
.expect("missing miri");
206-
install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball);
203+
if let Some(tarball) = builder.ensure(dist::Miri { compiler: self.compiler, target: self.target }) {
204+
install_sh(builder, "miri", self.compiler.stage, Some(self.target), &tarball);
205+
} else {
206+
// Miri is only available on nightly
207+
builder.info(
208+
&format!("skipping Install miri stage{} ({})", self.compiler.stage, self.target),
209+
);
210+
}
207211
};
208212
LlvmTools, alias = "llvm-tools", Self::should_build(_config), only_hosts: true, {
209213
let tarball = builder

src/librustdoc/clean/cfg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,9 @@ impl<'a> fmt::Display for Display<'a> {
507507
"openbsd" => "OpenBSD",
508508
"redox" => "Redox",
509509
"solaris" => "Solaris",
510+
"tvos" => "tvOS",
510511
"wasi" => "WASI",
512+
"watchos" => "watchOS",
511513
"windows" => "Windows",
512514
_ => "",
513515
},

src/librustdoc/html/static/css/rustdoc.css

+1-10
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ code, pre, a.test-arrow, .code-header {
338338
}
339339
pre {
340340
padding: 14px;
341+
line-height: 1.5; /* https://github.com/rust-lang/rust/issues/105906 */
341342
}
342343
.item-decl pre {
343344
overflow-x: auto;
@@ -1972,10 +1973,7 @@ in storage.js
19721973
}
19731974

19741975
.scraped-example .code-wrapper .example-wrap {
1975-
display: grid;
1976-
grid-template-columns: max-content auto;
19771976
width: 100%;
1978-
overflow-x: auto;
19791977
overflow-y: hidden;
19801978
margin-bottom: 0;
19811979
}
@@ -1984,13 +1982,6 @@ in storage.js
19841982
overflow-x: hidden;
19851983
}
19861984

1987-
.scraped-example .code-wrapper .example-wrap pre.rust {
1988-
overflow-x: inherit;
1989-
width: inherit;
1990-
overflow-y: hidden;
1991-
}
1992-
1993-
19941985
.more-examples-toggle {
19951986
max-width: calc(100% + 25px);
19961987
margin-top: 10px;
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Test that code blocks nested within <sub> do not have a line height of 0.
2+
goto: "file://" + |DOC_PATH| + "/test_docs/codeblock_sub/index.html"
3+
4+
store-property: (codeblock_sub_1, "#codeblock-sub-1", "offsetHeight")
5+
assert-property-false: ("#codeblock-sub-3", { "offsetHeight": |codeblock_sub_1| })

src/test/rustdoc-gui/src/test_docs/lib.rs

+19
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,22 @@ impl TypeWithImplDoc {
455455
/// fn doc
456456
pub fn test_fn() {}
457457
}
458+
459+
/// <sub id="codeblock-sub-1">
460+
///
461+
/// ```
462+
/// one
463+
/// ```
464+
///
465+
/// </sub>
466+
///
467+
/// <sub id="codeblock-sub-3">
468+
///
469+
/// ```
470+
/// one
471+
/// two
472+
/// three
473+
/// ```
474+
///
475+
/// </sub>
476+
pub mod codeblock_sub {}

src/test/ui/error-codes/E0377.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(coerce_unsized)]
2+
use std::ops::CoerceUnsized;
3+
4+
pub struct Foo<T: ?Sized> {
5+
field_with_unsized_type: T,
6+
}
7+
8+
pub struct Bar<T: ?Sized> {
9+
field_with_unsized_type: T,
10+
}
11+
12+
impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {} //~ ERROR E0377
13+
14+
fn main() {}

src/test/ui/error-codes/E0377.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with the same definition; expected `Foo`, found `Bar`
2+
--> $DIR/E0377.rs:12:1
3+
|
4+
LL | impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0377`.

src/tools/tidy/src/error_codes_check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use regex::Regex;
1111

1212
// A few of those error codes can't be tested but all the others can and *should* be tested!
1313
const EXEMPTED_FROM_TEST: &[&str] = &[
14-
"E0313", "E0377", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523",
15-
"E0554", "E0640", "E0717", "E0729", "E0789",
14+
"E0313", "E0461", "E0462", "E0465", "E0476", "E0490", "E0514", "E0519", "E0523", "E0554",
15+
"E0640", "E0717", "E0729", "E0789",
1616
];
1717

1818
// Some error codes don't have any tests apparently...

0 commit comments

Comments
 (0)