mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
2e41425de6
Make `#[diagnostic::on_unimplemented]` format string parsing more robust This commit fixes several issues with the format string parsing of the `#[diagnostic::on_unimplemented]` attribute that were pointed out by `@ehuss.` In detail it fixes: * Appearing format specifiers (display, etc). For these we generate a warning that the specifier is unsupported. Otherwise we ignore them * Positional arguments. For these we generate a warning that positional arguments are unsupported in that location and replace them with the format string equivalent (so `{}` or `{n}` where n is the index of the positional argument) * Broken format strings with enclosed }. For these we generate a warning about the broken format string and set the emitted message literally to the provided unformatted string * Unknown format specifiers. For these we generate an additional warning about the unknown specifier. Otherwise we emit the literal string as message. This essentially makes those strings behave like `format!` with the minor difference that we do not generate hard errors but only warnings. After that we continue trying to do something unsuprising (mostly either ignoring the broken parts or falling back to just giving back the literal string as provided). Fix #122391 r? `@compiler-errors` |
||
---|---|---|
.. | ||
auxiliary | ||
on_unimplemented | ||
can_use_the_diagnostic_name_in_other_places.rs | ||
deny_malformed_attribute.rs | ||
deny_malformed_attribute.stderr | ||
existing_proc_macros.rs | ||
non_existing_attributes_accepted.rs | ||
non_existing_attributes_accepted.stderr | ||
requires_path.rs | ||
requires_path.stderr |