mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rollup merge of #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 #95512. r? `@oli-obk`
This commit is contained in:
commit
35ef5c6e4c
@ -16,20 +16,27 @@ use std::collections::{BTreeSet, HashMap};
|
|||||||
/// # extern crate rust_middle;
|
/// # extern crate rust_middle;
|
||||||
/// # use rustc_middle::ty::Ty;
|
/// # use rustc_middle::ty::Ty;
|
||||||
/// #[derive(SessionDiagnostic)]
|
/// #[derive(SessionDiagnostic)]
|
||||||
/// #[error(code = "E0505", slug = "move-out-of-borrow-error")]
|
/// #[error(code = "E0505", slug = "borrowck-move-out-of-borrow")]
|
||||||
/// pub struct MoveOutOfBorrowError<'tcx> {
|
/// pub struct MoveOutOfBorrowError<'tcx> {
|
||||||
/// pub name: Ident,
|
/// pub name: Ident,
|
||||||
/// pub ty: Ty<'tcx>,
|
/// pub ty: Ty<'tcx>,
|
||||||
/// #[primary_span]
|
/// #[primary_span]
|
||||||
/// #[label = "cannot move out of borrow"]
|
/// #[label]
|
||||||
/// pub span: Span,
|
/// pub span: Span,
|
||||||
/// #[label = "`{ty}` first borrowed here"]
|
/// #[label = "first-borrow-label"]
|
||||||
/// pub other_span: Span,
|
/// pub first_borrow_span: Span,
|
||||||
/// #[suggestion(message = "consider cloning here", code = "{name}.clone()")]
|
/// #[suggestion(code = "{name}.clone()")]
|
||||||
/// pub opt_sugg: Option<(Span, Applicability)>
|
/// pub clone_sugg: Option<(Span, Applicability)>
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// ```fluent
|
||||||
|
/// move-out-of-borrow = cannot move out of {$name} because it is borrowed
|
||||||
|
/// .label = cannot move out of borrow
|
||||||
|
/// .first-borrow-label = `{$ty}` first borrowed here
|
||||||
|
/// .suggestion = consider cloning here
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// Then, later, to emit the error:
|
/// Then, later, to emit the error:
|
||||||
///
|
///
|
||||||
/// ```ignore (pseudo-rust)
|
/// ```ignore (pseudo-rust)
|
||||||
@ -37,10 +44,13 @@ use std::collections::{BTreeSet, HashMap};
|
|||||||
/// expected,
|
/// expected,
|
||||||
/// actual,
|
/// actual,
|
||||||
/// span,
|
/// span,
|
||||||
/// other_span,
|
/// first_borrow_span,
|
||||||
/// opt_sugg: Some(suggestion, Applicability::MachineApplicable),
|
/// clone_sugg: Some(suggestion, Applicability::MachineApplicable),
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// See rustc dev guide for more examples on using the `#[derive(SessionDiagnostic)]`:
|
||||||
|
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/sessiondiagnostic.html>
|
||||||
pub fn session_diagnostic_derive(s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
pub fn session_diagnostic_derive(s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
|
||||||
// Names for the diagnostic we build and the session we build it from.
|
// Names for the diagnostic we build and the session we build it from.
|
||||||
let diag = format_ident!("diag");
|
let diag = format_ident!("diag");
|
||||||
|
@ -134,7 +134,7 @@ pub struct TypeofReservedKeywordUsed<'tcx> {
|
|||||||
#[primary_span]
|
#[primary_span]
|
||||||
#[label]
|
#[label]
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
#[suggestion_verbose(message = "suggestion", code = "{ty}")]
|
#[suggestion_verbose(code = "{ty}")]
|
||||||
pub opt_sugg: Option<(Span, Applicability)>,
|
pub opt_sugg: Option<(Span, Applicability)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user