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

rc_buffer should not be marked as MachineApplicable #6241

Closed
jyn514 opened this issue Oct 27, 2020 · 1 comment · Fixed by #9633
Closed

rc_buffer should not be marked as MachineApplicable #6241

jyn514 opened this issue Oct 27, 2020 · 1 comment · Fixed by #9633
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@jyn514
Copy link
Member

jyn514 commented Oct 27, 2020

I tried this code (https://github.com/rust-lang/rust/blob/0da6d42f297642a60f2640ec313b879b376b9ad8/compiler/rustc_passes/src/liveness.rs#L262):

    fn set_captures(&mut self, hir_id: HirId, cs: Vec<CaptureInfo>) {
        self.capture_info_map.insert(hir_id, Rc::new(cs));
    }

I expected to see this happen: rc_buffer warns, but doesn't change the code since it would also have to change the type of capture_info_map.

Instead, this happened: rc_buffer tries and fails to substitute the types.

error[E0308]: mismatched types
   --> compiler/rustc_passes/src/liveness.rs:262:46
    |
262 |         self.capture_info_map.insert(hir_id, Rc::new(cs));
    |                                              ^^^^^^^^^^^ expected slice, found struct `std::vec::Vec`
    |
    = note: expected struct `std::rc::Rc<[liveness::CaptureInfo]>`
               found struct `std::rc::Rc<std::vec::Vec<liveness::CaptureInfo>>`

warning: usage of `Rc<T>` when T is a buffer type
   --> compiler/rustc_passes/src/liveness.rs:193:32
    |
193 |     capture_info_map: HirIdMap<Rc<Vec<CaptureInfo>>>,
    |                                ^^^^^^^^^^^^^^^^^^^^ help: try: `Rc<[CaptureInfo]>`
    |
    = note: `#[warn(clippy::rc_buffer)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer

Meta

  • cargo clippy -V: clippy 0.0.212 (ffa2e7a 2020-10-24)
@jyn514 jyn514 added the C-bug Category: Clippy is not doing the correct thing label Oct 27, 2020
@phansch phansch added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Dec 18, 2020
@camsteffen camsteffen added the good-first-issue These issues are a good way to get started with Clippy label Feb 8, 2021
@roynrishingha
Copy link
Contributor

@rustbot claim

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 good-first-issue These issues are a good way to get started with Clippy 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.

4 participants