-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Also suggest Some
when an Option<T>
is expected, but T
is given
#42764
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
Comments
More generally, if the expected type is an enum, and the found type is T, then you should search the enum's variants and check them whether |
I agree we should list variants like that, but I also think the |
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Jul 13, 2017
Most notably, this will suggest `Some(x)` when the expected type was an Option<T> but we got an x: T. Resolves rust-lang#42764.
zackmdavis
added a commit
to zackmdavis/rust
that referenced
this issue
Jul 15, 2017
We want the suggested replacement (which IDE tooling and such might offer to automatically swap in) to, like, actually be correct: suggesting `MyVariant(x)` when the actual fix is `MyEnum::MyVariant(x)` might be better than nothing, but Rust is supposed to be the future of computing: we're better than better than nothing. As an exceptional case, we excise the prelude path, preferring to suggest `Some` or `Ok` rather than `std::prelude::v1::Some` and `std::prelude::v2::Ok`. (It's not worth the effort to future-proof against hypothetical preludes v2, v3, &c.: we trust our successors to grep—excuse me, ripgrep—for that.) Also, don't make this preëmpt the existing probe-for-return-type suggestions, despite their being looked unfavorably upon, at least in this situation (rust-lang#42764 (comment)): Cody Schafer pointed out that that's a separate issue (rust-lang#43178 (comment)). This is in the matter of rust-lang#42764.
bors
added a commit
that referenced
this issue
Jul 19, 2017
suggest one-argument enum variant to fix type mismatch when applicable Following @est31's [suggestion](#42764 (comment)). ![some_suggestion](https://user-images.githubusercontent.com/1076988/28101064-ee83f51e-667a-11e7-9e4f-d8f9eb2fb6c3.png) Resolves #42764.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
produces
I think the first item in this list should be
Some
The text was updated successfully, but these errors were encountered: