Skip to content

Commit 4512f21

Browse files
committed
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

0 commit comments

Comments
 (0)