]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/diagnostic_builder.rs
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
[rust.git] / src / librustc_errors / diagnostic_builder.rs
index 73f66d550374050c4be7cc0eef6a3eceacfa1549..82bbae18a9c0b53c5dc5df7e93ba42a8375bb1e6 100644 (file)
@@ -186,11 +186,25 @@ pub fn delay_as_bug(&mut self) {
     /// all, and you just supplied a `Span` to create the diagnostic,
     /// then the snippet will just include that `Span`, which is
     /// called the primary span.
-    pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self {
+    pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self {
         self.0.diagnostic.span_label(span, label);
         self
     }
 
+    /// Labels all the given spans with the provided label.
+    /// See `span_label` for more information.
+    pub fn span_labels(
+        &mut self,
+        spans: impl IntoIterator<Item = Span>,
+        label: impl AsRef<str>,
+    ) -> &mut Self {
+        let label = label.as_ref();
+        for span in spans {
+            self.0.diagnostic.span_label(span, label);
+        }
+        self
+    }
+
     forward!(pub fn note_expected_found(
         &mut self,
         expected_label: &dyn fmt::Display,
@@ -399,8 +413,5 @@ macro_rules! struct_span_err {
 
 #[macro_export]
 macro_rules! error_code {
-    ($code:ident) => {{
-        let _ = $code;
-        $crate::DiagnosticId::Error(stringify!($code).to_owned())
-    }};
+    ($code:ident) => {{ $crate::DiagnosticId::Error(stringify!($code).to_owned()) }};
 }