rust-lang / rust-lang/rust-clippy

invalid "no field on type" errors

Open
#7,480 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I tried this code:

            if k.end > p.pos || (k.start == k.end && k.end == p.pos) {
                return Ok(k);
            }

(taken from the pijul code base, https://nest.pijul.com/pijul/pijul)

I then ran cargo clippy -p libpijul -Z unstable-options --fix --allow-no-vcs.
(without -Z unstable-options --fix, this doesn't happen)

I expected to see this happen: no errors

Instead, this happened: I got the following error

error[E0609]: no field `end` on type `pristine::vertex::Position<pristine::change_id::ChangeId>`
   --> libpijul/src/pristine/sanakirja.rs:521:56
    |
521 |             if k.end > p.pos || (k.start == k.end && p.end == p.pos) {
    |                                                        ^^^ unknown field
    |
    = note: available fields are: `change`, `pos`

error[E0609]: no field `start` on type `pristine::vertex::Position<pristine::change_id::ChangeId>`
   --> libpijul/src/pristine/sanakirja.rs:602:75
    |
602 |         && ((k.start < p.pos && p.pos <= k.end) || (k.start == k.end && p.start == p.pos))
    |                                                                           ^^^^^ unknown field
    |
    = note: available fields are: `change`, `pos`

(notice that k and p are swapped on the left side of the comparison)

Meta
  • cargo clippy -V: clippy 0.1.53
  • rustc -Vv:
rustc 1.53.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with cargo clippy -p libpijul -Z unstable-options --fix --allow-no-vcs using the Rust snippet from the report. Inspect the resulting diagnostics at libpijul/src/pristine/sanakirja.rs:521 and :602, where the reported field references are swapped. Done means the command no longer produces these invalid no field errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.