Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4512f21

Browse files
committedOct 31, 2023
Accept less invalid Rust in rustdoc
1 parent 22b2712 commit 4512f21

35 files changed

+428
-127
lines changed
 

‎library/core/src/primitive_docs.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,26 +1077,6 @@ mod prim_tuple {}
10771077
#[doc(hidden)]
10781078
impl<T> (T,) {}
10791079

1080-
// Fake impl that's only really used for docs.
1081-
#[cfg(doc)]
1082-
#[stable(feature = "rust1", since = "1.0.0")]
1083-
#[doc(fake_variadic)]
1084-
/// This trait is implemented on arbitrary-length tuples.
1085-
impl<T: Clone> Clone for (T,) {
1086-
fn clone(&self) -> Self {
1087-
loop {}
1088-
}
1089-
}
1090-
1091-
// Fake impl that's only really used for docs.
1092-
#[cfg(doc)]
1093-
#[stable(feature = "rust1", since = "1.0.0")]
1094-
#[doc(fake_variadic)]
1095-
/// This trait is implemented on arbitrary-length tuples.
1096-
impl<T: Copy> Copy for (T,) {
1097-
// empty
1098-
}
1099-
11001080
#[rustc_doc_primitive = "f32"]
11011081
/// A 32-bit floating point type (specifically, the "binary32" type defined in IEEE 754-2008).
11021082
///

‎src/librustdoc/core.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,14 @@ pub(crate) fn run_global_ctxt(
319319
tcx.hir().for_each_module(|module| tcx.ensure().collect_mod_item_types(module))
320320
});
321321

322-
// NOTE: This is copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
322+
// NOTE: These are copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
323+
let _ = tcx.sess.time("wf_checking", || {
324+
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
325+
});
323326
tcx.sess.time("item_types_checking", || {
324327
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
325328
});
329+
326330
tcx.sess.abort_if_errors();
327331
tcx.sess.time("missing_docs", || rustc_lint::check_crate(tcx));
328332
tcx.sess.time("check_mod_attrs", || {

‎tests/rustdoc-gui/src/lib2/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ pub struct LongItemInfo2;
147147
#[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
148148
impl SimpleTrait for LongItemInfo2 {}
149149

150-
pub struct WhereWhitespace<T>;
150+
pub struct WhereWhitespace<T>(T);
151151

152152
impl<T> WhereWhitespace<T> {
153153
pub fn new<F>(f: F) -> Self
154154
where
155155
F: FnMut() -> i32,
156-
{}
156+
{todo!()}
157157
}
158158

159159
impl<K, T> Whitespace<&K> for WhereWhitespace<T>
@@ -187,6 +187,11 @@ impl ItemInfoAlignmentTest {
187187
pub mod scroll_traits {
188188
use std::iter::*;
189189

190+
struct Intersperse<T>(T);
191+
struct IntersperseWith<T, U>(T, U);
192+
struct Flatten<T>(T);
193+
struct Peekable<T>(T);
194+
190195
/// Shamelessly (partially) copied from `std::iter::Iterator`.
191196
/// It allows us to check that the scroll is working as expected on "hidden" items.
192197
pub trait Iterator {

‎tests/rustdoc-json/enums/field_hidden.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Regression test for <https://github.com/rust-lang/rust/issues/100529>.
22

33
#![no_core]
4-
#![feature(no_core)]
4+
#![feature(no_core, lang_items)]
5+
6+
#[lang = "sized"]
7+
trait Sized {}
58

69
// @has "$.index[*][?(@.name=='ParseError')]"
710
// @has "$.index[*][?(@.name=='UnexpectedEndTag')]"

‎tests/rustdoc-json/enums/kind.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// ignore-tidy-linelength
22

3-
#![feature(no_core)]
3+
#![feature(no_core, lang_items)]
44
#![no_core]
55

6+
#[lang = "sized"]
7+
trait Sized {}
8+
69
pub enum Foo {
710
// @set Unit = "$.index[*][?(@.name=='Unit')].id"
811
// @is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"'

‎tests/rustdoc-json/enums/tuple_fields_hidden.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
#![feature(no_core)]
1+
#![feature(no_core, lang_items)]
22
#![no_core]
33

4+
#[lang = "sized"]
5+
trait Sized {}
6+
47
// @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id"
58
// @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id"
69
// @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id"

‎tests/rustdoc-json/generic-associated-types/gats.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// ignore-tidy-linelength
22

33
#![no_core]
4-
#![feature(lang_items, no_core)]
4+
#![feature(lang_items, no_core, arbitrary_self_types)]
55

66
#[lang = "sized"]
77
pub trait Sized {}
88

9+
#[lang = "receiver"]
10+
pub trait Receiver {}
11+
912
pub trait Display {}
1013

1114
pub trait LendingIterator {

‎tests/rustdoc-json/impls/auto.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
#![feature(no_core, auto_traits, lang_items)]
1+
#![feature(no_core, auto_traits, lang_items, arbitrary_self_types)]
22
#![no_core]
33

44
#[lang = "sized"]
55
trait Sized {}
66

7+
#[lang = "receiver"]
8+
pub trait Receiver {}
9+
710
pub auto trait Bar {}
811

912
/// has span
@@ -12,8 +15,8 @@ impl Foo {
1215
}
1316

1417
// Testing spans, so all tests below code
15-
// @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]"
16-
// @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]"
18+
// @is "$.index[*][?(@.docs=='has span')].span.begin" "[13, 0]"
19+
// @is "$.index[*][?(@.docs=='has span')].span.end" "[15, 1]"
1720
// FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91
1821
// is "$.index[*][?(@.inner.impl.synthetic==true)].span" null
1922
pub struct Foo;

‎tests/rustdoc-json/type/inherent_associated_type_bound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub struct Carrier<'a>(&'a ());
1616
pub fn user(_: for<'b> fn(Carrier<'b>::Focus<i32>)) {}
1717

1818
impl<'a> Carrier<'a> {
19-
pub type Focus<T> = &'a mut T;
19+
pub type Focus<T> = &'a mut T where T: 'a;
2020
}

‎tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// check-pass
2-
31
pub fn f() -> impl Sized {
42
pub enum E {
3+
//~^ ERROR: recursive type
54
V(E),
65
}
76

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0072]: recursive type `f::E` has infinite size
2+
--> $DIR/infinite-recursive-type-2.rs:2:5
3+
|
4+
LL | pub enum E {
5+
| ^^^^^^^^^^
6+
LL |
7+
LL | V(E),
8+
| - recursive without indirection
9+
|
10+
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
11+
|
12+
LL | V(Box<E>),
13+
| ++++ +
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0072`.

‎tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// check-pass
2-
31
fn f() -> impl Sized {
42
enum E {
3+
//~^ ERROR: recursive type
54
V(E),
65
}
76

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0072]: recursive type `f::E` has infinite size
2+
--> $DIR/infinite-recursive-type.rs:2:5
3+
|
4+
LL | enum E {
5+
| ^^^^^^
6+
LL |
7+
LL | V(E),
8+
| - recursive without indirection
9+
|
10+
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
11+
|
12+
LL | V(Box<E>),
13+
| ++++ +
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0072`.

‎tests/rustdoc-ui/invalid_const_in_lifetime_position.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ trait X {
44
fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
55
//~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
66
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
7+
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
8+
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
9+
//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments
10+
//~| ERROR associated type takes 0 generic arguments but 1 generic argument
11+
//~| ERROR trait `X` cannot be made into an object

‎tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,86 @@ note: associated type defined here, with 0 generic parameters
2828
LL | type Y<'a>;
2929
| ^
3030

31-
error: aborting due to 2 previous errors
31+
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
32+
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
33+
|
34+
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
35+
| ^ expected 1 lifetime argument
36+
|
37+
note: associated type defined here, with 1 lifetime parameter: `'a`
38+
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
39+
|
40+
LL | type Y<'a>;
41+
| ^ --
42+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
43+
help: add missing lifetime argument
44+
|
45+
LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
46+
| +++
47+
48+
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
49+
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
50+
|
51+
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
52+
| ^--- help: remove these generics
53+
| |
54+
| expected 0 generic arguments
55+
|
56+
note: associated type defined here, with 0 generic parameters
57+
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
58+
|
59+
LL | type Y<'a>;
60+
| ^
61+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
62+
63+
error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
64+
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
65+
|
66+
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
67+
| ^ expected 1 lifetime argument
68+
|
69+
note: associated type defined here, with 1 lifetime parameter: `'a`
70+
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
71+
|
72+
LL | type Y<'a>;
73+
| ^ --
74+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
75+
help: add missing lifetime argument
76+
|
77+
LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {}
78+
| +++
79+
80+
error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied
81+
--> $DIR/invalid_const_in_lifetime_position.rs:4:26
82+
|
83+
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
84+
| ^--- help: remove these generics
85+
| |
86+
| expected 0 generic arguments
87+
|
88+
note: associated type defined here, with 0 generic parameters
89+
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
90+
|
91+
LL | type Y<'a>;
92+
| ^
93+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
94+
95+
error[E0038]: the trait `X` cannot be made into an object
96+
--> $DIR/invalid_const_in_lifetime_position.rs:4:20
97+
|
98+
LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
99+
| ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
100+
|
101+
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
102+
--> $DIR/invalid_const_in_lifetime_position.rs:2:10
103+
|
104+
LL | trait X {
105+
| - this trait cannot be made into an object...
106+
LL | type Y<'a>;
107+
| ^ ...because it contains the generic associated type `Y`
108+
= help: consider moving `Y` to another trait
109+
110+
error: aborting due to 7 previous errors
32111

33-
For more information about this error, try `rustc --explain E0107`.
112+
Some errors have detailed explanations: E0038, E0107.
113+
For more information about an error, try `rustc --explain E0038`.

‎tests/rustdoc-ui/issues/issue-105742.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub trait SVec: Index<
2121
//~| missing generics for associated type `SVec::Item`
2222
//~| missing generics for associated type `SVec::Item`
2323
//~| missing generics for associated type `SVec::Item`
24+
//~| missing generics for associated type `SVec::Item`
25+
//~| missing generics for associated type `SVec::Item`
2426
Output = <Index<<Self as SVec>::Item,
2527
//~^ expected 1 lifetime argument
2628
//~| expected 1 generic argument
@@ -30,6 +32,8 @@ pub trait SVec: Index<
3032
//~| missing generics for associated type `SVec::Item`
3133
//~| missing generics for associated type `SVec::Item`
3234
//~| missing generics for associated type `SVec::Item`
35+
//~| missing generics for associated type `SVec::Item`
36+
//~| missing generics for associated type `SVec::Item`
3337
Output = <Self as SVec>::Item> as SVec>::Item,
3438
//~^ expected 1 lifetime argument
3539
//~| expected 1 generic argument
@@ -47,6 +51,10 @@ pub trait SVec: Index<
4751
//~| missing generics for associated type `SVec::Item`
4852
//~| missing generics for associated type `SVec::Item`
4953
//~| missing generics for associated type `SVec::Item`
54+
//~| missing generics for associated type `SVec::Item`
55+
//~| missing generics for associated type `SVec::Item`
56+
//~| missing generics for associated type `SVec::Item`
57+
//~| missing generics for associated type `SVec::Item`
5058
> {
5159
type Item<'a, T>;
5260

‎tests/rustdoc-ui/issues/issue-105742.stderr

Lines changed: 185 additions & 49 deletions
Large diffs are not rendered by default.

‎tests/rustdoc/not-wf-ambiguous-normalization.rs renamed to ‎tests/rustdoc-ui/not-wf-ambiguous-normalization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct DefaultAllocator;
1212
// `<DefaultAllocator as Allocator>::Buffer` to be ambiguous,
1313
// which caused an ICE with `-Znormalize-docs`.
1414
impl<T> Allocator for DefaultAllocator {
15+
//~^ ERROR: type annotations needed
1516
type Buffer = ();
1617
}
1718

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/not-wf-ambiguous-normalization.rs:14:23
3+
|
4+
LL | impl<T> Allocator for DefaultAllocator {
5+
| ^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.

‎tests/rustdoc-ui/recursive-deref-ice.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
pub struct Attribute;
66

7-
pub struct Map<'hir> {}
7+
pub struct Map<'hir> {
8+
lt: &'hir (),
9+
}
10+
811
impl<'hir> Map<'hir> {
912
pub fn attrs(&self) -> &'hir [Attribute] { &[] }
1013
}

‎tests/rustdoc-ui/unable-fulfill-trait.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
pub struct Foo<'a, 'b, T> {
44
field1: dyn Bar<'a, 'b,>,
55
//~^ ERROR
6-
//~^^ ERROR
6+
//~| ERROR
7+
//~| ERROR
78
}
89

910
pub trait Bar<'x, 's, U>

‎tests/rustdoc-ui/unable-fulfill-trait.stderr

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | field1: dyn Bar<'a, 'b,>,
55
| ^^^ expected 1 generic argument
66
|
77
note: trait defined here, with 1 generic parameter: `U`
8-
--> $DIR/unable-fulfill-trait.rs:9:11
8+
--> $DIR/unable-fulfill-trait.rs:10:11
99
|
1010
LL | pub trait Bar<'x, 's, U>
1111
| ^^^ -
@@ -20,7 +20,24 @@ error[E0227]: ambiguous lifetime bound, explicit lifetime bound required
2020
LL | field1: dyn Bar<'a, 'b,>,
2121
| ^^^^^^^^^^^^^^^^
2222

23-
error: aborting due to 2 previous errors
23+
error[E0478]: lifetime bound not satisfied
24+
--> $DIR/unable-fulfill-trait.rs:4:13
25+
|
26+
LL | field1: dyn Bar<'a, 'b,>,
27+
| ^^^^^^^^^^^^^^^^
28+
|
29+
note: lifetime parameter instantiated with the lifetime `'b` as defined here
30+
--> $DIR/unable-fulfill-trait.rs:3:20
31+
|
32+
LL | pub struct Foo<'a, 'b, T> {
33+
| ^^
34+
note: but lifetime parameter must outlive the lifetime `'a` as defined here
35+
--> $DIR/unable-fulfill-trait.rs:3:16
36+
|
37+
LL | pub struct Foo<'a, 'b, T> {
38+
| ^^
39+
40+
error: aborting due to 3 previous errors
2441

25-
Some errors have detailed explanations: E0107, E0227.
42+
Some errors have detailed explanations: E0107, E0227, E0478.
2643
For more information about an error, try `rustc --explain E0107`.

‎tests/rustdoc/const-generics/const-impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#![feature(adt_const_params)]
33
#![crate_name = "foo"]
44

5-
#[derive(PartialEq, Eq)]
5+
use std::marker::ConstParamTy;
6+
7+
#[derive(PartialEq, Eq, ConstParamTy)]
68
pub enum Order {
79
Sorted,
810
Unsorted,

‎tests/rustdoc/decl-trailing-whitespace.declaration.html

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
<code>pub trait Write {
22
// Required methods
33
fn <a href="#tymethod.poll_write" class="fn">poll_write</a>(
4-
self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
4+
self,
55
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
66
buf: &amp;mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]
77
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
8-
<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fn">poll_flush</a>(
9-
self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
10-
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;
11-
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
12-
<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fn">poll_close</a>(
13-
self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
14-
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;
15-
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
8+
<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fn">poll_flush</a>(self, cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
9+
<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fn">poll_close</a>(self, cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt;;
1610

1711
// Provided method
1812
fn <a href="#method.poll_write_vectored" class="fn">poll_write_vectored</a>(
19-
self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
13+
self,
2014
cx: &amp;mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
2115
bufs: &amp;[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>]
2216
) -&gt; <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>&gt;&gt; { ... }

‎tests/rustdoc/decl-trailing-whitespace.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ pub struct Error;
99
pub trait Write {
1010
// @snapshot 'declaration' - '//*[@class="rust item-decl"]//code'
1111
fn poll_write(
12-
self: Option<String>,
12+
self,
1313
cx: &mut Option<String>,
1414
buf: &mut [usize]
1515
) -> Option<Result<usize, Error>>;
1616
fn poll_flush(
17-
self: Option<String>,
17+
self,
1818
cx: &mut Option<String>
1919
) -> Option<Result<(), Error>>;
2020
fn poll_close(
21-
self: Option<String>,
21+
self,
2222
cx: &mut Option<String>,
2323
) -> Option<Result<(), Error>>;
2424

2525
fn poll_write_vectored(
26-
self: Option<String>,
26+
self,
2727
cx: &mut Option<String>,
2828
bufs: &[usize]
2929
) -> Option<Result<usize, Error>> {}

‎tests/rustdoc/hide-complex-unevaluated-const-arguments.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
//
55
// Read the documentation of `rustdoc::clean::utils::print_const_expr`
66
// for further details.
7-
#![feature(const_trait_impl, generic_const_exprs)]
7+
#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)]
88
#![allow(incomplete_features)]
99

10+
use std::marker::ConstParamTy;
11+
1012
// @has hide_complex_unevaluated_const_arguments/trait.Stage.html
1113
pub trait Stage {
1214
// A helper constant that prevents const expressions containing it
@@ -29,11 +31,13 @@ pub trait Stage {
2931
//
3032
// @has - '//*[@id="associatedconstant.ARRAY1"]' \
3133
// 'const ARRAY1: [u8; { _ }]'
32-
const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)];
34+
const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]
35+
where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:;
3336

3437
// @has - '//*[@id="associatedconstant.VERBOSE"]' \
3538
// 'const VERBOSE: [u16; { _ }]'
36-
const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT];
39+
const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT]
40+
where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:;
3741

3842
// Check that we do not leak the private struct field contained within
3943
// the path. The output could definitely be improved upon
@@ -69,6 +73,7 @@ pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {}
6973

7074
pub trait Sup<const N: usize, const S: Struct> {}
7175

76+
#[derive(ConstParamTy, PartialEq, Eq)]
7277
pub struct Struct { private: () }
7378

7479
impl Struct {

‎tests/rustdoc/intra-doc/prim-associated-traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ pub struct Number {
4141
pub u_128: u128,
4242
pub ch: char,
4343
pub boolean: bool,
44-
pub string: str,
44+
pub string: &'static str,
4545
pub n: !,
4646
}

‎tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@
33
#![feature(no_core)]
44
#![no_core]
55
#[lang = "owned_box"]
6-
pub struct Box<T>;
6+
pub struct Box<T>(*const T);
77

88
impl<T> Box<T> {
99
pub fn new(x: T) -> Box<T> {
10-
Box
10+
Box(std::ptr::null())
1111
}
1212
}
1313

14+
#[lang = "sized"]
15+
trait Sized {}
16+
1417
#[doc(notable_trait)]
1518
pub trait FakeIterator {}
1619

1720
impl<I: FakeIterator> FakeIterator for Box<I> {}
1821

1922
#[lang = "pin"]
20-
pub struct Pin<T>;
23+
pub struct Pin<T>(T);
2124

2225
impl<T> Pin<T> {
2326
pub fn new(x: T) -> Pin<T> {
24-
Pin
27+
Pin(x)
2528
}
2629
}
2730

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<pre class="rust item-decl"><code>pub enum Cow&lt;'a, B&gt;<span class="where fmt-newline">where
2-
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
2+
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
33
Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a B</a>),
44
Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>),
55
}</code></pre>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<pre class="rust item-decl"><code>pub enum Cow2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
1+
<pre class="rust item-decl"><code>pub enum Cow2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + 'a&gt; {
22
Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a B</a>),
33
Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>),
44
}</code></pre>

‎tests/rustdoc/whitespace-after-where-clause.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
// @has 'foo/trait.ToOwned.html'
77
// @snapshot trait - '//*[@class="rust item-decl"]'
88
pub trait ToOwned<T>
9-
where T: Clone
9+
where
10+
T: Clone,
1011
{
1112
type Owned;
1213
fn to_owned(&self) -> Self::Owned;
@@ -26,7 +27,7 @@ pub trait ToOwned2<T: Clone> {
2627
// @snapshot enum - '//*[@class="rust item-decl"]'
2728
pub enum Cow<'a, B: ?Sized + 'a>
2829
where
29-
B: ToOwned<Clone>,
30+
B: ToOwned<()>,
3031
{
3132
Borrowed(&'a B),
3233
Whatever(u32),
@@ -35,7 +36,7 @@ where
3536
// @has 'foo/enum.Cow2.html'
3637
// @snapshot enum2 - '//*[@class="rust item-decl"]'
3738
// There should be a whitespace before `{` in this case!
38-
pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
39+
pub enum Cow2<'a, B: ?Sized + ToOwned<()> + 'a> {
3940
Borrowed(&'a B),
4041
Whatever(u32),
4142
}
@@ -44,7 +45,7 @@ pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
4445
// @snapshot struct - '//*[@class="rust item-decl"]'
4546
pub struct Struct<'a, B: ?Sized + 'a>
4647
where
47-
B: ToOwned<Clone>,
48+
B: ToOwned<()>,
4849
{
4950
pub a: &'a B,
5051
pub b: u32,
@@ -53,7 +54,7 @@ where
5354
// @has 'foo/struct.Struct2.html'
5455
// @snapshot struct2 - '//*[@class="rust item-decl"]'
5556
// There should be a whitespace before `{` in this case!
56-
pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
57+
pub struct Struct2<'a, B: ?Sized + ToOwned<()> + 'a> {
5758
pub a: &'a B,
5859
pub b: u32,
5960
}
@@ -62,7 +63,7 @@ pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
6263
// @snapshot union - '//*[@class="rust item-decl"]'
6364
pub union Union<'a, B: ?Sized + 'a>
6465
where
65-
B: ToOwned<Clone>,
66+
B: ToOwned<()>,
6667
{
6768
a: &'a B,
6869
b: u32,
@@ -71,7 +72,7 @@ where
7172
// @has 'foo/union.Union2.html'
7273
// @snapshot union2 - '//*[@class="rust item-decl"]'
7374
// There should be a whitespace before `{` in this case!
74-
pub union Union2<'a, B: ?Sized + ToOwned<Clone> + 'a> {
75+
pub union Union2<'a, B: ?Sized + ToOwned<()> + 'a> {
7576
a: &'a B,
7677
b: u32,
7778
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<pre class="rust item-decl"><code>pub struct Struct&lt;'a, B&gt;<span class="where fmt-newline">where
2-
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
2+
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
33
pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a B</a>,
44
pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>,
55
}</code></pre>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<pre class="rust item-decl"><code>pub struct Struct2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
1+
<pre class="rust item-decl"><code>pub struct Struct2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + 'a&gt; {
22
pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&amp;'a B</a>,
33
pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>,
44
}</code></pre>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<pre class="rust item-decl"><code>pub union Union&lt;'a, B&gt;<span class="where fmt-newline">where
2-
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
2+
B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{
33
/* private fields */
44
}</code></pre>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<pre class="rust item-decl"><code>pub union Union2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>&gt; + 'a&gt; {
1+
<pre class="rust item-decl"><code>pub union Union2&lt;'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a>&lt;<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>&gt; + 'a&gt; {
22
/* private fields */
33
}</code></pre>

0 commit comments

Comments
 (0)
Please sign in to comment.