Skip to content

"did you mean" for misusing a field as a method is misleading #38321

Closed
@whitequark

Description

@whitequark

The error is currently:

error: no method named `src_addr` found for type `&wire::ipv4::Repr` in the current scope
   --> src/wire/ipv4.rs:409:34
    |
409 |         packet.set_src_addr(self.src_addr());
    |                                  ^^^^^^^^
    |
note: did you mean to write `self.src_addr`?
   --> src/wire/ipv4.rs:409:34
    |
409 |         packet.set_src_addr(self.src_addr());
    |                                  ^^^^^^^^

which is of course absurd.

To reproduce:

struct Foo {
    src_addr: usize
}

fn main() {
    let foo = Foo { src_addr: 10 };
    foo.src_addr()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions