Guillaume Gomez
bd6fb63596
Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkov
...
Handle macros with multiple kinds, and improve errors
(I recommend reviewing this commit-by-commit.)
Switch to a bitflags `MacroKinds` to support macros with more than one kind
Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`.
Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds.
This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`.
Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes.
This allows detecting and report macro kind mismatches early, and more precisely, improving various error messages. In particular, this eliminates the case in `failed_to_match_macro` to check for a function-like invocation of a macro with no function-like rules.
Instead, macro kind mismatches now result in an unresolved macro, and we detect this case in `unresolved_macro_suggestions`, which now carefully distinguishes between a kind mismatch and other errors.
This also handles cases of forward-referenced attributes and cyclic attributes.
----
In this PR, I've minimally fixed up `rustdoc` so that it compiles and passes tests. This is just the minimal necessary fixes to handle the switch to `MacroKinds`, and it only works for macros that don't actually have multiple kinds. This will panic (with a `todo!`) if it encounters a macro with multiple kinds.
rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros. I'd appreciate some help from a rustdoc expert on that.
----
r? ````````@petrochenkov````````
2025-08-13 18:43:01 +02:00
..
2025-08-10 21:52:23 +00:00
2024-11-27 07:18:25 -08:00
2025-04-17 19:45:28 +08:00
2025-04-17 19:45:28 +08:00
2025-08-10 21:47:52 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-03-25 15:02:55 +00:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-04-12 22:50:10 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-04-29 13:46:17 +10:00
2024-11-27 07:18:25 -08:00
2024-10-28 14:12:45 +11:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-01-13 12:46:58 -05:00
2024-01-22 20:14:59 +11:00
2025-04-03 21:41:58 +00:00
2025-04-03 21:41:58 +00:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2025-08-11 17:02:32 +00:00
2025-08-11 17:02:32 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-01-13 12:46:58 -05:00
2024-11-27 07:18:25 -08:00
2024-04-04 02:14:57 +01:00
2025-05-09 15:31:27 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-06-05 13:07:32 +10:00
2024-11-27 07:18:25 -08:00
2023-12-11 09:19:09 +11:00
2025-04-03 18:10:48 +00:00
2025-04-03 18:10:48 +00:00
2025-04-03 21:41:58 +00:00
2025-04-03 21:41:58 +00:00
2025-04-03 21:41:58 +00:00
2024-07-24 21:03:52 +10:00
2025-04-03 21:41:58 +00:00
2024-07-24 21:03:52 +10:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-06-03 13:35:31 +02:00
2024-03-25 15:02:55 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-02-18 22:51:19 +02:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-04-10 22:02:52 +02:00
2025-04-03 21:41:58 +00:00
2025-04-03 21:41:58 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-06-12 21:28:49 +00:00
2024-11-27 07:18:25 -08:00
2024-01-29 17:43:07 +08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-08-05 15:28:49 +03:00
2025-08-05 15:28:49 +03:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2023-12-11 09:19:09 +11:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-06-12 21:28:49 +00:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-10-28 14:12:45 +11:00
2025-04-03 21:41:58 +00:00
2025-03-07 14:51:07 +11:00
2024-11-27 07:18:25 -08:00
2024-11-03 13:55:52 -08:00
2024-11-27 07:18:25 -08:00
2025-04-03 11:08:55 +03:00
2025-04-03 11:08:55 +03:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-02-13 20:27:43 +00:00
2025-08-05 15:28:49 +03:00
2025-08-05 15:28:49 +03:00
2025-06-03 13:35:31 +02:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2025-03-25 17:33:09 +03:00
2025-03-25 17:33:09 +03:00
2025-03-25 17:33:09 +03:00
2025-04-16 22:44:02 +03:00
2025-04-16 22:44:02 +03:00
2025-04-13 21:48:53 +03:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-07-26 20:26:15 +02:00
2025-07-26 20:26:15 +02:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-06-03 13:35:31 +02:00
2025-06-03 13:35:31 +02:00
2025-06-03 13:35:31 +02:00
2025-04-03 11:08:55 +03:00
2025-02-21 17:37:03 +00:00
2025-01-07 16:04:14 +01:00
2025-02-10 20:21:39 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2025-08-05 15:28:49 +03:00
2025-08-05 15:28:49 +03:00
2025-04-03 21:41:58 +00:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:19:17 +11:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-06-05 13:07:32 +10:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-07-14 16:53:36 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-01-13 12:46:58 -05:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-02-10 20:21:39 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-07 10:42:01 +08:00
2025-04-07 19:13:30 +03:00
2025-04-07 19:13:30 +03:00
2024-11-27 07:18:25 -08:00
2025-03-14 19:50:03 +00:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-01-29 17:43:07 +08:00
2024-01-29 17:43:07 +08:00
2024-11-27 07:18:25 -08:00
2024-02-11 02:43:44 +09:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-08-06 23:59:47 +00:00
2025-08-06 23:59:47 +00:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-28 14:32:45 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-02-16 20:02:50 +00:00
2025-08-12 09:24:45 -07:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-04-02 06:20:35 +11:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-08-10 21:55:02 +00:00
2025-08-10 21:55:02 +00:00
2024-02-16 20:02:50 +00:00
2024-12-27 19:58:16 +11:00
2025-07-28 17:35:09 +03:00
2024-11-27 07:18:25 -08:00
2023-07-14 16:53:36 +01:00
2025-06-12 01:13:24 -07:00
2025-06-12 01:13:24 -07:00
2024-11-27 07:18:25 -08:00
2025-04-17 19:45:28 +08:00
2025-04-17 19:45:28 +08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-04-03 21:41:58 +00:00
2024-01-22 20:14:59 +11:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-10-11 21:21:32 +02:00
2024-03-06 22:24:25 +01:00
2024-11-27 07:18:25 -08:00
2023-07-14 16:53:36 +01:00
2025-03-30 01:32:21 +03:00
2025-05-29 10:24:23 +00:00
2024-03-25 15:02:55 +00:00
2024-03-25 15:02:55 +00:00
2025-03-07 14:51:08 +11:00
2025-03-07 14:51:08 +11:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2023-12-11 09:19:09 +11:00
2024-11-27 07:18:25 -08:00
2023-07-14 16:53:36 +01:00
2025-04-16 11:10:10 +02:00
2025-07-28 17:35:09 +03:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-04-03 11:08:55 +03:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-05-28 08:15:15 +10:00
2024-05-28 08:15:15 +10:00
2025-03-25 17:33:09 +03:00
2024-11-27 07:18:25 -08:00
2024-01-22 20:14:59 +11:00
2024-02-16 20:02:50 +00:00
2025-08-05 15:28:49 +03:00
2025-08-05 15:28:49 +03:00
2024-03-25 15:02:55 +00:00
2024-11-27 07:18:25 -08:00
2025-01-19 08:53:02 -07:00
2025-01-19 08:53:02 -07:00
2025-04-08 23:06:31 +03:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-10-04 21:09:54 +00:00
2024-11-27 07:18:25 -08:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-03-14 19:12:42 +00:00
2024-02-16 20:02:50 +00:00
2023-03-14 19:12:42 +00:00
2024-02-16 20:02:50 +00:00
2023-03-14 19:12:42 +00:00
2024-02-16 20:02:50 +00:00
2024-05-17 18:33:37 -03:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-04-11 15:07:08 +02:00
2024-11-27 07:18:25 -08:00
2025-08-08 10:35:47 -07:00
2024-11-27 07:18:25 -08:00
2023-10-04 21:09:54 +00:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2023-12-11 09:19:09 +11:00
2025-06-03 11:45:58 +02:00
2025-04-03 11:08:55 +03:00
2023-11-24 19:15:52 +01:00
2025-04-03 11:08:55 +03:00
2023-11-24 19:15:52 +01:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2025-02-22 13:30:41 +08:00
2025-02-22 13:30:41 +08:00
2024-02-16 20:02:50 +00:00
2024-11-27 07:18:25 -08:00
2025-04-29 13:46:17 +10:00
2024-11-27 07:18:25 -08:00