Skip to content

Commit 35ef5c6

Browse files
authored
Rollup merge of rust-lang#96269 - davidtwco:diagnostic-translation-minor-changes, r=oli-obk
errors: minor translation-related changes - For one error in typeck, specifying "suggestion" as the attribute for the only suggestion is unnecessary, it's the default of the derive. - The documentation comment for the `SessionDiagnostic` derive is out-of-date, it should have been updated in rust-lang#95512. r? `@oli-obk`
2 parents d8fcf53 + f79d5e9 commit 35ef5c6

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

compiler/rustc_macros/src/session_diagnostic.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,41 @@ use std::collections::{BTreeSet, HashMap};
1616
/// # extern crate rust_middle;
1717
/// # use rustc_middle::ty::Ty;
1818
/// #[derive(SessionDiagnostic)]
19-
/// #[error(code = "E0505", slug = "move-out-of-borrow-error")]
19+
/// #[error(code = "E0505", slug = "borrowck-move-out-of-borrow")]
2020
/// pub struct MoveOutOfBorrowError<'tcx> {
2121
/// pub name: Ident,
2222
/// pub ty: Ty<'tcx>,
2323
/// #[primary_span]
24-
/// #[label = "cannot move out of borrow"]
24+
/// #[label]
2525
/// pub span: Span,
26-
/// #[label = "`{ty}` first borrowed here"]
27-
/// pub other_span: Span,
28-
/// #[suggestion(message = "consider cloning here", code = "{name}.clone()")]
29-
/// pub opt_sugg: Option<(Span, Applicability)>
26+
/// #[label = "first-borrow-label"]
27+
/// pub first_borrow_span: Span,
28+
/// #[suggestion(code = "{name}.clone()")]
29+
/// pub clone_sugg: Option<(Span, Applicability)>
3030
/// }
3131
/// ```
3232
///
33+
/// ```fluent
34+
/// move-out-of-borrow = cannot move out of {$name} because it is borrowed
35+
/// .label = cannot move out of borrow
36+
/// .first-borrow-label = `{$ty}` first borrowed here
37+
/// .suggestion = consider cloning here
38+
/// ```
39+
///
3340
/// Then, later, to emit the error:
3441
///
3542
/// ```ignore (pseudo-rust)
3643
/// sess.emit_err(MoveOutOfBorrowError {
3744
/// expected,
3845
/// actual,
3946
/// span,
40-
/// other_span,
41-
/// opt_sugg: Some(suggestion, Applicability::MachineApplicable),
47+
/// first_borrow_span,
48+
/// clone_sugg: Some(suggestion, Applicability::MachineApplicable),
4249
/// });
4350
/// ```
51+
///
52+
/// See rustc dev guide for more examples on using the `#[derive(SessionDiagnostic)]`:
53+
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/sessiondiagnostic.html>
4454
pub fn session_diagnostic_derive(s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
4555
// Names for the diagnostic we build and the session we build it from.
4656
let diag = format_ident!("diag");

compiler/rustc_typeck/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
134134
#[primary_span]
135135
#[label]
136136
pub span: Span,
137-
#[suggestion_verbose(message = "suggestion", code = "{ty}")]
137+
#[suggestion_verbose(code = "{ty}")]
138138
pub opt_sugg: Option<(Span, Applicability)>,
139139
}
140140

0 commit comments

Comments
 (0)