Skip to content
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

E0308 should suggest .into() if available #102415

Closed
estebank opened this issue Sep 28, 2022 · 0 comments · Fixed by #102496
Closed

E0308 should suggest .into() if available #102415

estebank opened this issue Sep 28, 2022 · 0 comments · Fixed by #102496
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

Given:

fn main() {
    let x: A = B;
}

struct A;
struct B;

impl From<B> for A {
    fn from(_: B) -> Self { A }
}

the current output is

error[E0308]: mismatched types
 --> src/main.rs:2:16
  |
2 |     let x: A = B;
  |            -   ^ expected struct `A`, found struct `B`
  |            |
  |            expected due to this

but we should probe for possible Into and From impls and suggest them if reasonable.

@estebank 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. labels Sep 28, 2022
@compiler-errors compiler-errors self-assigned this Sep 29, 2022
@bors bors closed this as completed in cec087a Oct 5, 2022
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-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants