-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[regression] type inference on parse() #73242
Comments
|
There were roughly ~15-20 crates that failed in the crater run due to this, mostly in tests. I'm not sure whether we think that's sufficient reasoning to drop the impl, I get that it can be useful... cc @rust-lang/libs (and relabeling as this is not an inference regression) |
Can we add Being able to easily compare a socketaddr to a string seems pretty valuable for testing, I'd rather see we make it easier than require the turbofish. #72239 for the PR that added these impls |
I’m not in favor since this would blur the difference between "this string does not parse as a valid socket address" v.s. "it does, but one not equal to that one". Code that doesn’t care about that difference can already use |
#72239 mostly cared about PartialOrd and Ord impls (as you can tell from the PR title). Unlike PartialEq, none existed before on SocketAddr so they won't be problematic. I think the PR included new PartialEq impls only in support of heterogeneous PartialOrd (see #72239 (comment)) which was ultimately removed from the PR anyway. I opened #73304 to revert the new PartialEq impls, leaving the PartialOrd and Ord impls from #72239. |
Revert heterogeneous SocketAddr PartialEq impls Originally added in rust-lang#72239. These lead to inference regressions (mostly in tests) in code that looks like: ```rust let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080); assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); ``` That compiles as of stable 1.44.0 but fails in beta with: ```console error[E0284]: type annotations needed --> src/main.rs:3:41 | 3 | assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); | ^^^^^ cannot infer type for type parameter `F` declared on the associated function `parse` | = note: cannot satisfy `<_ as std::str::FromStr>::Err == _` help: consider specifying the type argument in the method call | 3 | assert_eq!(socket, "127.0.0.1:8080".parse::<F>().unwrap()); | ``` Closes rust-lang#73242.
Revert heterogeneous SocketAddr PartialEq impls Originally added in rust-lang#72239. These lead to inference regressions (mostly in tests) in code that looks like: ```rust let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080); assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); ``` That compiles as of stable 1.44.0 but fails in beta with: ```console error[E0284]: type annotations needed --> src/main.rs:3:41 | 3 | assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); | ^^^^^ cannot infer type for type parameter `F` declared on the associated function `parse` | = note: cannot satisfy `<_ as std::str::FromStr>::Err == _` help: consider specifying the type argument in the method call | 3 | assert_eq!(socket, "127.0.0.1:8080".parse::<F>().unwrap()); | ``` Closes rust-lang#73242.
Revert heterogeneous SocketAddr PartialEq impls Originally added in rust-lang#72239. These lead to inference regressions (mostly in tests) in code that looks like: ```rust let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080); assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); ``` That compiles as of stable 1.44.0 but fails in beta with: ```console error[E0284]: type annotations needed --> src/main.rs:3:41 | 3 | assert_eq!(socket, "127.0.0.1:8080".parse().unwrap()); | ^^^^^ cannot infer type for type parameter `F` declared on the associated function `parse` | = note: cannot satisfy `<_ as std::str::FromStr>::Err == _` help: consider specifying the type argument in the method call | 3 | assert_eq!(socket, "127.0.0.1:8080".parse::<F>().unwrap()); | ``` Closes rust-lang#73242.
https://play.rust-lang.org/?version=beta&mode=debug&edition=2018&gist=cbe4ae71cf9d88e5c0fdf6d06af3502e as a minimal example.
Unclear whether this is a new trait impl or some regression elsewhere.
The text was updated successfully, but these errors were encountered: