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

vec_box doesn't take scopes into account #6236

Closed
jyn514 opened this issue Oct 27, 2020 · 0 comments · Fixed by #6271
Closed

vec_box doesn't take scopes into account #6236

jyn514 opened this issue Oct 27, 2020 · 0 comments · Fixed by #6271
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 L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@jyn514
Copy link
Member

jyn514 commented Oct 27, 2020

I tried this code:

mod inner {
    pub struct S;
}

mod inner2 {
    use crate::inner::S;

    pub fn f() -> Vec<Box<S>> {
        vec![]
    }
}

I expected to see this happen: Clippy suggests turning Vec<Box<S>> into Vec<S>

Instead, this happened: Clippy suggests turning it into Vec<inner::S>.

error[E0433]: failed to resolve: use of undeclared crate or module `inner`
  --> src/lib.rs:10:23
   |
10 |     pub fn f() -> Vec<inner::S> {
   |                       ^^^^^ use of undeclared crate or module `inner`
Original diagnostics will follow.

warning: `Vec<T>` is already on the heap, the boxing is unnecessary.
  --> src/lib.rs:10:19
   |
10 |     pub fn f() -> Vec<Box<S>> {
   |                   ^^^^^^^^^^^ help: try: `Vec<inner::S>`
   |
   = note: `#[warn(clippy::vec_box)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#vec_box

Meta

  • cargo clippy -V: clippy 0.0.212 (ffa2e7a 2020-10-24)
  • rustc -Vv:
rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0

@rustbot modify labels: +A-suggestion +L-suggestion-causes-error

@jyn514 jyn514 added the C-bug Category: Clippy is not doing the correct thing label Oct 27, 2020
@rustbot rustbot added L-suggestion Lint: Improving, adding or fixing lint suggestions I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Oct 27, 2020
camsteffen added a commit to camsteffen/rust-clippy that referenced this issue Oct 30, 2020
bors added a commit that referenced this issue Nov 8, 2020
Fix vec_box scope error

changelog: Fix vec_box suggestion with wrong type scope

Fixes #6236
@bors bors closed this as completed in 7c74d87 Nov 8, 2020
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 L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants