summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_macros
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_macros')
-rw-r--r--compiler/rustc_macros/Cargo.toml3
-rw-r--r--compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs14
-rw-r--r--compiler/rustc_macros/src/diagnostics/subdiagnostic.rs4
-rw-r--r--compiler/rustc_macros/src/lib.rs1
-rw-r--r--compiler/rustc_macros/src/newtype.rs6
-rw-r--r--compiler/rustc_macros/src/serialize.rs6
6 files changed, 22 insertions, 12 deletions
diff --git a/compiler/rustc_macros/Cargo.toml b/compiler/rustc_macros/Cargo.toml
index 16c4a8500..17651ce95 100644
--- a/compiler/rustc_macros/Cargo.toml
+++ b/compiler/rustc_macros/Cargo.toml
@@ -8,7 +8,6 @@ proc-macro = true
[dependencies]
synstructure = "0.13.0"
-# FIXME(Nilstrieb): Updating this causes changes in the diagnostics output.
-syn = { version = "=2.0.8", features = ["full"] }
+syn = { version = "2.0.9", features = ["full"] }
proc-macro2 = "1"
quote = "1"
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
index 2e6e84ad8..e9a5cd9de 100644
--- a/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
+++ b/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
@@ -203,14 +203,18 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
if first && (nested.input.is_empty() || nested.input.peek(Token![,])) {
self.slug.set_once(path.clone(), path.span().unwrap());
first = false;
- return Ok(())
+ return Ok(());
}
first = false;
let Ok(nested) = nested.value() else {
- span_err(nested.input.span().unwrap(), "diagnostic slug must be the first argument").emit();
- return Ok(())
+ span_err(
+ nested.input.span().unwrap(),
+ "diagnostic slug must be the first argument",
+ )
+ .emit();
+ return Ok(());
};
if path.is_ident("code") {
@@ -221,7 +225,9 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
#diag.code(rustc_errors::DiagnosticId::Error(#code.to_string()));
});
} else {
- span_err(path.span().unwrap(), "unknown argument").note("only the `code` parameter is valid after the slug").emit();
+ span_err(path.span().unwrap(), "unknown argument")
+ .note("only the `code` parameter is valid after the slug")
+ .emit();
// consume the buffer so we don't have syntax errors from syn
let _ = nested.parse::<TokenStream>();
diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
index e8dc98691..877e97450 100644
--- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
+++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
@@ -188,7 +188,9 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
let mut kind_slugs = vec![];
for attr in self.variant.ast().attrs {
- let Some(SubdiagnosticVariant { kind, slug, no_span }) = SubdiagnosticVariant::from_attr(attr, self)? else {
+ let Some(SubdiagnosticVariant { kind, slug, no_span }) =
+ SubdiagnosticVariant::from_attr(attr, self)?
+ else {
// Some attributes aren't errors - like documentation comments - but also aren't
// subdiagnostics.
continue;
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs
index 904f8eb57..f4593d0fe 100644
--- a/compiler/rustc_macros/src/lib.rs
+++ b/compiler/rustc_macros/src/lib.rs
@@ -7,6 +7,7 @@
#![allow(rustc::default_hash_types)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
+#![cfg_attr(not(bootstrap), allow(internal_features))]
#![recursion_limit = "128"]
use synstructure::decl_derive;
diff --git a/compiler/rustc_macros/src/newtype.rs b/compiler/rustc_macros/src/newtype.rs
index 415a89b0f..72b47de1a 100644
--- a/compiler/rustc_macros/src/newtype.rs
+++ b/compiler/rustc_macros/src/newtype.rs
@@ -36,7 +36,8 @@ impl Parse for Newtype {
false
}
"max" => {
- let Meta::NameValue(MetaNameValue { value: Expr::Lit(lit), .. }) = &attr.meta else {
+ let Meta::NameValue(MetaNameValue { value: Expr::Lit(lit), .. }) = &attr.meta
+ else {
panic!("#[max = NUMBER] attribute requires max value");
};
@@ -47,7 +48,8 @@ impl Parse for Newtype {
false
}
"debug_format" => {
- let Meta::NameValue(MetaNameValue { value: Expr::Lit(lit), .. }) = &attr.meta else {
+ let Meta::NameValue(MetaNameValue { value: Expr::Lit(lit), .. }) = &attr.meta
+ else {
panic!("#[debug_format = FMT] attribute requires a format");
};
diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs
index 8d017d149..ba75517d7 100644
--- a/compiler/rustc_macros/src/serialize.rs
+++ b/compiler/rustc_macros/src/serialize.rs
@@ -43,7 +43,7 @@ fn decodable_body(
let ty_name = s.ast().ident.to_string();
let decode_body = match s.variants() {
[] => {
- let message = format!("`{}` has no variants to decode", ty_name);
+ let message = format!("`{ty_name}` has no variants to decode");
quote! {
panic!(#message)
}
@@ -59,14 +59,14 @@ fn decodable_body(
})
.collect();
let message = format!(
- "invalid enum variant tag while decoding `{}`, expected 0..{}",
+ "invalid enum variant tag while decoding `{}`, expected 0..{}, actual {{}}",
ty_name,
variants.len()
);
quote! {
match ::rustc_serialize::Decoder::read_usize(__decoder) {
#match_inner
- _ => panic!(#message),
+ n => panic!(#message, n),
}
}
}