diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-11 01:46:34 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-11 16:00:49 +0000 |
| commit | 189f264926ff70b58c8907473de60766477e7dd6 (patch) | |
| tree | 39ec2fed72b9826301c68bbc3ca4529e93e8aa14 /compiler/rustc_builtin_macros | |
| parent | 577166503aee7290e09374da21f4045c455acfd5 (diff) | |
| download | rust-189f264926ff70b58c8907473de60766477e7dd6.tar.gz rust-189f264926ff70b58c8907473de60766477e7dd6.zip | |
Allow attr entries to declare list of alternatives for `List` and `NamedValueStr`
Modify `AttributeTemplate` to support list of alternatives for list and name value attribute styles. Suggestions now provide more correct suggested code: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler)] | LL - #[used(compiler, linker)] LL + #[used(linker)] | LL - #[used(compiler, linker)] LL + #[used] | ``` instead of the prior "masking" of the lack of this feature by suggesting pipe-separated lists: ``` error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] | ^^^^^^------------------^ | | | expected a single argument here | help: try changing it to one of the following valid forms of the attribute | LL - #[used(compiler, linker)] LL + #[used(compiler|linker)] | LL - #[used(compiler, linker)] LL + #[used] | ```
Diffstat (limited to 'compiler/rustc_builtin_macros')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/cfg_accessible.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_builtin_macros/src/derive.rs | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_builtin_macros/src/cfg_accessible.rs b/compiler/rustc_builtin_macros/src/cfg_accessible.rs index 5f203dd5d11..f7d8f4aa783 100644 --- a/compiler/rustc_builtin_macros/src/cfg_accessible.rs +++ b/compiler/rustc_builtin_macros/src/cfg_accessible.rs @@ -44,7 +44,7 @@ impl MultiItemModifier for Expander { item: Annotatable, _is_derive_const: bool, ) -> ExpandResult<Vec<Annotatable>, Annotatable> { - let template = AttributeTemplate { list: Some("path"), ..Default::default() }; + let template = AttributeTemplate { list: Some(&["path"]), ..Default::default() }; validate_attr::check_builtin_meta_item( &ecx.sess.psess, meta_item, diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index e259f5b3955..a33eca43de5 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -34,8 +34,10 @@ impl MultiItemModifier for Expander { let (sess, features) = (ecx.sess, ecx.ecfg.features); let result = ecx.resolver.resolve_derives(ecx.current_expansion.id, ecx.force_mode, &|| { - let template = - AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() }; + let template = AttributeTemplate { + list: Some(&["Trait1, Trait2, ..."]), + ..Default::default() + }; validate_attr::check_builtin_meta_item( &sess.psess, meta_item, |
