fix review comments
This commit is contained in:
parent
f3e01c4f6a
commit
344888a582
5 changed files with 114 additions and 46 deletions
|
|
@ -16,6 +16,15 @@ fn should_warn_complex_case() {
|
|||
}));
|
||||
2
|
||||
];
|
||||
|
||||
let v1 = vec![
|
||||
Arc::new(Mutex::new({
|
||||
let x = 1;
|
||||
dbg!(x);
|
||||
x
|
||||
}));
|
||||
2
|
||||
];
|
||||
}
|
||||
|
||||
fn should_not_warn_custom_arc() {
|
||||
|
|
|
|||
|
|
@ -40,17 +40,47 @@ help: consider initializing each `Arc` element individually
|
|||
|
|
||||
LL ~ let v = {
|
||||
LL + let mut v = Vec::with_capacity(2);
|
||||
LL + (0..2).for_each(|_| v.push(std::sync::Arc::new..));
|
||||
LL + (0..2).for_each(|_| v.push(std::sync::Arc::new(..)));
|
||||
LL + v
|
||||
LL ~ };
|
||||
|
|
||||
help: or if this is intentional, consider extracting the `Arc` initialization to a variable
|
||||
|
|
||||
LL ~ let v = {
|
||||
LL + let data = std::sync::Arc::new..;
|
||||
LL + let data = std::sync::Arc::new(..);
|
||||
LL + vec![data; 2]
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: calling `Arc::new` in `vec![elem; len]`
|
||||
--> $DIR/arc.rs:20:14
|
||||
|
|
||||
LL | let v1 = vec![
|
||||
| ______________^
|
||||
LL | | Arc::new(Mutex::new({
|
||||
LL | | let x = 1;
|
||||
LL | | dbg!(x);
|
||||
... |
|
||||
LL | | 2
|
||||
LL | | ];
|
||||
| |_____^
|
||||
|
|
||||
= note: each element will point to the same `Arc` instance
|
||||
help: consider initializing each `Arc` element individually
|
||||
|
|
||||
LL ~ let v1 = {
|
||||
LL + let mut v = Vec::with_capacity(2);
|
||||
LL + (0..2).for_each(|_| v.push(Arc::new(..)));
|
||||
LL + v
|
||||
LL ~ };
|
||||
|
|
||||
help: or if this is intentional, consider extracting the `Arc` initialization to a variable
|
||||
|
|
||||
LL ~ let v1 = {
|
||||
LL + let data = Arc::new(..);
|
||||
LL + vec![data; 2]
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ fn should_warn_complex_case() {
|
|||
}));
|
||||
2
|
||||
];
|
||||
|
||||
let v1 = vec![
|
||||
Rc::new(Mutex::new({
|
||||
let x = 1;
|
||||
dbg!(x);
|
||||
x
|
||||
}));
|
||||
2
|
||||
];
|
||||
}
|
||||
|
||||
fn should_not_warn_custom_arc() {
|
||||
|
|
|
|||
|
|
@ -40,17 +40,47 @@ help: consider initializing each `Rc` element individually
|
|||
|
|
||||
LL ~ let v = {
|
||||
LL + let mut v = Vec::with_capacity(2);
|
||||
LL + (0..2).for_each(|_| v.push(std::rc::Rc::new..));
|
||||
LL + (0..2).for_each(|_| v.push(std::rc::Rc::new(..)));
|
||||
LL + v
|
||||
LL ~ };
|
||||
|
|
||||
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
||||
|
|
||||
LL ~ let v = {
|
||||
LL + let data = std::rc::Rc::new..;
|
||||
LL + let data = std::rc::Rc::new(..);
|
||||
LL + vec![data; 2]
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: calling `Rc::new` in `vec![elem; len]`
|
||||
--> $DIR/rc.rs:21:14
|
||||
|
|
||||
LL | let v1 = vec![
|
||||
| ______________^
|
||||
LL | | Rc::new(Mutex::new({
|
||||
LL | | let x = 1;
|
||||
LL | | dbg!(x);
|
||||
... |
|
||||
LL | | 2
|
||||
LL | | ];
|
||||
| |_____^
|
||||
|
|
||||
= note: each element will point to the same `Rc` instance
|
||||
help: consider initializing each `Rc` element individually
|
||||
|
|
||||
LL ~ let v1 = {
|
||||
LL + let mut v = Vec::with_capacity(2);
|
||||
LL + (0..2).for_each(|_| v.push(Rc::new(..)));
|
||||
LL + v
|
||||
LL ~ };
|
||||
|
|
||||
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
||||
|
|
||||
LL ~ let v1 = {
|
||||
LL + let data = Rc::new(..);
|
||||
LL + vec![data; 2]
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue