about summary refs log tree commit diff
path: root/compiler/rustc_macros/src/diagnostics/utils.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-03 23:53:44 +0000
committerMichael Goulet <michael@errs.io>2023-05-08 03:34:46 +0000
commita156bd771457110415b1eec74cf52c9502d461a3 (patch)
treeeefcd36e3289030d0c1589b36d78a60795d3a543 /compiler/rustc_macros/src/diagnostics/utils.rs
parent2b9279f3131056a1a1dd5de7513de4eb98987770 (diff)
downloadrust-a156bd771457110415b1eec74cf52c9502d461a3.tar.gz
rust-a156bd771457110415b1eec74cf52c9502d461a3.zip
Make spans a bit better
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/utils.rs')
-rw-r--r--compiler/rustc_macros/src/diagnostics/utils.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs
index bc97e39bebd..e2434981f8d 100644
--- a/compiler/rustc_macros/src/diagnostics/utils.rs
+++ b/compiler/rustc_macros/src/diagnostics/utils.rs
@@ -207,6 +207,12 @@ impl<'ty> FieldInnerTy<'ty> {
             FieldInnerTy::Plain(..) => quote! { #inner },
         }
     }
+
+    pub fn span(&self) -> proc_macro2::Span {
+        match self {
+            FieldInnerTy::Option(ty) | FieldInnerTy::Vec(ty) | FieldInnerTy::Plain(ty) => ty.span(),
+        }
+    }
 }
 
 /// Field information passed to the builder. Deliberately omits attrs to discourage the