Skip to content

Commit f79d5e9

Browse files
committed
macros: update doc comment for diagnostic derive
The documentation comment for this derive is out-of-date, it should have been updated in #95512. Signed-off-by: David Wood <[email protected]>
1 parent 437468d commit f79d5e9

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
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");

0 commit comments

Comments
 (0)