Skip to content

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

Closed
@qwfy

Description

@qwfy

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions