Skip to content
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 pretty HIR for anon consts in diagnostics #123926

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

compiler-errors
Copy link
Member

This removes the NoAnn printer which skips over nested bodies altogether, which is confusing, and requires users of {ty|qpath|pat}_to_string to pass in &tcx which now impleemnts hir_pretty::PpAnn.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 14, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 14, 2024

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@@ -0,0 +1,9 @@
error[E0533]: expected value, found struct variant `Struct<0>::Variant`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to print Struct<>::Variant

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Apr 14, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@@ -24,7 +24,9 @@ LL - let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
LL + let str::as_bytes;
|

error[E0533]: expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes`
error[E0533]: expected unit struct, unit variant or constant, found associated function `str<{
fn str() { let (/*ERROR*/); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly this seems to be the first time we leak pp's /*ERROR*/ in error messages.
At least according to rg -F '/*ERROR*/' -g 'tests/**/*.stderr'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For follow-up: Would it make sense to only print function signatures in const items in types instead of including their body? What is the output with

fn main() {
let str::<{fn str<T>() { let _; }}, T>::as_bytes;
}

@estebank
Copy link
Contributor

I don't expect people to actually get anon consts like that unless they're fuzzing

Nice of you to make a distinction between our users and fuzzers, I'm not so sure that an edge case will be hit by one and not the other ^_^

@bors r+

@bors
Copy link
Contributor

bors commented Apr 15, 2024

📌 Commit d5ba4a6 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 15, 2024
@compiler-errors
Copy link
Member Author

@bors r- land after other pr

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 15, 2024
@compiler-errors
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Apr 15, 2024

📌 Commit 2beb6a4 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 15, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#123016 (Remove `TypeVariableOriginKind` and `ConstVariableOriginKind`)
 - rust-lang#123462 (Cleanup: Rename `ModSep` to `PathSep`)
 - rust-lang#123603 (Don't even parse an intrinsic unless the feature gate is enabled)
 - rust-lang#123926 (Fix pretty HIR for anon consts in diagnostics)
 - rust-lang#123973 (crashes: readme: add reminder to add Fixes #abcde to prs to automatically close issues.)
 - rust-lang#123984 (sanitizers: Add rustc_sanitizers to triagebot.toml)
 - rust-lang#123989 (Just use `type_dependent_def_id` to figure out what the method is for an expr)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1069ad3 into rust-lang:master Apr 16, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
Rollup merge of rust-lang#123926 - compiler-errors:no-ann, r=estebank

Fix pretty HIR for anon consts in diagnostics

This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 18, 2024
Fix pretty HIR for anon consts in diagnostics

This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`.

There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh.

r? estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants