rust/src/test/ui/attributes
Nicholas Nethercote 99f5945f85 Overhaul MacArgs::Eq.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
2022-05-05 07:06:12 +10:00
..
auxiliary Expand NtExpr tokens only in key-value attributes 2020-11-03 00:53:43 +03:00
main-removed-2 Remove obsolete no-op #[main] attribute from compiler. 2022-02-08 00:46:16 +00:00
attr-before-view-item.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
attr-before-view-item2.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
attr-eq-token-tree.rs Move some tests to more reasonable directories 2021-11-14 14:38:42 -03:00
attr-eq-token-tree.stderr Move some tests to more reasonable directories 2021-11-14 14:38:42 -03:00
attr-mix-new.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
attrs-on-params.rs Add attr-on-params test 2021-02-09 22:17:10 +01:00
attrs-on-params.stderr Add attr-on-params test 2021-02-09 22:17:10 +01:00
attrs-with-no-formal-in-generics-1.rs Make sure #[rustc_doc_only_macro] and other rustc attributes are registered 2019-06-30 12:47:33 +03:00
attrs-with-no-formal-in-generics-1.stderr Make sure #[rustc_doc_only_macro] and other rustc attributes are registered 2019-06-30 12:47:33 +03:00
attrs-with-no-formal-in-generics-2.rs Make sure #[rustc_doc_only_macro] and other rustc attributes are registered 2019-06-30 12:47:33 +03:00
attrs-with-no-formal-in-generics-2.stderr Make sure #[rustc_doc_only_macro] and other rustc attributes are registered 2019-06-30 12:47:33 +03:00
attrs-with-no-formal-in-generics-3.rs Move some run-pass attribute tests to ui 2019-06-08 23:55:25 +03:00
attrs-with-no-formal-in-generics-3.stderr Move some run-pass attribute tests to ui 2019-06-08 23:55:25 +03:00
class-attributes-1.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
class-attributes-2.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
const-stability-on-macro.rs Cleanup feature gates. 2022-03-03 18:50:28 +01:00
const-stability-on-macro.stderr Cleanup feature gates. 2022-03-03 18:50:28 +01:00
doc-attr.rs Tweak diagnostics 2021-03-14 14:00:02 -07:00
doc-attr.stderr Tweak diagnostics 2021-03-14 14:00:02 -07:00
duplicated-attributes.rs Add a lint for duplicated attributes. 2021-12-15 23:43:13 +01:00
duplicated-attributes.stderr Add a lint for duplicated attributes. 2021-12-15 23:43:13 +01:00
extented-attribute-macro-error.rs Cleanup feature gates. 2022-03-03 18:50:28 +01:00
extented-attribute-macro-error.stderr Cleanup feature gates. 2022-03-03 18:50:28 +01:00
field-attributes-vis-unresolved.rs resolve: Make visibility resolution more speculative 2019-12-09 22:41:47 +03:00
field-attributes-vis-unresolved.stderr resolve: Make visibility resolution more speculative 2019-12-09 22:41:47 +03:00
invalid-doc-attr.rs Error on conflicting #[doc(inline)]/#[doc(no_inline)] attributes 2021-05-08 17:22:26 +02:00
invalid-doc-attr.stderr Unify titles in rustdoc book doc attributes chapter 2021-10-29 21:27:44 +02:00
issue-40962.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
issue-90873.rs Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
issue-90873.stderr Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
item-attributes.rs Update tests for extern block linting 2021-01-13 07:49:16 -05:00
key-value-expansion-on-mac.rs Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
key-value-expansion-on-mac.stderr Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
key-value-expansion.rs Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
key-value-expansion.stderr Overhaul MacArgs::Eq. 2022-05-05 07:06:12 +10:00
key-value-non-ascii.rs Handle Spans for byte and raw strings and add more detail 2021-02-03 13:34:28 -08:00
key-value-non-ascii.stderr Modify structured suggestion output 2021-08-11 09:46:24 +00:00
main-removed-1.rs Remove obsolete no-op #[main] attribute from compiler. 2022-02-08 00:46:16 +00:00
main-removed-1.stderr Remove obsolete no-op #[main] attribute from compiler. 2022-02-08 00:46:16 +00:00
method-attributes.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
multiple-invalid.rs hir: Disallow target_feature on constants 2019-09-26 16:55:52 +01:00
multiple-invalid.stderr hir: Disallow target_feature on constants 2019-09-26 16:55:52 +01:00
nonterminal-expansion.rs Enhance well-formedness checks for #[repr(...)] attributes 2021-07-09 22:03:48 +02:00
nonterminal-expansion.stderr Bless tests 2021-10-15 02:36:58 -05:00
obsolete-attr.rs Update tests for extern block linting 2021-01-13 07:49:16 -05:00
obsolete-attr.stderr Update tests for extern block linting 2021-01-13 07:49:16 -05:00
register-attr-tool-fail.rs Support registering attributes and attribute tools using crate-level attributes 2019-11-09 17:50:51 +03:00
register-attr-tool-fail.stderr Move malformed attribute code to a function and fix inner attribute suggestion. 2021-09-25 08:11:10 -07:00
register-attr-tool-import.rs Use opt_def_id() over def_id() 2020-03-01 15:15:29 +09:00
register-attr-tool-import.stderr Use opt_def_id() over def_id() 2020-03-01 15:15:29 +09:00
register-attr-tool-prelude.rs Clarify message about unresolved use 2020-09-01 18:38:14 +01:00
register-attr-tool-prelude.stderr Clarify message about unresolved use 2020-09-01 18:38:14 +01:00
register-attr-tool-unused.rs Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
register-attr-tool-unused.stderr Remove Session.used_attrs and move logic to CheckAttrVisitor 2021-08-21 13:27:27 -05:00
register-attr-tool.rs Support registering attributes and attribute tools using crate-level attributes 2019-11-09 17:50:51 +03:00
suffixed-literal-meta.rs Move some tests to more reasonable directories 2021-11-18 12:09:34 -03:00
suffixed-literal-meta.stderr Move some tests to more reasonable directories 2021-11-18 12:09:34 -03:00
tool_attributes.rs Move some tests to more reasonable directories 2021-11-14 14:38:42 -03:00
unknown-attr.rs resolve: Tweak "cannot find" wording for attributes 2019-09-15 13:10:12 +03:00
unknown-attr.stderr resolve: Tweak "cannot find" wording for attributes 2019-09-15 13:10:12 +03:00
unnamed-field-attributes-dup.rs def_collector: Do not forget to save indices of fields with multiple attributes 2019-11-24 11:47:45 +03:00
unnamed-field-attributes-vis.rs expand: Fully preserve visibilities on unnamed fields with attributes 2019-11-24 11:47:46 +03:00
unnamed-field-attributes.rs def_collector: Do not ICE on attributes on unnamed fields 2019-09-14 17:36:39 +03:00
unrestricted-attribute-tokens.rs Move some tests to more reasonable directories 2021-11-06 15:35:20 -03:00
used_with_arg.rs Move tests into attributes directory to pacify tidy 2022-02-09 11:21:25 +01:00
used_with_arg.stderr Move tests into attributes directory to pacify tidy 2022-02-09 11:21:25 +01:00
used_with_arg_no_mangle.rs check_used should only look at actual used attributes 2022-02-25 22:53:34 +01:00
used_with_multi_args.rs Move tests into attributes directory to pacify tidy 2022-02-09 11:21:25 +01:00
used_with_multi_args.stderr Move tests into attributes directory to pacify tidy 2022-02-09 11:21:25 +01:00
variant-attributes.rs Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00