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

most borrowck diagnostic migration #101686

Closed
wants to merge 5 commits into from
Closed

Conversation

AndyJado
Copy link
Contributor

Covered the simple cases for the whole crate, looking for merge. Then I can focus on the nested ones, rebase is becoming rather slow.

@rustbot label +S-waiting-on-author -S-waiting-on-review

@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 Sep 11, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 11, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2022
@AndyJado
Copy link
Contributor Author

r? @davidtwco

@AndyJado AndyJado marked this pull request as ready for review September 11, 2022 13:25
@rustbot
Copy link
Collaborator

rustbot commented Sep 11, 2022

rustc_error_messages was changed

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

@davidtwco davidtwco mentioned this pull request Sep 12, 2022
84 tasks
compiler/rustc_borrowck/src/borrowck_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/borrowck_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/borrowck_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/borrowck_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/diagnostics/region_name.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/region_infer/opaque_types.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/region_infer/opaque_types.rs Outdated Show resolved Hide resolved
@davidtwco
Copy link
Member

I'd also like it if you could squash some of your commits because these aren't particularly meaningful to anyone reading them later to understand the changes you've made and why.

@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor

Please run x.py fmt

borrow_desc: br_desc,
local_name,
type_desc: &type_desc,
dtor_desc,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Except english words, There are also variables passed in dtor_desc, which would be better:

  • add a field for the diagnose struct
  • make dtor_desc a subdiag
  • some flunet magic I should go check out

Copy link
Member

Choose a reason for hiding this comment

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

Probably a subdiagnostic.

@AndyJado AndyJado marked this pull request as ready for review September 21, 2022 10:38
@davidtwco davidtwco removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 22, 2022
@@ -54,7 +54,311 @@ borrowck_returned_lifetime_wrong =
{$mir_def_name} was supposed to return data with lifetime `{$outlived_fr_name}` but it is returning data with lifetime `{$fr_name}`

borrowck_returned_lifetime_short =
{$category_desc}requires that `{$free_region_name}` must outlive `{$outlived_fr_name}`
{$category ->
[Assignment] assignment {""}
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to end all of these with an empty string? I assume you don't want to just add a space after the selector because then the other case would have two leading spaces? Maybe we could trim translated messages to avoid this, that's probably sensible anyway.

[OpaqueType] opaque type {""}
[ClosureUpvar] closure capture {""}
[Usage] this usage {""}
*[other] {""}
Copy link
Member

Choose a reason for hiding this comment

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

How practical do you think it would be to separate these out into variants of a type rather than using string-based dispatching?

borrow_desc: br_desc,
local_name,
type_desc: &type_desc,
dtor_desc,
Copy link
Member

Choose a reason for hiding this comment

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

Probably a subdiagnostic.

@bors

This comment was marked as resolved.

@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)
Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Check compiletest suite=ui-fulldeps mode=ui (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 71 tests
Some tests failed in compiletest suite=ui-fulldeps mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
F....F.................i...............................................

---- [ui] src/test/ui-fulldeps/dropck-tarena-unsound-drop.rs stdout ----
diff of stderr:


7    | -
8    | |
9    | `arena` dropped here while still borrowed
-    | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `TypedArena`
+    | borrow might be used here, when `arena` is dropped and runs the destructor for type `TypedArena`
12 error: aborting due to previous error
13 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/dropck-tarena-unsound-drop/dropck-tarena-unsound-drop.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args dropck-tarena-unsound-drop.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-fulldeps/dropck-tarena-unsound-drop.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-fulldeps/dropck-tarena-unsound-drop" "-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-fulldeps/dropck-tarena-unsound-drop/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0597]: `arena` does not live long enough
   |
   |
LL |     f(&arena);
   |       ^^^^^^ borrowed value does not live long enough
LL | } //~^ ERROR `arena` does not live long enough
   | |
   | |
   | `arena` dropped here while still borrowed
   | borrow might be used here, when `arena` is dropped and runs the destructor for type `TypedArena`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
------------------------------------------
------------------------------------------


---- [ui] src/test/ui-fulldeps/dropck-tarena-cycle-checked.rs stdout ----
diff of stderr:

7    | -
8    | |
9    | `arena` dropped here while still borrowed
-    | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `TypedArena`
+    | borrow might be used here, when `arena` is dropped and runs the destructor for type `TypedArena`
12 error: aborting due to previous error
13 



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui-fulldeps/dropck-tarena-cycle-checked/dropck-tarena-cycle-checked.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args dropck-tarena-cycle-checked.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-fulldeps/dropck-tarena-cycle-checked.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-fulldeps/dropck-tarena-cycle-checked" "-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-fulldeps/dropck-tarena-cycle-checked/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0597]: `arena` does not live long enough
   |
   |
LL |     f(&arena);
   |       ^^^^^^ borrowed value does not live long enough
LL | } //~^ ERROR `arena` does not live long enough
   | |
   | |
   | `arena` dropped here while still borrowed
   | borrow might be used here, when `arena` is dropped and runs the destructor for type `TypedArena`
error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
------------------------------------------

@bors
Copy link
Contributor

bors commented Oct 14, 2022

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

@AndyJado AndyJado marked this pull request as draft October 18, 2022 01:46
@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!

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.

Apologies for the delay in getting back to reviewing this.

Comment on lines +89 to 97
let case: ClosureConstructLabel;
let diff_span: Option<Span>;
if old_loan_span == new_loan_span {
err.span_label(
old_loan_span,
"closures are constructed here in different iterations of loop",
);
case = ClosureConstructLabel::Both { old_loan_span };
diff_span = None;
} else {
err.span_label(old_loan_span, "first closure is constructed here");
err.span_label(new_loan_span, "second closure is constructed here");
case = ClosureConstructLabel::First { old_loan_span };
diff_span = Some(new_loan_span);
}
Copy link
Member

Choose a reason for hiding this comment

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

let (case, diff_span) = if /* .. */ {
    /* .. */
} else {
    /* .. */
};

I think this would be tidier if it was written this way.


let loop_message = if location == move_out.source || move_site.traversed_back_edge {
", in previous iteration of loop"
"InLoop"
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better if we could avoid having strings like these and dispatching on them - it isn't easy for translators to know what possible values there are.

@@ -418,6 +414,7 @@ fn check_opaque_type_parameter_valid(
.into_iter()
.map(|i| tcx.def_span(opaque_generics.param_at(i, tcx).def_id))
.collect();
// FIXME(#100717) requires eager translation/list support
Copy link
Member

Choose a reason for hiding this comment

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

We have eager translation now.

@@ -7,7 +7,7 @@ LL | }
| -
| |
| `v` dropped here while still borrowed
| borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap`
| borrow might be used here, when `v` is dropped and runs the destructor for type `Wrap`
Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's much advantage to changing the message here.

@AndyJado
Copy link
Contributor Author

AndyJado commented Nov 4, 2022

I am closing this PR since it relies too much on string base dispatch and out-dated discussion.

I'll try to keep following PR clear and small like this one

@AndyJado AndyJado closed this Nov 4, 2022
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-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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants