add on_unmatch_args

This commit is contained in:
yukang
2026-04-19 20:57:37 +08:00
parent cf1817bc6e
commit 8d75f0cbfc
45 changed files with 576 additions and 11 deletions
+3
View File
@@ -45,6 +45,9 @@ fn clone(&self) -> Self {
/// variant must also be specified. Only a single field is supported.
#[unstable(feature = "field_projections", issue = "145383")]
#[allow_internal_unstable(field_representing_type_raw, builtin_syntax)]
#[diagnostic::on_unmatch_args(
note = "this macro expects a container type and a field path, like `field_of!(Type, field)` or `field_of!(Enum, Variant.field)`"
)]
// NOTE: when stabilizing this macro, we can never add new trait impls for `FieldRepresentingType`,
// since it is `#[fundamental]` and thus could break users of this macro, since the compiler expands
// it to `FieldRepresentingType<...>`. Thus stabilizing this requires careful thought about the
+1
View File
@@ -131,6 +131,7 @@
#![feature(deprecated_suggestion)]
#![feature(derive_const)]
#![feature(diagnostic_on_const)]
#![feature(diagnostic_on_unmatch_args)]
#![feature(doc_cfg)]
#![feature(doc_notable_trait)]
#![feature(extern_types)]
+3
View File
@@ -1567,6 +1567,9 @@ impl<T> SizedTypeProperties for T {}
/// [`offset_of_enum`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-enum.html
/// [`offset_of_slice`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-slice.html
#[stable(feature = "offset_of", since = "1.77.0")]
#[diagnostic::on_unmatch_args(
note = "this macro expects a container type and a (nested) field path, like `offset_of!(Type, field)`"
)]
#[allow_internal_unstable(builtin_syntax, core_intrinsics)]
pub macro offset_of($Container:ty, $($fields:expr)+ $(,)?) {
// The `{}` is for better error messages