diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index eb2e82d7988c9..ad7197426f56d 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -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" } diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index b20157f2c7c89..3bffbd77b68b3 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -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 diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index 336e14ef96630..cb864d43b2dd1 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -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" } diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 1f819beeb5d7d..d9c5b119d3864 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -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); diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index c971714e05bb3..10db8bd823a94 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -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" } diff --git a/compiler/rustc_infer/Cargo.toml b/compiler/rustc_infer/Cargo.toml index 02ac83a5e8b25..a0c21c4495e7f 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml @@ -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" } diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index a3151d2d36577..8b1082b875923 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -31,7 +31,7 @@ pub enum TypeAnnotationNeeded { /// ``` E0282, /// An implementation cannot be chosen unambiguously because of lack of information. - /// ```compile_fail,E0283 + /// ```compile_fail /// let _ = Default::default(); /// ``` E0283, diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs index da0271a345e40..1a60bab18dbda 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -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); /// } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs index fec04af231393..2803cc0444be5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -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) +/// ``` +/// 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 diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 3c6cc2b90010f..55c565bac8188 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -13,9 +13,11 @@ use crate::infer::region_constraints::VerifyIfEq; /// Given a "verify-if-eq" type test like: /// +/// ```ignore (not valid syntax) /// exists<'a...> { /// verify_if_eq(some_type, bound_region) /// } +/// ``` /// /// and the type `test_ty` that the type test is being tested against, /// returns: diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index bae246418b05a..657d6fd697fc6 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -272,7 +272,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { /// /// It will not, however, work for higher-ranked bounds like: /// - /// ```compile_fail,E0311 + /// ``` /// trait Foo<'a, 'b> /// where for<'x> >::Bar: 'x /// { diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index 872f617474c06..f09a789e5d688 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -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 /// >::Item: 'b +/// { +/// +/// } /// ``` /// /// If we have an obligation like `>::Item: 'c`, then @@ -253,7 +259,15 @@ pub enum VerifyBound<'tcx> { /// for cases like /// /// ```rust -/// where for<'a> ::Item: 'a +/// # trait SomeTrait<'a> { +/// # type Item; +/// # } +/// fn foo<'a, 'b, T: SomeTrait<'a>>() +/// where +/// >::Item: 'a +/// { +/// +/// } /// ``` /// /// The idea is that we have to find some instantiation of `'a` that can