Skip to content

rc_buffer expands type aliases, which breaks scoping #6238

Open
@jyn514

Description

@jyn514

I tried this code (https://github.com/rust-lang/rust/blob/a6ff925f8b5598a1f6d84964525baa1d4a08fd63/compiler/rustc_infer/src/infer/region_constraints/mod.rs#L545):

type Lrc = std::rc::Rc;

fn f(choice_regions: &Lrc<Vec<ty::Region<'tcx>>>)

I expected to see this happen: Clippy suggests Lrc<[ty::Region<'tcx>]>

Instead, this happened: Clippy suggests Rc<[ty::Region<'tcx>]>

The following errors were reported:
error[E0412]: cannot find type `Rc` in this scope
   --> compiler/rustc_infer/src/infer/region_constraints/mod.rs:545:26
    |
545 |         choice_regions: &Rc<[ty::Region<'tcx>]>,
    |                          ^^ not found in this scope
    |
help: consider importing one of these items
    |
3   | use crate::infer::combine::ast::mut_visit::process::imp::process_inner::sys::ext::net::sys_common::wtf8::Rc;
    |
3   | use std::rc::Rc;

warning: usage of `Rc<T>` when T is a buffer type
   --> compiler/rustc_infer/src/infer/region_constraints/mod.rs:545:26
    |
545 |         choice_regions: &Lrc<Vec<ty::Region<'tcx>>>,
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc<[ty::Region<'tcx>]>`
    |
    = 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 (4760b8f 2020-10-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions