From cf1c06b64f0d44d93e32a0cd02cf99394834d2de Mon Sep 17 00:00:00 2001 From: Gent Binaku Date: Thu, 5 Jan 2023 07:10:18 +0100 Subject: [PATCH 1/5] working doctests --- compiler/rustc_ast_lowering/Cargo.toml | 3 +-- compiler/rustc_ast_lowering/src/lib.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index ce1c8d4997d74..c2a2bc795c382 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -3,8 +3,7 @@ name = "rustc_ast_lowering" version = "0.0.0" edition = "2021" -[lib] -doctest = false + [dependencies] rustc_arena = { path = "../rustc_arena" } diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 427b71722abcc..7ff9de72a28bb 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1418,21 +1418,23 @@ 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 - /// ``` + /// type TestReturn<'a, 'x, T> = impl Debug + 'x; + /// /// /// and return a type like `TestReturn<'static, T, 'a>`, 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<'a, 'x, T> = impl Debug + 'x; + /// fn test<'a, 'x, T: Debug>(x: &'a T) -> TestReturn<'a, 'x, T>{} /// ``` /// /// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the From ffe76dfa7b7c719bf0456a2d232a85676fd2b86b Mon Sep 17 00:00:00 2001 From: Gent Binaku Date: Thu, 5 Jan 2023 07:13:11 +0100 Subject: [PATCH 2/5] working doctests --- compiler/rustc_ast_lowering/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7ff9de72a28bb..f972a90919651 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1426,9 +1426,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// /// we will create a TAIT definition in the HIR like /// type TestReturn<'a, 'x, T> = impl Debug + 'x; - /// - /// - /// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like: + /// and return a type like `TestReturn<'a, 'x, 'T>`, so that the function looks like: /// /// ```rust /// #![feature(type_alias_impl_trait)] From 873b2e47df5267610e425e178220b47ce4347a48 Mon Sep 17 00:00:00 2001 From: Gent Binaku Date: Sat, 14 Jan 2023 12:11:47 +0100 Subject: [PATCH 3/5] Rust ignore doctest --- compiler/rustc_ast_lowering/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index f972a90919651..761a07add1935 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1425,7 +1425,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// ``` /// /// we will create a TAIT definition in the HIR like - /// type TestReturn<'a, 'x, T> = impl Debug + 'x; + /// + /// ```rust,ignore + /// type TestReturn<'a, T, 'x> = impl Debug + 'x + /// ``` /// and return a type like `TestReturn<'a, 'x, 'T>`, so that the function looks like: /// /// ```rust From 8fb3354a792b803b110824f40134b74757d957d1 Mon Sep 17 00:00:00 2001 From: Gent Binaku Date: Sat, 14 Jan 2023 12:21:01 +0100 Subject: [PATCH 4/5] Rust ignore doctest --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 761a07add1935..7a148b33945fa 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1426,7 +1426,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// /// we will create a TAIT definition in the HIR like /// - /// ```rust,ignore + /// ```rust,no_run /// type TestReturn<'a, T, 'x> = impl Debug + 'x /// ``` /// and return a type like `TestReturn<'a, 'x, 'T>`, so that the function looks like: From 700db5c277307000b625d34ea45d4971fc547410 Mon Sep 17 00:00:00 2001 From: Gent Binaku Date: Sat, 14 Jan 2023 12:32:57 +0100 Subject: [PATCH 5/5] Rust ignore doctest --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7a148b33945fa..36a493ce02de8 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1426,7 +1426,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// /// we will create a TAIT definition in the HIR like /// - /// ```rust,no_run + /// ```ignore (cannot-test-this-because-type) /// type TestReturn<'a, T, 'x> = impl Debug + 'x /// ``` /// and return a type like `TestReturn<'a, 'x, 'T>`, so that the function looks like: