Skip to content

Detect infinite recursion for #[error("{}", self)] - #457

Open
jaideeppyne wants to merge 1 commit into
dtolnay:masterfrom
jaideeppyne:fix/error-self-positional-recursion
Open

jaideeppyne wants to merge 1 commit into
dtolnay:masterfrom
jaideeppyne:fix/error-self-positional-recursion

Conversation

@jaideeppyne

Copy link
Copy Markdown

Fixes #420.

#[error("{self}")] already injects an unconditional_recursion warning. The equivalent form that puts self in the extra format arguments did not:

#[derive(Error, Debug)]
#[error("{}", self)]
pub struct Error;

That compiled, then overflowed the stack at runtime. Treat a Display of extra argument self the same as {self}. Adds a UI test for the reported case.

The existing check only flagged {self} in the format string. The
equivalent form #[error("{}", self)] still compiled and overflowed
the stack at runtime. Treat a Display of extra argument self the
same way.
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.

another infinite recursion

1 participant