Skip to content

Remove Ident::empty #140252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Apr 24, 2025

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

r? @oli-obk

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 24, 2025
@nnethercote
Copy link
Contributor Author

Helps with #137978.

@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2025

fmease is on vacation.

Please choose another assignee.

@nnethercote nnethercote marked this pull request as ready for review April 25, 2025 05:26
@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@nnethercote
Copy link
Contributor Author

Oh, the first commit here is from #140095 and doesn't need to be reviewed; this PR shouldn't be merged until that one has been.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 28, 2025

r=me when the other PR landed

@bors reviewed

@oli-obk oli-obk added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2025
@bors
Copy link
Collaborator

bors commented Apr 28, 2025

☔ The latest upstream changes (presumably #140388) made this pull request unmergeable. Please resolve the merge conflicts.

As part of this, streamline a bunch of related stuff:

- Introduce `PathParser::word_sym`, as an alternative to
  `PathParser::word`.
- Remove `MetaItemParser::path`, and just get the two parsers
  one at a time.
- Rename `MetaItemParser::path_without_args` as `MetaItemParser::path`,
  and avoid the clone.
- Inline and remove `MetaItemParser::word_without_args`, which has a
  single use.
- Remove `MetaItemParser::word_or_empty_without_args`, which has a
  single use.
- Remove `MetaItemParser::path_is`, which is unused.
- Remove `MetaItemListParser::all_{word,path}_list`, which are unused.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants