-
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
Suggest &*
when appropriate
#132784
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
estebank
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-papercut
Diagnostics: An error or lint that needs small tweaks.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
labels
Nov 8, 2024
@rustbot claim |
uellenberg
added a commit
to uellenberg/rust
that referenced
this issue
Nov 12, 2024
uellenberg
added a commit
to uellenberg/rust
that referenced
this issue
Nov 12, 2024
uellenberg
added a commit
to uellenberg/rust
that referenced
this issue
Nov 12, 2024
uellenberg
added a commit
to uellenberg/rust
that referenced
this issue
Nov 12, 2024
uellenberg
added a commit
to uellenberg/rust
that referenced
this issue
Dec 13, 2024
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 14, 2024
Suggest using deref in patterns Fixes rust-lang#132784 This changes the following code: ```rs use std::sync::Arc; fn main() { let mut x = Arc::new(Some(1)); match x { Some(_) => {} None => {} } } ``` to output ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | LL | match x { | - this expression has type `Arc<Option<{integer}>>` ... LL | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | LL | match *x { | ~~ ``` instead of ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | match x { | - this expression has type `Arc<Option<{integer}>>` 5 | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` ``` This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 15, 2024
Rollup merge of rust-lang#132939 - uellenberg:suggest-deref, r=oli-obk Suggest using deref in patterns Fixes rust-lang#132784 This changes the following code: ```rs use std::sync::Arc; fn main() { let mut x = Arc::new(Some(1)); match x { Some(_) => {} None => {} } } ``` to output ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | LL | match x { | - this expression has type `Arc<Option<{integer}>>` ... LL | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | LL | match *x { | ~~ ``` instead of ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | match x { | - this expression has type `Arc<Option<{integer}>>` 5 | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` ``` This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
https://users.rust-lang.org/t/type-errors-are-a-part-of-library-api-surface-and-a-fundamental-shortcoming-in-rust/120859
Other cases
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: