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

rustc_parse: diagnostics migration, v4 #105670

Merged
merged 11 commits into from
Feb 2, 2023

Conversation

Xiretza
Copy link
Contributor

@Xiretza Xiretza commented Dec 13, 2022

This is all the rustc_parse migrations I have in store right now; unfortunately life is pretty busy right now, so I won't be able to do much more in the near future.

cc #100717

r? @davidtwco

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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 Dec 13, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 13, 2022

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

rustc_macros::diagnostics was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

@bors

This comment was marked as resolved.

Comment on lines 1 to 8
// #60115

mod foo {
pub bar();
//~^ ERROR missing `fn` or `struct` for function or struct definition
}

fn main() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were these tests deleted?

Copy link
Contributor Author

@Xiretza Xiretza Dec 27, 2022

Choose a reason for hiding this comment

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

They weren't deleted, just changed and renamed. I've split the changing and renaming into different commits to ease reviewing.

compiler/rustc_errors/src/diagnostic.rs Outdated Show resolved Hide resolved
Comment on lines 440 to 439
if let FieldInnerTy::Vec(_) = info.ty {
throw_invalid_attr!(attr, &meta, |diag| diag
.help("#[suggestion_*(...)] applied to `Vec` field is ambiguous"));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What do these changes to the macros do? Also, it might be nice to have that message be a bit more helpful, like: "it's not supported at all" or "try x instead".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've improved the message. The problem is that #[suggestion(code = "foo")] spans: Vec<Span> could either mean:

for span in spans {
    span_suggestion(span, "foo");
}

or:

multipart_suggestion(spans.into_iter().map(|span| (span, "foo")));

In order to avoid ambiguity, a Subdiagnostic must be used (either a Vec of #[suggestion] subdiagnostics, or a single #[multipart_suggestion] subdiagnostic).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the change is not "forbid x" but "give a better error if x happens"? Thanks for this change, these sort of papercuts have been annoying me in the past 👍

Please add this case to one of the files in https://github.com/rust-lang/rust/tree/master/src/test/ui-fulldeps/session-diagnostic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is "forbid x", but previously "x" was the first behaviour, which, while technically a correct interpretation, is probably not what most people would want. This behaviour wasn't actually used anywhere, it's just a preventative measure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying, that seems like a good idea.

compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
@Xiretza Xiretza force-pushed the rustc_parse-diagnostics-4 branch 4 times, most recently from 671c276 to 7843eb0 Compare December 27, 2022 22:32
@bors

This comment was marked as resolved.

Copy link
Contributor

@mejrs mejrs left a comment

Choose a reason for hiding this comment

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

(now to wait for someone with r+ permissions to drive by 😅 )

@davidtwco
Copy link
Member

Apologies for the delay in reviewing this. Thanks for your work and thanks for @mejrs for the initial review.

@bors r+

@bors
Copy link
Contributor

bors commented Jan 7, 2023

📌 Commit ddfdcbe5e279ee76e618c6f29f50953abb537527 has been approved by davidtwco

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 Jan 7, 2023
@bors

This comment was marked as resolved.

@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 Jan 8, 2023
@Xiretza
Copy link
Contributor Author

Xiretza commented Jan 8, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 8, 2023
The check previously matched this, and suggested adding a missing
`struct`:

pub Foo(...):

It was probably intended to match this instead (semicolon instead of
colon):

pub Foo(...);
This is required in order to support translatable diagnostics.
#[derive(Subdiagnostic)] does not allow multiple subdiagnostics on one
variant, as in NonItemInItemListSub::Other.
@Xiretza
Copy link
Contributor Author

Xiretza commented Feb 1, 2023

@rustbot ready

@estebank
Copy link
Contributor

estebank commented Feb 1, 2023

@bors r=davidtwco

@bors
Copy link
Contributor

bors commented Feb 1, 2023

📌 Commit 0d0d369 has been approved by davidtwco

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Feb 1, 2023

🌲 The tree is currently closed for pull requests below priority 50. This pull request will be tested once the tree is reopened.

@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 Feb 1, 2023
@bors
Copy link
Contributor

bors commented Feb 2, 2023

⌛ Testing commit 0d0d369 with merge 131f0c6...

@bors
Copy link
Contributor

bors commented Feb 2, 2023

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 131f0c6 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (131f0c6): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.3% [1.5%, 3.2%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-6.2%, -2.0%] 2
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic merged-by-bors This PR was explicitly merged by bors. 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.

9 participants