@@ -16,31 +16,41 @@ use std::collections::{BTreeSet, HashMap};
16
16
/// # extern crate rust_middle;
17
17
/// # use rustc_middle::ty::Ty;
18
18
/// #[derive(SessionDiagnostic)]
19
- /// #[error(code = "E0505", slug = "move-out-of-borrow-error ")]
19
+ /// #[error(code = "E0505", slug = "borrowck- move-out-of-borrow")]
20
20
/// pub struct MoveOutOfBorrowError<'tcx> {
21
21
/// pub name: Ident,
22
22
/// pub ty: Ty<'tcx>,
23
23
/// #[primary_span]
24
- /// #[label = "cannot move out of borrow" ]
24
+ /// #[label]
25
25
/// 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)>
30
30
/// }
31
31
/// ```
32
32
///
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
+ ///
33
40
/// Then, later, to emit the error:
34
41
///
35
42
/// ```ignore (pseudo-rust)
36
43
/// sess.emit_err(MoveOutOfBorrowError {
37
44
/// expected,
38
45
/// actual,
39
46
/// span,
40
- /// other_span ,
41
- /// opt_sugg : Some(suggestion, Applicability::MachineApplicable),
47
+ /// first_borrow_span ,
48
+ /// clone_sugg : Some(suggestion, Applicability::MachineApplicable),
42
49
/// });
43
50
/// ```
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>
44
54
pub fn session_diagnostic_derive ( s : synstructure:: Structure < ' _ > ) -> proc_macro2:: TokenStream {
45
55
// Names for the diagnostic we build and the session we build it from.
46
56
let diag = format_ident ! ( "diag" ) ;
0 commit comments