-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix impl block in const expr #104889
Merged
bors
merged 6 commits into
rust-lang:master
from
GuillaumeGomez:fix-impl-block-in-const-expr
Dec 22, 2022
Merged
Fix impl block in const expr #104889
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cdfc505
Fix missing const expression items visit
GuillaumeGomez 9cce0bc
Add regression test for impl blocks in const expr
GuillaumeGomez 9c46173
Update newly failing UI tests
GuillaumeGomez eb93d1b
Improve code readability
GuillaumeGomez a9d582f
Speed up execution a bit by removing some walks
GuillaumeGomez a954d63
Improve code
GuillaumeGomez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
4 changes: 1 addition & 3 deletions
4
src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.rs
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/test/rustdoc-ui/infinite-recursive-type-impl-trait-return.stderr
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0072]: recursive type `DEF_ID` has infinite size | ||
--> $DIR/infinite-recursive-type-impl-trait-return.rs:7:5 | ||
| | ||
LL | enum E { | ||
| ^^^^^^ | ||
LL | This(E), | ||
| - recursive without indirection | ||
| | ||
help: insert some indirection (e.g., a `DEF_ID`) to break the cycle | ||
| | ||
LL | This(Box<E>), | ||
| ++++ + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `DEF_ID`. |
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/test/rustdoc-ui/infinite-recursive-type-impl-trait.stderr
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0072]: recursive type `f::E` has infinite size | ||
--> $DIR/infinite-recursive-type-impl-trait.rs:2:5 | ||
| | ||
LL | enum E { | ||
| ^^^^^^ | ||
LL | V(E), | ||
| - recursive without indirection | ||
| | ||
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | ||
| | ||
LL | V(Box<E>), | ||
| ++++ + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0072`. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracing the history this essentially appears to be a regression test for #75100 (added in #75127). Making this fail may break some docs that rely on function bodys not being fully type-checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@jyn514 might have more insight whether this specific test came from some real-world code, or is ok to regress).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erf, that'd be pretty bad if some docs rely on that (meaning if this PR introduces regression for them). At the very least, we should run a crater run to see what the impact is. If there is none, maybe we can consider changing this behaviour? I'd really prefer to avoid rewriting the
hir::Visitor
if possible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I should have looked at the original test impl. It was added as a failing test then got changed to
check-pass
in #102890. So seems likely that it's not relied on in the wild as it isn't yet in a stable release.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But your concerns remain completely valid. I think a crater run should definitely be run if we agree on this PR before r+ing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not in a stable release, then it shouldn't be a problem.
However, this PR changes other long-standing behaviors, such as causing lints to run on doc comments of nested functions. Probably a lot more crates rely on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what should we do here? Is it ok and then we run a crater or this approach isn't the right one and we close this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds right - the original test was just to make sure rustdoc didn't ICE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be okay with cratering and calling it good. Rust's stability promise reserves the right to change lints, which is what broke rust-lang/rust, so as long as that's the only thing that happened, it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll start a crater run soon then.