Suggest using a standalone doctest for non-local impl defs#126422
Merged
bors merged 2 commits intorust-lang:masterfrom Jun 19, 2024
Merged
Suggest using a standalone doctest for non-local impl defs#126422bors merged 2 commits intorust-lang:masterfrom
bors merged 2 commits intorust-lang:masterfrom
Conversation
Urgau
commented
Jun 13, 2024
| | | ||
| = 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() { ... }` |
Member
Author
There was a problem hiding this comment.
This is the real difference, before it generated something like this:
help: move the `impl` block outside of this function `_doctest_main_src_lib_rs_3_0` and up 2 bodies
--> src/lib.rs:4:38
|
4 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_3_0() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
6 | struct Local;
| ------------ may need to be moved as well
This comment has been minimized.
This comment has been minimized.
lqd
reviewed
Jun 13, 2024
Member
|
I wonder, would it be beneficial/possible to have a machine-applicable suggestion here? |
3c57761 to
c44d3cb
Compare
Member
Author
Beneficial, yes. Possible, not currently, since when compiling doctests Footnotes
|
This comment has been minimized.
This comment has been minimized.
Member
|
(cc #126430 on that last failure) |
c44d3cb to
94c2821
Compare
Member
|
@bors r+ rollup |
Collaborator
GuillaumeGomez
added a commit
to GuillaumeGomez/rust
that referenced
this pull request
Jun 18, 2024
…r=fmease Suggest using a standalone doctest for non-local impl defs This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in rust-lang#124568. Fixes rust-lang#126339 r? `@fmease`
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 18, 2024
…llaumeGomez Rollup of 9 pull requests Successful merges: - rust-lang#123782 (Test that opaque types can't have themselves as a hidden type with incompatible lifetimes) - rust-lang#124580 (Suggest removing unused tuple fields if they are the last fields) - rust-lang#125852 (improve tip for inaccessible traits) - rust-lang#126422 (Suggest using a standalone doctest for non-local impl defs) - rust-lang#126427 (Rewrite `intrinsic-unreachable`, `sepcomp-cci-copies`, `sepcomp-inlining` and `sepcomp-separate` `run-make` tests to rmake.rs) - rust-lang#126493 (safe transmute: support non-ZST, variantful, uninhabited enums) - rust-lang#126572 (override user defined channel when using precompiled rustc) - rust-lang#126615 (Add `rustc-ice*` to `.gitignore`) - rust-lang#126632 (Replace `move||` with `move ||`) Failed merges: - rust-lang#126558 (hir_typeck: be more conservative in making "note caller chooses ty param" note) r? `@ghost` `@rustbot` modify labels: rollup
jieyouxu
added a commit
to jieyouxu/rust
that referenced
this pull request
Jun 19, 2024
…r=fmease Suggest using a standalone doctest for non-local impl defs This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in rust-lang#124568. Fixes rust-lang#126339 r? ``@fmease``
This was referenced Jun 19, 2024
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 19, 2024
Rollup of 10 pull requests Successful merges: - rust-lang#124135 (delegation: Implement glob delegation) - rust-lang#125078 (fix: break inside async closure has incorrect span for enclosing closure) - rust-lang#125293 (Place tail expression behind terminating scope) - rust-lang#126422 (Suggest using a standalone doctest for non-local impl defs) - rust-lang#126493 (safe transmute: support non-ZST, variantful, uninhabited enums) - rust-lang#126504 (Sync fuchsia test runner with clang test runner) - rust-lang#126558 (hir_typeck: be more conservative in making "note caller chooses ty param" note) - rust-lang#126586 (Add `@badboy` and `@BlackHoleFox` as Mac Catalyst maintainers) - rust-lang#126615 (Add `rustc-ice*` to `.gitignore`) - rust-lang#126632 (Replace `move||` with `move ||`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 19, 2024
Rollup merge of rust-lang#126422 - Urgau:doctest-impl-non-local-def, r=fmease Suggest using a standalone doctest for non-local impl defs This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in rust-lang#124568. Fixes rust-lang#126339 r? ```@fmease```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR tweaks the lint output of the
non_local_definitionslint to suggest using a standalone doctest instead of a moving theimpldef to an impossible place as was already done withmacro_rules!case in #124568.Fixes #126339
r? @fmease