diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-13 18:43:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-13 18:43:01 +0200 |
| commit | cf42ac6bf2e8effc1d84bdaec16531a6cbb42f62 (patch) | |
| tree | 836fea17da007e848465afc8c92dbfd78627e103 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | d42a48d91813fab843174f26e2504c869f9a211e (diff) | |
| parent | e7e18a3297a01f25b5b7f40e86125b80cae8a7a5 (diff) | |
| download | rust-cf42ac6bf2e8effc1d84bdaec16531a6cbb42f62.tar.gz rust-cf42ac6bf2e8effc1d84bdaec16531a6cbb42f62.zip | |
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````````
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
