Remove Ident::empty.

All uses have been removed. And it's nonsensical: an identifier by
definition has at least one char.

The commits adds an is-non-empty assertion to `Ident::new` to enforce
this, and converts some `Ident` constructions to use `Ident::new`.
Adding the assertion requires making `Ident::new` and
`Ident::with_dummy_span` non-const, which is no great loss.

The commit amends a couple of places that do path splitting to ensure no
empty identifiers are created.
This commit is contained in:
Nicholas Nethercote
2025-04-24 11:56:44 +10:00
parent 667247db71
commit 0984db553d
7 changed files with 54 additions and 45 deletions

View File

@@ -3828,7 +3828,7 @@ impl<'a> Parser<'a> {
// Convert `label` -> `'label`,
// so that nameres doesn't complain about non-existing label
let label = format!("'{}", ident.name);
let ident = Ident { name: Symbol::intern(&label), span: ident.span };
let ident = Ident::new(Symbol::intern(&label), ident.span);
self.dcx().emit_err(errors::ExpectedLabelFoundIdent {
span: ident.span,