Skip to content

Maybe offset-by-one error in compilation error message #99049

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

Closed
qwfy opened this issue Jul 8, 2022 · 3 comments
Closed

Maybe offset-by-one error in compilation error message #99049

qwfy opened this issue Jul 8, 2022 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code.

Comments

@qwfy
Copy link

qwfy commented Jul 8, 2022

The following (maybe incorrect) error message is given by the compiler:

71  | trait ColumnValue: for<'r> sqlx::Encode<'r, Postgres> + sqlx::Type<Postgres> {
    |       ----------- this trait cannot be made into an object...
    = help: consider turning `type_info` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
    = help: consider turning `compatible` into a method by giving it a `&self` argument or constraining it so it does not apply to trait objects
help: consider turning `type_info` into a method by giving it a `&self` argument
    |
175 |     fn type_info&self() -> DB::TypeInfo;
    |                 +++++ <======== (************ LOOK HERE ************)
help: consider turning `compatible` into a method by giving it a `&self` argument
    |
184 |     fn compatible&self, (ty: &DB::TypeInfo) -> bool {
    |                  ++++++

when compiling the code:

trait ColumnValue: for<'r> sqlx::Encode<'r, sqlx::Postgres> + sqlx::Type<sqlx::Postgres> {
}

Shouldn't the message labeled "LOOK HERE" be fn type_info(&self) -> DB::TypeInfo; ?

$ cargo --version
cargo 1.57.0 (b2e52d7ca 2021-10-21)

$ rustc --version
rustc 1.57.0 (f1edd0429 2021-11-29)
@qwfy qwfy added the C-bug Category: This is a bug. label Jul 8, 2022
@ehuss ehuss added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Jul 8, 2022
@compiler-errors
Copy link
Member

Hi @qwfy, this is an old version of Rust. Do you mind checking if this reproduces on the current version of 1.62? Also, is the code sample you provided complete? It doesn't really look related to the errors you provided.

@qwfy
Copy link
Author

qwfy commented Jul 9, 2022

@compiler-errors
Copy link
Member

Thanks for the reproduction, the sample you provided in "when compiling the code" in the issue above was not complete, but the cargo project you linked was. Anyways, I fixed this already in #98506, which is currently in nightly. The new output renders without those faulty suggestions.

@qwfy qwfy closed this as completed Jul 9, 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` C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code.
Projects
None yet
Development

No branches or pull requests

3 participants