Skip to content

Implement PartialEq for Ident, PartialEq for TokenStream #51074

Closed
@dtolnay

Description

@dtolnay

The original hesitation around these impls was whether to consider things equal that have different Spans.

I propose that if somebody is writing a macro that relies on knowing whether two tokens are the very same down to their syntax context, we should consider that an unhelpable case of "doing it wrong." On the other hand comparing the text of an Ident is quite common and perfectly correct. For example when iterating through field attributes in a custom derive to handle something like #[serde(rename = "...")] it makes sense to compare whether the idents in the token stream are == i_serde or == i_rename.

tracking issue: #38356
cc @Eijebong @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions