From 85f2ecab576d3f02619b4d4976a6d7827c65ed4b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 11 Jun 2024 15:32:38 +0000 Subject: [PATCH] Add a `fn main() {}` to a doctest to prevent the test from being wrapped in a `fn main() {}` body --- compiler/rustc_error_codes/src/error_codes/E0792.md | 4 ++++ compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/compiler/rustc_error_codes/src/error_codes/E0792.md b/compiler/rustc_error_codes/src/error_codes/E0792.md index bad2b5abfe4d7..5e3dcc4aa7277 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0792.md +++ b/compiler/rustc_error_codes/src/error_codes/E0792.md @@ -39,6 +39,8 @@ type Foo = impl std::fmt::Debug; fn foo() -> Foo { 5u32 } + +fn main() {} ``` This means that no matter the generic parameter to `foo`, @@ -57,4 +59,6 @@ type Foo = impl Debug; fn foo() -> Foo { Vec::::new() } + +fn main() {} ``` diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 6098da990c043..7aef6321eeb5d 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -46,6 +46,8 @@ declare_lint! { /// fn test() -> impl Trait { /// 42 /// } + /// + /// fn main() {} /// ``` /// /// {{produces}}