Skip to content

Add logic to determine whether unnamed fmt arguments are present#343

Merged
dtolnay merged 1 commit intomasterfrom
unnamed
Nov 4, 2024
Merged

Add logic to determine whether unnamed fmt arguments are present#343
dtolnay merged 1 commit intomasterfrom
unnamed

Conversation

@dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 4, 2024

This is needed for an upcoming change that disallows extra positional fmt arguments in the format string of a tuple struct or tuple variant due to ambiguity. For example in #[error("{} {0}", $N)] Variant(i32) it is ambiguous whether the {0} refers to $N vs &self.0. One would need to write a named #[error("{n} {n}", n = $N)] for the former or a numbered #[error("{n} {0}", n = $N)] for the latter, both of which have an obviously unambiguous meaning.

@dtolnay dtolnay merged commit d2a823d into master Nov 4, 2024
@dtolnay dtolnay deleted the unnamed branch November 4, 2024 16:44
takumi-earth pushed a commit to earthlings-dev/thiserror that referenced this pull request Jan 27, 2026
Add logic to determine whether unnamed fmt arguments are present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant