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

useless_vec: missing spans if vec is not a fn param #12101

Closed
matthiaskrgr opened this issue Jan 5, 2024 · 1 comment · Fixed by #12116
Closed

useless_vec: missing spans if vec is not a fn param #12101

matthiaskrgr opened this issue Jan 5, 2024 · 1 comment · Fixed by #12116
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jan 5, 2024

Summary

Clippy does not generate proper diagnostics/spans here which in turn makes rustfix fail...

Reproducer

I tried this code:

// run-pass

struct Pair { x: isize, y: isize }

pub fn main() {
    for elt in &(vec![Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) {
        assert_eq!(elt.x + elt.y, 30);
    }
}

I expected to see this happen:
Something pointing inside the vec inside the &( .. )

Instead, this happened:

warning: useless use of `vec!`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec
  = note: `#[warn(clippy::useless_vec)]` on by default

warning: 1 warning emitted

clippy completely fails to get proper spans lol

Version

rustc 1.77.0-nightly (f688dd684 2024-01-04)
binary: rustc
commit-hash: f688dd684faca5b31b156fac2c6e0ae81fc9bc90
commit-date: 2024-01-04
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Additional Labels

No response

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Jan 5, 2024
@J-ZhengLi
Copy link
Member

@rustbot claim

github-merge-queue bot pushed a commit to privacy-scaling-explorations/zkevm-circuits that referenced this issue Feb 16, 2024
### Description

We've been using the version one year ago. Let's get a new year vibe.

### Issue Link


### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Refactor (no updates to logic)

### Contents

Major clippy fix

- Clippy now detect useless vector. It is a little bit
[buggy](rust-lang/rust-clippy#12101), and it
sometimes complains without giving the exact line.
bors added a commit that referenced this issue Feb 24, 2024
fix suggestion error in [`useless_vec`]

fixes: #12101

---

changelog: fix suggestion error in [`useless_vec`]

r+ `@matthiaskrgr` since they opened the issue?
bors added a commit that referenced this issue Feb 26, 2024
fix suggestion error in [`useless_vec`]

fixes: #12101

---

changelog: fix suggestion error in [`useless_vec`]

r+ `@matthiaskrgr` since they opened the issue?
bors added a commit that referenced this issue Feb 26, 2024
fix suggestion error in [`useless_vec`]

fixes: #12101

---

changelog: fix suggestion error in [`useless_vec`]

r+ `@matthiaskrgr` since they opened the issue?
bors added a commit that referenced this issue Feb 26, 2024
fix suggestion error in [`useless_vec`]

fixes: #12101

---

changelog: fix suggestion error in [`useless_vec`]

r+ `@matthiaskrgr` since they opened the issue?
@bors bors closed this as completed in d12b53e Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants