mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Extend testing of rc_buffer lint
This commit is contained in:
parent
2dd7175d60
commit
d0ddbb9d0d
6 changed files with 122 additions and 37 deletions
|
@ -1,13 +1,26 @@
|
|||
#![warn(clippy::rc_buffer)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[warn(clippy::rc_buffer)]
|
||||
struct S {
|
||||
a: Rc<String>,
|
||||
b: Rc<PathBuf>,
|
||||
c: Rc<Vec<u8>>,
|
||||
d: Rc<OsString>,
|
||||
// triggers lint
|
||||
bad1: Rc<String>,
|
||||
bad2: Rc<PathBuf>,
|
||||
bad3: Rc<Vec<u8>>,
|
||||
bad4: Rc<OsString>,
|
||||
// does not trigger lint
|
||||
good1: Rc<RefCell<String>>,
|
||||
}
|
||||
|
||||
// triggers lint
|
||||
fn func_bad1(_: Rc<String>) {}
|
||||
fn func_bad2(_: Rc<PathBuf>) {}
|
||||
fn func_bad3(_: Rc<Vec<u8>>) {}
|
||||
fn func_bad4(_: Rc<OsString>) {}
|
||||
// does not trigger lint
|
||||
fn func_good1(_: Rc<RefCell<String>>) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,28 +1,52 @@
|
|||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:7:8
|
||||
--> $DIR/rc_buffer.rs:10:11
|
||||
|
|
||||
LL | a: Rc<String>,
|
||||
| ^^^^^^^^^^ help: try: `Rc<str>`
|
||||
LL | bad1: Rc<String>,
|
||||
| ^^^^^^^^^^ help: try: `Rc<str>`
|
||||
|
|
||||
= note: `-D clippy::rc-buffer` implied by `-D warnings`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:8:8
|
||||
--> $DIR/rc_buffer.rs:11:11
|
||||
|
|
||||
LL | b: Rc<PathBuf>,
|
||||
| ^^^^^^^^^^^ help: try: `Rc<std::path::Path>`
|
||||
LL | bad2: Rc<PathBuf>,
|
||||
| ^^^^^^^^^^^ help: try: `Rc<std::path::Path>`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:9:8
|
||||
--> $DIR/rc_buffer.rs:12:11
|
||||
|
|
||||
LL | c: Rc<Vec<u8>>,
|
||||
| ^^^^^^^^^^^ help: try: `Rc<[u8]>`
|
||||
LL | bad3: Rc<Vec<u8>>,
|
||||
| ^^^^^^^^^^^ help: try: `Rc<[u8]>`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:10:8
|
||||
--> $DIR/rc_buffer.rs:13:11
|
||||
|
|
||||
LL | d: Rc<OsString>,
|
||||
| ^^^^^^^^^^^^ help: try: `Rc<std::ffi::OsStr>`
|
||||
LL | bad4: Rc<OsString>,
|
||||
| ^^^^^^^^^^^^ help: try: `Rc<std::ffi::OsStr>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:19:17
|
||||
|
|
||||
LL | fn func_bad1(_: Rc<String>) {}
|
||||
| ^^^^^^^^^^ help: try: `Rc<str>`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:20:17
|
||||
|
|
||||
LL | fn func_bad2(_: Rc<PathBuf>) {}
|
||||
| ^^^^^^^^^^^ help: try: `Rc<std::path::Path>`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:21:17
|
||||
|
|
||||
LL | fn func_bad3(_: Rc<Vec<u8>>) {}
|
||||
| ^^^^^^^^^^^ help: try: `Rc<[u8]>`
|
||||
|
||||
error: usage of `Rc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer.rs:22:17
|
||||
|
|
||||
LL | fn func_bad4(_: Rc<OsString>) {}
|
||||
| ^^^^^^^^^^^^ help: try: `Rc<std::ffi::OsStr>`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
#![warn(clippy::rc_buffer)]
|
||||
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[warn(clippy::rc_buffer)]
|
||||
struct S {
|
||||
a: Arc<String>,
|
||||
b: Arc<PathBuf>,
|
||||
c: Arc<Vec<u8>>,
|
||||
d: Arc<OsString>,
|
||||
// triggers lint
|
||||
bad1: Arc<String>,
|
||||
bad2: Arc<PathBuf>,
|
||||
bad3: Arc<Vec<u8>>,
|
||||
bad4: Arc<OsString>,
|
||||
// does not trigger lint
|
||||
good1: Arc<Mutex<String>>,
|
||||
}
|
||||
|
||||
// triggers lint
|
||||
fn func_bad1(_: Arc<String>) {}
|
||||
fn func_bad2(_: Arc<PathBuf>) {}
|
||||
fn func_bad3(_: Arc<Vec<u8>>) {}
|
||||
fn func_bad4(_: Arc<OsString>) {}
|
||||
// does not trigger lint
|
||||
fn func_good1(_: Arc<Mutex<String>>) {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,28 +1,52 @@
|
|||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:7:8
|
||||
--> $DIR/rc_buffer_arc.rs:9:11
|
||||
|
|
||||
LL | a: Arc<String>,
|
||||
| ^^^^^^^^^^^ help: try: `Arc<str>`
|
||||
LL | bad1: Arc<String>,
|
||||
| ^^^^^^^^^^^ help: try: `Arc<str>`
|
||||
|
|
||||
= note: `-D clippy::rc-buffer` implied by `-D warnings`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:8:8
|
||||
--> $DIR/rc_buffer_arc.rs:10:11
|
||||
|
|
||||
LL | b: Arc<PathBuf>,
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<std::path::Path>`
|
||||
LL | bad2: Arc<PathBuf>,
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<std::path::Path>`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:9:8
|
||||
--> $DIR/rc_buffer_arc.rs:11:11
|
||||
|
|
||||
LL | c: Arc<Vec<u8>>,
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<[u8]>`
|
||||
LL | bad3: Arc<Vec<u8>>,
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<[u8]>`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:10:8
|
||||
--> $DIR/rc_buffer_arc.rs:12:11
|
||||
|
|
||||
LL | d: Arc<OsString>,
|
||||
| ^^^^^^^^^^^^^ help: try: `Arc<std::ffi::OsStr>`
|
||||
LL | bad4: Arc<OsString>,
|
||||
| ^^^^^^^^^^^^^ help: try: `Arc<std::ffi::OsStr>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:18:17
|
||||
|
|
||||
LL | fn func_bad1(_: Arc<String>) {}
|
||||
| ^^^^^^^^^^^ help: try: `Arc<str>`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:19:17
|
||||
|
|
||||
LL | fn func_bad2(_: Arc<PathBuf>) {}
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<std::path::Path>`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:20:17
|
||||
|
|
||||
LL | fn func_bad3(_: Arc<Vec<u8>>) {}
|
||||
| ^^^^^^^^^^^^ help: try: `Arc<[u8]>`
|
||||
|
||||
error: usage of `Arc<T>` when T is a buffer type
|
||||
--> $DIR/rc_buffer_arc.rs:21:17
|
||||
|
|
||||
LL | fn func_bad4(_: Arc<OsString>) {}
|
||||
| ^^^^^^^^^^^^^ help: try: `Arc<std::ffi::OsStr>`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
12
tests/ui/rc_buffer_redefined_string.rs
Normal file
12
tests/ui/rc_buffer_redefined_string.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
#![warn(clippy::rc_buffer)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct String;
|
||||
|
||||
struct S {
|
||||
// does not trigger lint
|
||||
good1: Rc<String>,
|
||||
}
|
||||
|
||||
fn main() {}
|
0
tests/ui/rc_buffer_redefined_string.stderr
Normal file
0
tests/ui/rc_buffer_redefined_string.stderr
Normal file
Loading…
Reference in a new issue