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

Missing parenthesis in help message #109436

Closed
gabi-250 opened this issue Mar 21, 2023 · 1 comment · Fixed by #109472
Closed

Missing parenthesis in help message #109436

gabi-250 opened this issue Mar 21, 2023 · 1 comment · Fixed by #109472
Assignees
Labels
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.

Comments

@gabi-250
Copy link
Contributor

gabi-250 commented Mar 21, 2023

Code

struct Foo;

struct Bar;

impl From<&Foo> for Bar {
    fn from(foo: &Foo) -> Bar {
        Bar
    }
}

fn main() {
    let foo = Foo;
    let b: Bar = foo.into();
}

Current output

error[E0277]: the trait bound `Foo: Into<_>` is not satisfied
  --> src/main.rs:13:22
   |
13 |     let b: Bar = foo.into();
   |                      ^^^^ the trait `~const Into<_>` is not implemented for `Foo`
   |
   = note: required for `Foo` to implement `Into<Bar>`
help: consider borrowing here
   |
13 |     let b: Bar = &foo.into();
   |                  +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `reference-loop` due to previous error

Desired output

error[E0277]: the trait bound `Foo: Into<_>` is not satisfied
  --> src/main.rs:13:22
   |
13 |     let b: Bar = foo.into();
   |                      ^^^^ the trait `~const Into<_>` is not implemented for `Foo`
   |
   = note: required for `Foo` to implement `Into<Bar>`
help: consider borrowing here
   |
13 |     let b: Bar = (&foo).into();
   |                   +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `reference-loop` due to previous error

Rationale and extra context

No response

Other cases

No response

Anything else?

The help message suggests borrowing foo.into(), which obviously doesn't fix the issue (it leads to a series of other misleading errors). This happens using rustc 1.68.0 (2c8cc3432 2023-03-06).

@gabi-250 gabi-250 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. labels Mar 21, 2023
@mu001999
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 23, 2023
Add parentheses properly for method calls

Fixes rust-lang#109436
@bors bors closed this as completed in 20f3f43 Mar 23, 2023
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 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