Merge remote-tracking branch 'upstream/master' into rustup
This commit is contained in:
commit
c6a577ea11
14 changed files with 110 additions and 32 deletions
|
|
@ -1,7 +1,19 @@
|
|||
#[warn(clippy::as_conversions)]
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![warn(clippy::as_conversions)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate macro_rules;
|
||||
|
||||
fn with_external_macro() {
|
||||
as_conv_with_arg!(0u32 as u64);
|
||||
as_conv!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = 0u32 as u64;
|
||||
|
||||
let j = &i as *const u64 as *mut u64;
|
||||
|
||||
with_external_macro();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:4:13
|
||||
--> $DIR/as_conversions.rs:14:13
|
||||
|
|
||||
LL | let i = 0u32 as u64;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -8,7 +8,7 @@ LL | let i = 0u32 as u64;
|
|||
= help: consider using a safe wrapper for this conversion
|
||||
|
||||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:6:13
|
||||
--> $DIR/as_conversions.rs:16:13
|
||||
|
|
||||
LL | let j = &i as *const u64 as *mut u64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -16,7 +16,7 @@ LL | let j = &i as *const u64 as *mut u64;
|
|||
= help: consider using a safe wrapper for this conversion
|
||||
|
||||
error: using a potentially dangerous silent `as` conversion
|
||||
--> $DIR/as_conversions.rs:6:13
|
||||
--> $DIR/as_conversions.rs:16:13
|
||||
|
|
||||
LL | let j = &i as *const u64 as *mut u64;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -70,3 +70,17 @@ macro_rules! ref_arg_function {
|
|||
fn fun_example(ref _x: usize) {}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! as_conv_with_arg {
|
||||
(0u32 as u64) => {
|
||||
()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! as_conv {
|
||||
() => {
|
||||
0u32 as u64
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,24 @@ fn main() {
|
|||
let sample = vec![a.clone(), "b".to_string(), "c".to_string()];
|
||||
let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
|
||||
non_copy_contains.contains(&a);
|
||||
|
||||
// Fix #5991
|
||||
let vec_a = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let vec_b = vec_a.iter().collect::<Vec<_>>();
|
||||
if vec_b.len() > 3 {}
|
||||
let other_vec = vec![1, 3, 12, 4, 16, 2];
|
||||
let we_got_the_same_numbers = other_vec.iter().filter(|item| vec_b.contains(item)).collect::<Vec<_>>();
|
||||
|
||||
// Fix #6297
|
||||
let sample = [1; 5];
|
||||
let multiple_indirect = sample.iter().collect::<Vec<_>>();
|
||||
let sample2 = vec![2, 3];
|
||||
if multiple_indirect.is_empty() {
|
||||
// do something
|
||||
} else {
|
||||
let found = sample2
|
||||
.iter()
|
||||
.filter(|i| multiple_indirect.iter().any(|s| **s % **i == 0))
|
||||
.collect::<Vec<_>>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![warn(clippy::temporary_assignment)]
|
||||
#![allow(const_item_mutation)]
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: assignment to temporary
|
||||
--> $DIR/temporary_assignment.rs:48:5
|
||||
--> $DIR/temporary_assignment.rs:47:5
|
||||
|
|
||||
LL | Struct { field: 0 }.field = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -7,7 +7,7 @@ LL | Struct { field: 0 }.field = 1;
|
|||
= note: `-D clippy::temporary-assignment` implied by `-D warnings`
|
||||
|
||||
error: assignment to temporary
|
||||
--> $DIR/temporary_assignment.rs:49:5
|
||||
--> $DIR/temporary_assignment.rs:48:5
|
||||
|
|
||||
LL | / MultiStruct {
|
||||
LL | | structure: Struct { field: 0 },
|
||||
|
|
@ -17,13 +17,13 @@ LL | | .field = 1;
|
|||
| |______________^
|
||||
|
||||
error: assignment to temporary
|
||||
--> $DIR/temporary_assignment.rs:54:5
|
||||
--> $DIR/temporary_assignment.rs:53:5
|
||||
|
|
||||
LL | ArrayStruct { array: [0] }.array[0] = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: assignment to temporary
|
||||
--> $DIR/temporary_assignment.rs:55:5
|
||||
--> $DIR/temporary_assignment.rs:54:5
|
||||
|
|
||||
LL | (0, 0).0 = 1;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -20,4 +20,7 @@ fn main() {
|
|||
foo!(a, i32);
|
||||
foo!(b, f32);
|
||||
foo!(c, f64);
|
||||
|
||||
// do not lint cast to cfg-dependant type
|
||||
1 as std::os::raw::c_char;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
dead_code,
|
||||
clippy::single_match,
|
||||
clippy::wildcard_in_or_patterns,
|
||||
clippy::unnested_or_patterns, clippy::diverging_sub_expression
|
||||
clippy::unnested_or_patterns,
|
||||
clippy::diverging_sub_expression
|
||||
)]
|
||||
|
||||
use std::io::ErrorKind;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
dead_code,
|
||||
clippy::single_match,
|
||||
clippy::wildcard_in_or_patterns,
|
||||
clippy::unnested_or_patterns, clippy::diverging_sub_expression
|
||||
clippy::unnested_or_patterns,
|
||||
clippy::diverging_sub_expression
|
||||
)]
|
||||
|
||||
use std::io::ErrorKind;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: wildcard match will miss any future added variants
|
||||
--> $DIR/wildcard_enum_match_arm.rs:38:9
|
||||
--> $DIR/wildcard_enum_match_arm.rs:39:9
|
||||
|
|
||||
LL | _ => eprintln!("Not red"),
|
||||
| ^ help: try this: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
|
||||
|
|
@ -11,25 +11,25 @@ LL | #![deny(clippy::wildcard_enum_match_arm)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: wildcard match will miss any future added variants
|
||||
--> $DIR/wildcard_enum_match_arm.rs:42:9
|
||||
--> $DIR/wildcard_enum_match_arm.rs:43:9
|
||||
|
|
||||
LL | _not_red => eprintln!("Not red"),
|
||||
| ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan`
|
||||
|
||||
error: wildcard match will miss any future added variants
|
||||
--> $DIR/wildcard_enum_match_arm.rs:46:9
|
||||
--> $DIR/wildcard_enum_match_arm.rs:47:9
|
||||
|
|
||||
LL | not_red => format!("{:?}", not_red),
|
||||
| ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan`
|
||||
|
||||
error: wildcard match will miss any future added variants
|
||||
--> $DIR/wildcard_enum_match_arm.rs:62:9
|
||||
--> $DIR/wildcard_enum_match_arm.rs:63:9
|
||||
|
|
||||
LL | _ => "No red",
|
||||
| ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
|
||||
|
||||
error: match on non-exhaustive enum doesn't explicitly match all known variants
|
||||
--> $DIR/wildcard_enum_match_arm.rs:79:9
|
||||
--> $DIR/wildcard_enum_match_arm.rs:80:9
|
||||
|
|
||||
LL | _ => {},
|
||||
| ^ help: try this: `std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted | std::io::ErrorKind::NotConnected | std::io::ErrorKind::AddrInUse | std::io::ErrorKind::AddrNotAvailable | std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::AlreadyExists | std::io::ErrorKind::WouldBlock | std::io::ErrorKind::InvalidInput | std::io::ErrorKind::InvalidData | std::io::ErrorKind::TimedOut | std::io::ErrorKind::WriteZero | std::io::ErrorKind::Interrupted | std::io::ErrorKind::Other | std::io::ErrorKind::UnexpectedEof | _`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue