-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Diagnostic translation for borrow_check:errors
#112237
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
Diagnostic translation for borrow_check:errors
#112237
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidtwco Not sure how to use the create_err here after creating the struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no corresponding label
in the ftl file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
span, | ||
E0503, | ||
"cannot use {} because it was mutably borrowed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change the wording from here to "cannot use {$desc}
when mutably borrowed"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be completely wrong, feel free to correct me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These labels weren't added to the ftl file, where did they go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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