You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
try_from_instead_of_from_str lint causes error when TryFrom::try_from parameter is not named 'value' #17877
Clippy suggests a replacement that includes a hardcoded value: &str parameter, but the suggestion still uses the existing code's parameter name inside the function body.
warning: `TryFrom<str>` could be `FromStr`
╭▸ src/lib.rs:5:1
│
5 │ ┏ impl TryFrom<&str> for Foo {
6 │ ┃ type Error = std::io::Error;
7 │ ┃
8 │ ┃ fn try_from(s: &str) -> Result<Self, Self::Error> {
‡ ┃
12 │ ┃ }
│ ┗━┛
│
├ help: `FromStr` can also be implemented alongside `TryFrom` if you want to avoid breaking changes
├ help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#try_from_instead_of_from_str
╰ note: `#[warn(clippy::try_from_instead_of_from_str)]` on by default
help: replace with
╭╴
5 + impl core::str::FromStr for Foo {
6 + type Err = std::io::Error;
7 +
8 + fn from_str(value: &str) -> Result<Self, Self::Err> {
9 + let _ = s;
10 + Ok(Self)
11 + }
12 + }
╰╴
Desired output: The parameter should probably just use the same name as in the original impl, which would be a shorter diff than replacing all references in the body.
Activity
wasd243 commentedon Oct 14, 2026
@rustbot claim