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

Migrate rustc_mir_build diagnostics #100854

Closed

Conversation

lunabunja
Copy link
Contributor

This PR migrates rustc_mir_build to use translatable diagnostics
@rustbot label +A-translation
r? rust-lang/diagnostics

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 21, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 21, 2022
@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja mentioned this pull request Aug 22, 2022
84 tasks
@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from 9b7b2cf to fc79d28 Compare August 22, 2022 07:24
@davidtwco
Copy link
Member

r? @davidtwco

@rust-highfive rust-highfive assigned davidtwco and unassigned estebank Aug 23, 2022
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

This looks good to me, one question..

compiler/rustc_mir_build/src/lib.rs Show resolved Hide resolved
@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch 2 times, most recently from b7d514f to ed1e9bb Compare August 24, 2022 07:59
@davidtwco davidtwco 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 24, 2022
@davidtwco
Copy link
Member

Use @rustbot ready when you're looking for a review :)

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from b2fa07a to bed1132 Compare August 24, 2022 17:17
@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from bed1132 to e7a4a79 Compare August 25, 2022 07:04
@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from 74b15df to c9d8bf6 Compare August 28, 2022 18:21
@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch 3 times, most recently from ad407f2 to 3a1e207 Compare August 29, 2022 08:40
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

Still looks good, I assume you're still working on it as the PR is a draft, nice work!

@lunabunja
Copy link
Contributor Author

Thank you, and yes I'm still working actively on this. There are more pattern diagnostics than I imagined at first. Also I've been committing most diagnostics separately, should I squash them or keep them this way?

@davidtwco
Copy link
Member

Thank you, and yes I'm still working actively on this. There are more pattern diagnostics than I imagined at first. Also I've been committing most diagnostics separately, should I squash them or keep them this way?

Either is fine :)

@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from 0e1dd82 to 5cb7e4f Compare September 1, 2022 09:39
@rust-log-analyzer

This comment has been minimized.

@lunabunja lunabunja force-pushed the mir_build_diagnostic_migration branch from 5cb7e4f to 3e527aa Compare September 1, 2022 10:57
@lunabunja
Copy link
Contributor Author

I've hit a problem where the most recent subdiagnostic's arguments "shadow" the previous ones (this was previously mentioned in Zulip) while migrating rustc_mir_build and it also looks like a lot of the diagnostics not yet migrated in rustc_mir_build depend on lists

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs stdout ----
diff of stderr:

53    | |
54 LL | |
55 LL | |         ref mut b,
-    | |         --------- another mutable borrow, by `b`, occurs here
+    | |         --------- another mutable borrow, by `c`, occurs here
57 LL | |         [
58 LL | |             ref mut c,
59    | |             --------- another mutable borrow, by `c`, occurs here
60 LL | |             ref mut d,
60 LL | |             ref mut d,
-    | |             --------- another mutable borrow, by `d`, occurs here
+    | |             --------- another mutable borrow, by `c`, occurs here
62 LL | |             ref e,
63    | |             ----- also borrowed as immutable, by `e`, here
64 LL | |         ]
75    | |
76 LL | |
77 LL | |             ref mut b,
77 LL | |             ref mut b,
-    | |             --------- another mutable borrow, by `b`, occurs here
+    | |             --------- another mutable borrow, by `c`, occurs here
79 LL | |             [
80 LL | |                 ref mut c,
81    | |                 --------- another mutable borrow, by `c`, occurs here
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
82 LL | |                 ref mut d,
82 LL | |                 ref mut d,
-    | |                 --------- another mutable borrow, by `d`, occurs here
+    | |                 --------- another mutable borrow, by `c`, occurs here
84 LL | |                 ref e,
85    | |                 ----- also borrowed as immutable, by `e`, here
86 LL | |             ]

The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice/borrowck-pat-ref-mut-twice.stderr
To update references, rerun the tests and pass the `--bless` flag
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice/auxiliary"
stdout: none
--- stderr -------------------------------
error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         ---------^^^---------
   |         |           |
   |         |           another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         ---------^^^---------
   |         |           |
   |         |           another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         ---------^^^---------
   |         |           |
   |         |           another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         ---------^^^---------
   |         |           |
   |         |           another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         ---------^^^---------
   |         |           |
   |         |           another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
LL |       let ref mut a @ (
   |           ^--------
   |           |
   |           |
   |  _________first mutable borrow, by `a`, occurs here
   | |
LL | |     //~^ ERROR cannot borrow value as mutable more than once at a time
LL | |         ref mut b,
   | |         --------- another mutable borrow, by `c`, occurs here
LL | |         [
LL | |             ref mut c,
   | |             --------- another mutable borrow, by `c`, occurs here
LL | |             ref mut d,
   | |             --------- another mutable borrow, by `c`, occurs here
LL | |             ref e,
   | |             ----- also borrowed as immutable, by `e`, here
LL | |         ]
LL | |     ) = (U, [U, U, U]);


error: cannot borrow value as mutable more than once at a time
   |
LL |       let ref mut a @ (
   |           ^--------
   |           |
   |           |
   |  _________first mutable borrow, by `a`, occurs here
   | |
LL | |         //~^ ERROR cannot borrow value as mutable more than once at a time
LL | |             ref mut b,
   | |             --------- another mutable borrow, by `c`, occurs here
LL | |             [
LL | |                 ref mut c,
   | |                 --------- another mutable borrow, by `c`, occurs here
LL | |                 ref mut d,
   | |                 --------- another mutable borrow, by `c`, occurs here
LL | |                 ref e,
   | |                 ----- also borrowed as immutable, by `e`, here
LL | |             ]
LL | |         ) = (u(), [u(), u(), u()]);

error: borrow of moved value
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:64:9
   |
   |
LL |     let a @ (ref mut b, ref mut c) = (U, U);
   |         -^^^^---------^^---------^
   |         |    |          value borrowed here after move
   |         |    value borrowed here after move
   |         value moved into `a` here
   |         value moved into `a` here
   |         move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait
error: borrow of moved value
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:67:9
   |
   |
LL |     let a @ (b, [c, d]) = &mut val; // Same as ^--
   |         -^^^^-^^^-^^-^^
   |         |    |   |  |
   |         |    |   |  value borrowed here after move
   |         |    value borrowed here after move
   |         value moved into `a` here
   |         value moved into `a` here
   |         move occurs because `a` has type `&mut (U, [U; 2])` which does not implement the `Copy` trait
error: borrow of moved value
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:70:9
   |
   |
LL |     let a @ &mut ref mut b = &mut U;
   |         -^^^^^^^^---------
   |         |        value borrowed here after move
   |         value moved into `a` here
   |         move occurs because `a` has type `&mut U` which does not implement the `Copy` trait


error: borrow of moved value
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:72:9
   |
LL |     let a @ &mut (ref mut b, ref mut c) = &mut (U, U);
   |         -^^^^^^^^^---------^^---------^
   |         |         |          value borrowed here after move
   |         |         value borrowed here after move
   |         value moved into `a` here
   |         value moved into `a` here
   |         move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               another mutable borrow, by `b`, occurs here
   |                                     first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               another mutable borrow, by `b`, occurs here
   |                                     first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               another mutable borrow, by `b`, occurs here
   |                                     first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              another mutable borrow, by `b`, occurs here
   |         first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               another mutable borrow, by `b`, occurs here
   |                                     first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     fn f1(ref mut a @ ref mut b: U) {}
   |           ---------^^^---------
   |           |           |
   |           |           another mutable borrow, by `b`, occurs here
   |           first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     fn f2(ref mut a @ ref mut b: U) {}
   |           ---------^^^---------
   |           |           |
   |           |           another mutable borrow, by `b`, occurs here
   |           first mutable borrow, by `a`, occurs here

error: cannot borrow value as mutable more than once at a time
   |
LL |           ref mut a @ [
   |           ^--------
   |           |
   |           |
   |  _________first mutable borrow, by `a`, occurs here
   | |
LL | |         //~^ ERROR cannot borrow value as mutable more than once at a time
LL | |             [ref b @ .., _],
   | |              ---------- also borrowed as immutable, by `b`, here
LL | |             [_, ref mut mid @ ..],
   | |                 ---------------- another mutable borrow, by `mid`, occurs here
LL | |             ..,
LL | |             [..],
LL | |         ] : [[U; 4]; 5]


error: cannot borrow value as mutable more than once at a time
   |
   |
LL |     fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
   |                      ---------^^^-------------
   |                      |           |           also moved into `c` here
   |                      |           |           also moved into `c` here
   |                      |           another mutable borrow, by `b`, occurs here
   |                      first mutable borrow, by `a`, occurs here
error: cannot move out of value because it is borrowed
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:21:34
   |
   |
LL |     fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
   |                                  ---------^^^-
   |                                  |           value moved into `c` here
   |                                  |           value moved into `c` here
   |                                  value borrowed, by `b`, here

error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         |           |
   |         |           |
   |         |           first mutable borrow occurs here
   |         second mutable borrow occurs here
LL |     drop(b);
   |          - first borrow later used here


error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |     let ref mut a @ ref mut b = U;
   |         |           |
   |         |           |
   |         |           first mutable borrow occurs here
   |         second mutable borrow occurs here
...
LL |     *b = U;


error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              second mutable borrow occurs here
   |         first mutable borrow occurs here
...
LL |             *a = Err(U);


error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               second mutable borrow occurs here
   |                                     first mutable borrow occurs here
...
LL |             *a = Err(U);


error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |         |              |
   |         |              |
   |         |              second mutable borrow occurs here
   |         first mutable borrow occurs here
LL |             drop(a);
   |                  - first borrow later used here


error[E0499]: cannot borrow value as mutable more than once at a time
   |
   |
LL |         ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => {
   |                                     |               |
   |                                     |               |
   |                                     |               second mutable borrow occurs here
   |                                     first mutable borrow occurs here
LL |             drop(a);
   |                  - first borrow later used here

error[E0382]: borrow of moved value
error[E0382]: borrow of moved value
  --> /checkout/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.rs:21:34
   |
LL |     fn f4_also_moved(ref mut a @ ref mut b @ c: U) {}
   |                      |           |           |
   |                      |           |           value moved here
   |                      |           value borrowed here after move
   |                      move occurs because value has type `U`, which does not implement the `Copy` trait

@bors
Copy link
Contributor

bors commented Sep 6, 2022

☔ The latest upstream changes (presumably #101479) made this pull request unmergeable. Please resolve the merge conflicts.

@davidtwco
Copy link
Member

I've hit a problem where the most recent subdiagnostic's arguments "shadow" the previous ones (this was previously mentioned in Zulip) while migrating rustc_mir_build and it also looks like a lot of the diagnostics not yet migrated in rustc_mir_build depend on lists

We'll just need to leave this untranslated for now, I'm afraid, so feel free to skip them and leave #[allow(..)] attributes for the lints (or if there really are a lot, just don't add the #[deny(..)]).

@davidtwco
Copy link
Member

Oh, and apologies for the delay in responding, don't know how I managed to miss this one for six days.

@lunabunja
Copy link
Contributor Author

It happens, I'll quickly resolve everything then

@Noratrieb
Copy link
Member

Hi, I've seen you changed some diagnostic structs in your PR. After #103345, the way we refer to fluent messages changed. They are now in a flat namespace with the same identifier as in the fluent file. For example, parser::cool_thing is now parser_cool_thing and parser::suggestion just suggestion.
You should rebase to the latest master and change your fluent message references as described above. Thanks!

@davidtwco
Copy link
Member

@AsyaTheAbove are you still able to work on this?

@lunabunja
Copy link
Contributor Author

lunabunja commented Nov 2, 2022

@AsyaTheAbove are you still able to work on this?

not really, I've been busy recently and even when I do get to work on it I have a few issues with my development environment that I've been struggling with

@mejrs
Copy link
Contributor

mejrs commented Nov 14, 2022

Does this only need a rebase? It seems good to go otherwise.

@davidtwco
Copy link
Member

Closing in favour of #104417.

@davidtwco davidtwco closed this Nov 15, 2022
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 23, 2022
Migrate rustc_mir_build diagnostics

Rebases rust-lang#100854

~~The remaining issue is how to better resolve rust-lang@72bea68af4ee2a41c44998916f6a789163f12e7d~~

~~The diagnostic macros seems to generate a broken diagnostic, and I couldn't figure out how to manually format the fluent message, so I hardcoded the format string for now. I'd like pointers to a better fix for this.~~

Also, I'm not 100% sure I didn't mess up a rebase somewhere 🙂

r? `@davidtwco`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Dec 9, 2022
Migrate rustc_mir_build diagnostics

Rebases rust-lang#100854

~~The remaining issue is how to better resolve rust-lang@72bea68af4ee2a41c44998916f6a789163f12e7d~~

~~The diagnostic macros seems to generate a broken diagnostic, and I couldn't figure out how to manually format the fluent message, so I hardcoded the format string for now. I'd like pointers to a better fix for this.~~

Also, I'm not 100% sure I didn't mess up a rebase somewhere 🙂

r? `@davidtwco`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Dec 11, 2022
Migrate rustc_mir_build diagnostics

Rebases rust-lang#100854

~~The remaining issue is how to better resolve rust-lang@72bea68af4ee2a41c44998916f6a789163f12e7d~~

~~The diagnostic macros seems to generate a broken diagnostic, and I couldn't figure out how to manually format the fluent message, so I hardcoded the format string for now. I'd like pointers to a better fix for this.~~

Also, I'm not 100% sure I didn't mess up a rebase somewhere 🙂

r? ``@davidtwco``
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Dec 11, 2022
Migrate rustc_mir_build diagnostics

Rebases rust-lang#100854

~~The remaining issue is how to better resolve rust-lang@72bea68af4ee2a41c44998916f6a789163f12e7d~~

~~The diagnostic macros seems to generate a broken diagnostic, and I couldn't figure out how to manually format the fluent message, so I hardcoded the format string for now. I'd like pointers to a better fix for this.~~

Also, I'm not 100% sure I didn't mess up a rebase somewhere 🙂

r? ```@davidtwco```
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2022
Migrate rustc_mir_build diagnostics

Rebases rust-lang#100854

~~The remaining issue is how to better resolve rust-lang@72bea68af4ee2a41c44998916f6a789163f12e7d~~

~~The diagnostic macros seems to generate a broken diagnostic, and I couldn't figure out how to manually format the fluent message, so I hardcoded the format string for now. I'd like pointers to a better fix for this.~~

Also, I'm not 100% sure I didn't mess up a rebase somewhere 🙂

r? `@davidtwco`
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 S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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