Skip to content

rc_buffer expands type aliases, which breaks scoping #6238

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

Open
jyn514 opened this issue Oct 27, 2020 · 3 comments
Open

rc_buffer expands type aliases, which breaks scoping #6238

jyn514 opened this issue Oct 27, 2020 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@jyn514
Copy link
Member

jyn514 commented Oct 27, 2020

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)
@jyn514 jyn514 added the C-bug Category: Clippy is not doing the correct thing label Oct 27, 2020
@jyn514
Copy link
Member Author

jyn514 commented Dec 29, 2020

And related: unnecessary_cast expands c_uint to u32, which will break on platforms where it's u16 or u64.

diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index f122fa14e70..568959631d9 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -1420,7 +1420,7 @@ pub(crate) fn phi(
 
     fn add_incoming_to_phi(&mut self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) {
         unsafe {
-            llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
+            llvm::LLVMAddIncoming(phi, &val, &bb, 1_u32);
         }
     }
 

(in practice, c_uint is always u32, but this could be relevant if this were c_ulong or something.)

@kraktus
Copy link
Contributor

kraktus commented Oct 2, 2022

since #8596 unnecessary_cast does not lint type aliases at all anymore, so I guess this can be closed

@jyn514
Copy link
Member Author

jyn514 commented Oct 2, 2022

@kraktus what about rc_buffer?

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
Projects
None yet
Development

No branches or pull requests

2 participants