From 8dec09eae243350f5dea96e96cd68410613918fc Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 28 Jun 2024 17:25:20 +0200 Subject: [PATCH] Update rustdoc doctest non_local_defs impl test --- .../rustdoc-ui/doctest/non-local-defs-impl.rs | 5 ++++- .../doctest/non-local-defs-impl.stdout | 19 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/rustdoc-ui/doctest/non-local-defs-impl.rs b/tests/rustdoc-ui/doctest/non-local-defs-impl.rs index c984e097c0463..c1ddc376fbe6d 100644 --- a/tests/rustdoc-ui/doctest/non-local-defs-impl.rs +++ b/tests/rustdoc-ui/doctest/non-local-defs-impl.rs @@ -15,7 +15,10 @@ /// # use pub_trait::Trait; /// /// struct Local; -/// impl Trait for &Local {} +/// +/// fn foo() { +/// impl Trait for &Local {} +/// } /// ``` /// /// But this shoudln't produce a warning: diff --git a/tests/rustdoc-ui/doctest/non-local-defs-impl.stdout b/tests/rustdoc-ui/doctest/non-local-defs-impl.stdout index 27797e22f8ecb..f39d2c2608b88 100644 --- a/tests/rustdoc-ui/doctest/non-local-defs-impl.stdout +++ b/tests/rustdoc-ui/doctest/non-local-defs-impl.stdout @@ -1,24 +1,23 @@ running 2 tests test $DIR/non-local-defs-impl.rs - doctest (line 13) - compile ... FAILED -test $DIR/non-local-defs-impl.rs - doctest (line 22) - compile ... ok +test $DIR/non-local-defs-impl.rs - doctest (line 25) - compile ... ok failures: ---- $DIR/non-local-defs-impl.rs - doctest (line 13) stdout ---- error: non-local `impl` definition, `impl` blocks should be written at the same level as their item - --> $DIR/non-local-defs-impl.rs:18:1 + --> $DIR/non-local-defs-impl.rs:20:5 | -LL | impl Trait for &Local {} - | ^^^^^-----^^^^^------ - | | | - | | `&'_ Local` is not local - | | help: remove `&` to make the `impl` local - | `Trait` is not local +LL | fn foo() { + | -------- move the `impl` block outside of this function `foo` and up 3 bodies +LL | impl Trait for &Local {} + | ^^^^^-----^^^^^^----- + | | | + | | `Local` is not local + | `Trait` is not local | - = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` - = help: make this doc-test a standalone test with its own `fn main() { ... }` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue note: the lint level is defined here --> $DIR/non-local-defs-impl.rs:11:9