Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

99144 enable doctests #106574

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name = "rustc_ast_lowering"
version = "0.0.0"
edition = "2021"

[lib]
doctest = false

[dependencies]
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
Expand Down
15 changes: 7 additions & 8 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,21 +1434,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// Given a function definition like:
///
/// ```rust
/// use std::fmt::Debug;
/// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
/// x
/// }
/// ```
///
/// we will create a TAIT definition in the HIR like
///
/// ```
/// type TestReturn<'a, T, 'x> = impl Debug + 'x
/// ```
///
/// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
/// we will create a TAIT definition in the HIR and change the return type so that the function looks like:
///
/// ```rust
/// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
/// #![feature(type_alias_impl_trait)]
/// use std::fmt::Debug;
/// type TestReturn<'x, 'a, T: Debug + 'a> = impl Debug + 'a;
/// fn test<'x, 'a, T: Debug>(x: &'a T) -> TestReturn<'x, 'a, T> { x }
///
/// ```
///
/// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_builtin_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name = "rustc_builtin_macros"
version = "0.0.0"
edition = "2021"

[lib]
doctest = false

[dependencies]
rustc_ast = { path = "../rustc_ast" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,16 +1036,17 @@ impl<'a> MethodDef<'a> {
/// ```
/// But if the struct is `repr(packed)`, we can't use something like
/// `&self.x` because that might cause an unaligned ref. So for any trait
/// method that takes a reference, we use a local block to force a copy.
/// This requires that the field impl `Copy`.
/// ```
/// method that takes a reference, if the struct impls `Copy` then we use a
/// local block to force a copy:
/// ```rust
/// # struct A { x: u8, y: u8 }
/// impl PartialEq for A {
/// fn eq(&self, other: &A) -> bool {
/// // Desugars to `{ self.x }.eq(&{ other.y }) && ...`
/// { self.x } == { other.y } && { self.y } == { other.y }
/// ({ self.x } == { other.y } && { self.y } == { other.y })
/// }
/// }
/// # use std::hash::Hash;
/// impl Hash for A {
/// fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
/// ::core::hash::Hash::hash(&{ self.x }, state);
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_expand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ version = "0.0.0"
edition = "2021"
build = false

[lib]
doctest = false

[dependencies]
crossbeam-channel = "0.5.0"
rustc_ast_passes = { path = "../rustc_ast_passes" }
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name = "rustc_infer"
version = "0.0.0"
edition = "2021"

[lib]
doctest = false

[dependencies]
tracing = "0.1"
rustc_middle = { path = "../rustc_middle" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum TypeAnnotationNeeded {
/// ```
E0282,
/// An implementation cannot be chosen unambiguously because of lack of information.
/// ```compile_fail,E0283
/// ```compile_fail
Noratrieb marked this conversation as resolved.
Show resolved Hide resolved
/// let _ = Default::default();
/// ```
E0283,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
///
/// Consider a case where we have
///
/// ```compile_fail,E0623
/// ```compile_fail
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
/// x.push(y);
/// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use rustc_middle::ty::{self, Region, TyCtxt};
/// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
///
/// # Example
/// ```compile_fail,E0623
/// fn foo(x: &mut Vec<&u8>, y: &u8)
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the compile_fail here?

/// fn foo<'a>(x: &mut Vec<&'a u8>, y: &'a u8)
/// { x.push(y); }
/// ```
/// The function returns the nested type corresponding to the anonymous region
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ use crate::infer::region_constraints::VerifyIfEq;

/// Given a "verify-if-eq" type test like:
///
/// ```ignore (not valid syntax)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it would be better to align the description with other parts of the document and make it ignore(illustrative).

/// exists<'a...> {
/// verify_if_eq(some_type, bound_region)
/// }
/// ```
///
/// and the type `test_ty` that the type test is being tested against,
/// returns:
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
///
/// It will not, however, work for higher-ranked bounds like:
///
/// ```compile_fail,E0311
/// ```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this compiles now then the previous comment is wrong as well (and we should find out why)

/// trait Foo<'a, 'b>
/// where for<'x> <Self as Foo<'x, 'b>>::Bar: 'x
/// {
Expand Down
18 changes: 16 additions & 2 deletions compiler/rustc_infer/src/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,15 @@ pub enum VerifyBound<'tcx> {
/// like this:
///
/// ```rust
/// fn foo<'a, 'b, T: SomeTrait<'a>>
/// # trait SomeTrait<'a> {
/// # type Item;
/// # }
/// fn foo<'a, 'b, T: SomeTrait<'a>>()
/// where
/// <T as SomeTrait<'a>>::Item: 'b
/// {
///
/// }
/// ```
///
/// If we have an obligation like `<T as SomeTrait<'?x>>::Item: 'c`, then
Expand All @@ -253,7 +259,15 @@ pub enum VerifyBound<'tcx> {
/// for cases like
///
/// ```rust
/// where for<'a> <T as SomeTrait<'a>::Item: 'a
/// # trait SomeTrait<'a> {
/// # type Item;
/// # }
/// fn foo<'a, 'b, T: SomeTrait<'a>>()
/// where
/// <T as SomeTrait<'a>>::Item: 'a
/// {
///
/// }
Comment on lines +262 to +270
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot more verbose and makes it harder to understand that the where clause is what's relevant here. I think it makes sense to ignore this block.

/// ```
///
/// The idea is that we have to find some instantiation of `'a` that can
Expand Down