Diagnostic translation for borrow_check:errors #112237
Diagnostic translation for borrow_check:errors #112237sladyn98 wants to merge 3 commits intorust-lang:masterfrom
borrow_check:errors #112237Conversation
| err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); | ||
| err.span_label(span, format!("use of borrowed {}", borrow_desc)); | ||
| err | ||
| create_err(CannotUseWhenMutablyBorrowed { span, desc }) |
There was a problem hiding this comment.
@davidtwco Not sure how to use the create_err here after creating the struct
There was a problem hiding this comment.
Use self.infcx.tcx.sess.create_err, create_err isn't a free-standing function :)
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Do we have to bless these tests or fix them manually : ) |
|
These tests are crashing because of a bug in this PR: |
|
Whoops, wrong button. |
| pub(crate) struct CannotUseWhenMutablyBorrowed<'a> { | ||
| #[primary_span] | ||
| pub span: Span, | ||
| #[label] |
There was a problem hiding this comment.
There is no corresponding label in the ftl file.
There was a problem hiding this comment.
I am still trying to understand how to use them, would just including the rest of the parameters under primary span work ? I can then just put their placeholders in the ftl file. I read the documentation but I was not really sure how to incorporate them in the .ftl file
There was a problem hiding this comment.
Adding a #[label] is a reference to a .label = <msg> attribute on the borrowck_cannot_use_when_mutably_borrowed message, so it should have something like:
borrowck_cannot_use_when_mutably_borrowed = cannot use `{$desc}` when mutably borrowed
.label = <msg>
| self.infcx.tcx.sess.create_err(CannotUseWhenMutablyBorrowed { | ||
| span, | ||
| E0503, | ||
| "cannot use {} because it was mutably borrowed", |
There was a problem hiding this comment.
Why did you change the wording from here to "cannot use {$desc} when mutably borrowed"?
There was a problem hiding this comment.
I read some of the examples in the ftl file and there were certain placeholders there so since desc would be put in here in the message I thought {desc} would be also substituted in the ftl file from the struct passed in.
There was a problem hiding this comment.
I might be completely wrong, feel free to correct me
There was a problem hiding this comment.
I meant, why did you change the wording? The old phrasing was "because it was mutably borrowed", the new phrasing is "when mutably borrowed"? I think we should separate diagnostics migration from tweaks of wording.
| err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); | ||
| err.span_label(span, format!("use of borrowed {}", borrow_desc)); |
There was a problem hiding this comment.
These labels weren't added to the ftl file, where did they go?
There was a problem hiding this comment.
Should they be added as separate messages with their labels something like this
borrowck_cannot_use_when_mutably_borrowed = {$borrow_span} is borrowed here
There was a problem hiding this comment.
You should preserve all the error messages as much as possible
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
@rustbot author |
|
☔ The latest upstream changes (presumably #114116) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@sladyn98 any updates on this? |
|
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Migrate diagnostics to use the struct derive and be translatable.
r? @davidtwco