-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[ui] Incorrect hint: Ok(wrap) instead *Deref #52537
Comments
Here's where the suggestion gets issued: rust/src/librustc/infer/error_reporting/mod.rs Lines 504 to 513 in 6cc78bf
The motivation was to solve #51632 (where a |
Here's another case of this: struct Foo;
fn takes_ref(_r: &Foo) {}
fn returns_result() -> Result<Foo,()> {}
fn main() -> Result<(),()> {
takes_ref(returns_result()?);
Ok(())
}
|
@zackmdavis I see what's happening, we're only checking wether the error came from a |
Clippy has helper functions to detect this that we might want to uplift ... |
(But for now I'm just going to remove the suggestion.) |
This suggestion was introduced in rust-lang#51938 / 6cc78bf (while introducing different language for type errors coming from `?` rather than a `match`), but it has a lot of false-positives (as repeatedly reported in Issues rust-lang#52537, rust-lang#52598, rust-lang#54578, rust-lang#55336), and incorrect suggestions carry more badness than marginal good suggestions do goodness. Just get rid of it (unless and until someone figures out how to do it correctly). Resolves rust-lang#52537, resolves rust-lang#54578.
…ng_suggestion, r=estebank back out bogus `Ok`-wrapping suggestion on `?` arm type mismatch This suggestion was introduced in rust-lang#51938 / 6cc78bf (while introducing different language for type errors coming from `?` rather than a `match`), but it has a lot of false-positives, and incorrect suggestions carry more badness than marginal good suggestions do goodness. I regret not doing this earlier. 😞 Resolves rust-lang#52537, resolves rust-lang#54578. r? @estebank
This suggestion was introduced in rust-lang#51938 / 6cc78bf (while introducing different language for type errors coming from `?` rather than a `match`), but it has a lot of false-positives (as repeatedly reported in Issues rust-lang#52537, rust-lang#52598, rust-lang#54578, rust-lang#55336), and incorrect suggestions carry more badness than marginal good suggestions do goodness. Just get rid of it (unless and until someone figures out how to do it correctly). Resolves rust-lang#52537, resolves rust-lang#54578.
Reproduced on versions:
rustc 1.29.0-nightly (12ed235ad 2018-07-18)
rustc 1.29.0-nightly (9fd3d7899 2018-07-07)
rustc 1.27.0 (3eda71b00 2018-06-19)
Isolated example to reproduce:
Actual error:
Mentioned suggestion about "wrap into
Ok
" is incorrect at all. There we should deref the value from theget_state()?
.Expected error: (something like this)
... expected struct `State`, found struct `StateDeref` help: try re-dereference(?) with a success variant: `&*get_state()?`
The text was updated successfully, but these errors were encountered: