-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use crate::session_diagnostics::CannotUseWhenMutablyBorrowed; | ||
use rustc_errors::{ | ||
struct_span_err, DiagnosticBuilder, DiagnosticId, DiagnosticMessage, ErrorGuaranteed, MultiSpan, | ||
}; | ||
|
@@ -29,17 +30,18 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> { | |
borrow_span: Span, | ||
borrow_desc: &str, | ||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { | ||
let mut err = struct_span_err!( | ||
self, | ||
span, | ||
E0503, | ||
"cannot use {} because it was mutably borrowed", | ||
desc, | ||
); | ||
|
||
err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); | ||
err.span_label(span, format!("use of borrowed {}", borrow_desc)); | ||
Comment on lines
-40
to
-41
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should preserve all the error messages as much as possible |
||
err | ||
create_err(CannotUseWhenMutablyBorrowed { span, desc }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
// let mut err = struct_span_err!( | ||
// self, | ||
// span, | ||
// E0503, | ||
// "cannot use {} because it was mutably borrowed", | ||
// desc, | ||
// ); | ||
|
||
// err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc)); | ||
// err.span_label(span, format!("use of borrowed {}", borrow_desc)); | ||
// err | ||
} | ||
|
||
pub(crate) fn cannot_mutably_borrow_multiply( | ||
|
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.