Skip to content

Commit

Permalink
Update rustdoc doctest non_local_defs impl test
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Jul 9, 2024
1 parent ab9a51f commit 3100dfa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 4 additions & 1 deletion tests/rustdoc-ui/doctest/non-local-defs-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 9 additions & 10 deletions tests/rustdoc-ui/doctest/non-local-defs-impl.stdout
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3100dfa

Please # to comment.