about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-06-28 17:25:20 +0200
committerUrgau <urgau@numericable.fr>2024-09-23 10:01:59 +0200
commit2423e9e2441dec751588220c2f0047880c0bcb32 (patch)
tree6dd3be3c7c4b32e450cdbc89a1a28cfbe201c6dd
parent9195d65725139f8415e223ee2488ae7347305e56 (diff)
downloadrust-2423e9e2441dec751588220c2f0047880c0bcb32.tar.gz
rust-2423e9e2441dec751588220c2f0047880c0bcb32.zip
Update rustdoc doctest non_local_defs impl test
-rw-r--r--tests/rustdoc-ui/doctest/non-local-defs-impl.rs5
-rw-r--r--tests/rustdoc-ui/doctest/non-local-defs-impl.stdout19
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 37c80bc1f27..b1ab5323a2b 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 27797e22f8e..f39d2c2608b 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 <https://github.com/rust-lang/rust/issues/120363>
 note: the lint level is defined here
   --> $DIR/non-local-defs-impl.rs:11:9