summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-27 12:35:18 +0000
committerbors <bors@rust-lang.org>2024-07-27 12:35:18 +0000
commit8fe0c753f23e7050b87a444b6622caf4d2272d5d (patch)
tree63d4f54922822700207afe54af5176a3e6b83aa2 /compiler/rustc_hir_analysis
parent3942254d00bf95cd5920980f85ebea57a1e6ce2a (diff)
parent8c402f125ccb3d8ccbabef40694482d481fc28b8 (diff)
downloadrust-8fe0c753f23e7050b87a444b6622caf4d2272d5d.tar.gz
rust-8fe0c753f23e7050b87a444b6622caf4d2272d5d.zip
Auto merge of #128006 - tgross35:missing-fragment-specifier-e2024, r=petrochenkov
Make `missing_fragment_specifier` an error in edition 2024

`missing_fragment_specifier` has been a future compatibility warning since 2017. Uplifting it to an unconditional hard error was attempted in 2020, but eventually reverted due to fallout.

Make it an error only in edition >= 2024, leaving the lint for older editions. This change will make it easier to support more macro syntax that relies on usage of `$`.

Fixes <https://github.com/rust-lang/rust/issues/40107>

---

It is rather late for the edition but since this change is relatively small, it seems worth at least bringing up. This follows a brief [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/268952-edition/topic/.60.20DBD.20-.3E.20hard.20error) (cc `@tmandry).`

Making this an edition-dependent lint has come up before but there was not a strong motivation. I am proposing it at this time because this would simplify the [named macro capture groups](https://github.com/rust-lang/rfcs/pull/3649) RFC, which has had mildly positive response, and makes use of new `$` syntax in the matcher. The proposed syntax currently parses as metavariables without a fragment specifier; this warning is raised, but there are no errors.

It is obviously not known that this specific RFC will eventually be accepted, but forbidding `missing_fragment_specifier` should make it easier to support any new syntax in the future that makes use of `$` in different ways. The syntax conflict is also not impossible to overcome, but making it clear that unnamed metavariables are rejected makes things more straightforward and should allow for better diagnostics.

`@Mark-Simulacrum` suggested making this forbid-by-default instead of an error at https://github.com/rust-lang/rust/issues/40107#issuecomment-761727885, but I don't think this would allow the same level of syntax flexibility.

It is also possible to reconsider making this an unconditional error since four years have elapsed since the previous attempt, but this seems likely to hit the same pitfalls. (Possibly worth a crater run?)

Tracking:

- https://github.com/rust-lang/rust/issues/128143
Diffstat (limited to 'compiler/rustc_hir_analysis')
0 files changed, 0 insertions, 0 deletions