|
12 | 12 | //! `.err()` on spans. |
13 | 13 | //! |
14 | 14 |
|
15 | | -use proc_macro::{Span, TokenStream}; |
| 15 | +use crate::proc_macro::{Span, TokenStream}; |
16 | 16 |
|
17 | 17 |
|
18 | 18 | /// Extension trait that adds a convenience method to `Diagnostic`. This is |
@@ -44,10 +44,10 @@ impl DiagnosticExt for Diagnostic { |
44 | 44 | // `Diagnostic`. |
45 | 45 |
|
46 | 46 | #[cfg(feature = "nightly")] |
47 | | -crate type Diagnostic = ::proc_macro::Diagnostic; |
| 47 | +pub(crate) type Diagnostic = crate::proc_macro::Diagnostic; |
48 | 48 |
|
49 | 49 | #[cfg(not(feature = "nightly"))] |
50 | | -crate struct Diagnostic { |
| 50 | +pub(crate) struct Diagnostic { |
51 | 51 | span: Span, |
52 | 52 | msg: String, |
53 | 53 | } |
@@ -86,19 +86,19 @@ crate struct Diagnostic { |
86 | 86 | // required. |
87 | 87 | #[cfg(not(feature = "nightly"))] |
88 | 88 | impl Diagnostic { |
89 | | - crate fn note(mut self, msg: impl Into<String>) -> Diagnostic { |
| 89 | + pub(crate) fn note(mut self, msg: impl Into<String>) -> Diagnostic { |
90 | 90 | self.msg += &format!("\n\nnote: {}", msg.into()); |
91 | 91 | self |
92 | 92 | } |
93 | 93 |
|
94 | | - crate fn span_note(mut self, _: Span, msg: impl Into<String>) -> Diagnostic { |
| 94 | + pub(crate) fn span_note(mut self, _: Span, msg: impl Into<String>) -> Diagnostic { |
95 | 95 | // With out span fake method, we can only handle one span. We take the |
96 | 96 | // one of the original error and ignore additional ones. |
97 | 97 | self.msg += &format!("\n\nnote: {}", msg.into()); |
98 | 98 | self |
99 | 99 | } |
100 | 100 |
|
101 | | - crate fn emit(self) { |
| 101 | + pub(crate) fn emit(self) { |
102 | 102 | // Create the error token stream that contains the `compile_error!()` |
103 | 103 | // invocation. |
104 | 104 | let msg = &self.msg; |
@@ -149,28 +149,28 @@ thread_local! { |
149 | 149 |
|
150 | 150 | /// On stable, we just copy the error token streams from the global variable. |
151 | 151 | #[cfg(not(feature = "nightly"))] |
152 | | -crate fn error_tokens() -> TokenStream { |
| 152 | +pub(crate) fn error_tokens() -> TokenStream { |
153 | 153 | ERROR_TOKENS.with(|toks| toks.borrow().iter().cloned().collect()) |
154 | 154 | } |
155 | 155 |
|
156 | 156 | /// On nightly, we don't use and don't have a strange global variable. Instead, |
157 | 157 | /// we just return an empty token stream. That's not a problem because all of |
158 | 158 | /// our errors were already printed. |
159 | 159 | #[cfg(feature = "nightly")] |
160 | | -crate fn error_tokens() -> TokenStream { |
| 160 | +pub(crate) fn error_tokens() -> TokenStream { |
161 | 161 | TokenStream::new() |
162 | 162 | } |
163 | 163 |
|
164 | 164 | /// Extension trait to add the `err()` method to `Span`. This makes it easy to |
165 | 165 | /// start a `Diagnostic` from a span. |
166 | | -crate trait SpanExt { |
| 166 | +pub(crate) trait SpanExt { |
167 | 167 | fn err(self, msg: impl Into<String>) -> Diagnostic; |
168 | 168 | } |
169 | 169 |
|
170 | 170 | impl SpanExt for Span { |
171 | 171 | #[cfg(feature = "nightly")] |
172 | 172 | fn err(self, msg: impl Into<String>) -> Diagnostic { |
173 | | - Diagnostic::spanned(self, ::proc_macro::Level::Error, msg) |
| 173 | + Diagnostic::spanned(self, crate::proc_macro::Level::Error, msg) |
174 | 174 | } |
175 | 175 |
|
176 | 176 | #[cfg(not(feature = "nightly"))] |
|
0 commit comments