@@ -59,6 +59,21 @@ macro_rules! diagnostic_child_methods {
5959 )
6060}
6161
62+ #[ derive( Debug , Clone ) ]
63+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
64+ /// Iterator over the children diagnostics of a `Diagnostic`.
65+ pub struct Children < ' a > ( :: std:: slice:: Iter < ' a , Diagnostic > ) ;
66+
67+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
68+ impl < ' a > Iterator for Children < ' a > {
69+ type Item = & ' a Diagnostic ;
70+
71+ fn next ( & mut self ) -> Option < Self :: Item > {
72+ self . 0 . next ( )
73+ }
74+ }
75+
76+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
6277impl Diagnostic {
6378 /// Create a new diagnostic with the given `level` and `message`.
6479 #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
@@ -94,6 +109,42 @@ impl Diagnostic {
94109 self . level
95110 }
96111
112+ /// Sets the level in `self` to `level`.
113+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
114+ pub fn set_level ( & mut self , level : Level ) {
115+ self . level = level;
116+ }
117+
118+ /// Returns the message in `self`.
119+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
120+ pub fn message ( & self ) -> & str {
121+ & self . message
122+ }
123+
124+ /// Sets the message in `self` to `message`.
125+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
126+ pub fn set_message < T : Into < String > > ( & mut self , message : T ) {
127+ self . message = message. into ( ) ;
128+ }
129+
130+ /// Returns the `Span` in `self`.
131+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
132+ pub fn span ( & self ) -> Option < Span > {
133+ self . span
134+ }
135+
136+ /// Sets the `Span` in `self` to `span`.
137+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
138+ pub fn set_span ( & mut self , span : Span ) {
139+ self . span = Some ( span) ;
140+ }
141+
142+ /// Returns an iterator over the children diagnostics of `self`.
143+ #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
144+ pub fn children ( & self ) -> Children {
145+ Children ( self . children . iter ( ) )
146+ }
147+
97148 /// Emit the diagnostic.
98149 #[ unstable( feature = "proc_macro_diagnostic" , issue = "38356" ) ]
99150 pub fn emit ( self ) {
0 commit comments