Skip to content

rc_buffer hardcodes Rc/Arc in suggestion, which might not be in scope #15802

@ada4a

Description

@ada4a

Summary

rc_buffer suggests replacing e.g. std::rc::Rc<Vec<T>> with Rc<[T]>, removing the qualification of Rc -- which can break if Rc is not actually imported.

Reproducer

I tried this code:

#![allow(unused)]
#![warn(clippy::rc_buffer)]

fn foo(_: std::rc::Rc<Vec<i32>>) {}

I expected to see this happen:

warning: usage of `Rc<T>` when T is a buffer type
 --> src/lib.rs:4:11
  |
4 | fn foo(_: std::rc::Rc<Vec<i32>>) {}
  |           ^^^^^^^^^^^^^^^^^^^^^ help: try: `std::rc::Rc<[i32]>`
  |

Instead, this happened:

warning: usage of `Rc<T>` when T is a buffer type
 --> src/lib.rs:4:11
  |
4 | fn foo(_: std::rc::Rc<Vec<i32>>) {}
  |           ^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc<[i32]>`
  |

Version

rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8

Additional Labels

@rustbot label I-suggestion-causes-error

@rustbot claim

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions