mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 00:56:14 +00:00
merge test
This commit is contained in:
parent
aff9c01ab9
commit
73cd2cde8b
@ -1,31 +0,0 @@
|
||||
#![warn(clippy::missing_panics_doc)]
|
||||
|
||||
pub fn option_unwrap<T>(v: &[T]) -> &T {
|
||||
let o: Option<&T> = v.last();
|
||||
o.unwrap()
|
||||
}
|
||||
|
||||
pub fn option_expect<T>(v: &[T]) -> &T {
|
||||
let o: Option<&T> = v.last();
|
||||
o.expect("passed an empty thing")
|
||||
}
|
||||
|
||||
pub fn result_unwrap<T>(v: &[T]) -> &T {
|
||||
let res: Result<&T, &str> = v.last().ok_or("oh noes");
|
||||
res.unwrap()
|
||||
}
|
||||
|
||||
pub fn result_expect<T>(v: &[T]) -> &T {
|
||||
let res: Result<&T, &str> = v.last().ok_or("oh noes");
|
||||
res.expect("passed an empty thing")
|
||||
}
|
||||
|
||||
pub fn last_unwrap(v: &[u32]) -> u32 {
|
||||
*v.last().unwrap()
|
||||
}
|
||||
|
||||
pub fn last_expect(v: &[u32]) -> u32 {
|
||||
*v.last().expect("passed an empty thing")
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,75 +0,0 @@
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:3:1
|
||||
|
|
||||
LL | pub fn option_unwrap<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:5:5
|
||||
|
|
||||
LL | o.unwrap()
|
||||
| ^^^^^^^^^^
|
||||
= note: `-D clippy::missing-panics-doc` implied by `-D warnings`
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:8:1
|
||||
|
|
||||
LL | pub fn option_expect<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:10:5
|
||||
|
|
||||
LL | o.expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:13:1
|
||||
|
|
||||
LL | pub fn result_unwrap<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:15:5
|
||||
|
|
||||
LL | res.unwrap()
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:18:1
|
||||
|
|
||||
LL | pub fn result_expect<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:20:5
|
||||
|
|
||||
LL | res.expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:23:1
|
||||
|
|
||||
LL | pub fn last_unwrap(v: &[u32]) -> u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:24:6
|
||||
|
|
||||
LL | *v.last().unwrap()
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:27:1
|
||||
|
|
||||
LL | pub fn last_expect(v: &[u32]) -> u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:28:6
|
||||
|
|
||||
LL | *v.last().expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
@ -151,3 +151,35 @@ pub fn debug_assertions() {
|
||||
debug_assert_eq!(1, 2);
|
||||
debug_assert_ne!(1, 2);
|
||||
}
|
||||
|
||||
// all function must be triggered the lint.
|
||||
// `pub` is required, because the lint does not consider unreachable items
|
||||
pub mod issue10240 {
|
||||
pub fn option_unwrap<T>(v: &[T]) -> &T {
|
||||
let o: Option<&T> = v.last();
|
||||
o.unwrap()
|
||||
}
|
||||
|
||||
pub fn option_expect<T>(v: &[T]) -> &T {
|
||||
let o: Option<&T> = v.last();
|
||||
o.expect("passed an empty thing")
|
||||
}
|
||||
|
||||
pub fn result_unwrap<T>(v: &[T]) -> &T {
|
||||
let res: Result<&T, &str> = v.last().ok_or("oh noes");
|
||||
res.unwrap()
|
||||
}
|
||||
|
||||
pub fn result_expect<T>(v: &[T]) -> &T {
|
||||
let res: Result<&T, &str> = v.last().ok_or("oh noes");
|
||||
res.expect("passed an empty thing")
|
||||
}
|
||||
|
||||
pub fn last_unwrap(v: &[u32]) -> u32 {
|
||||
*v.last().unwrap()
|
||||
}
|
||||
|
||||
pub fn last_expect(v: &[u32]) -> u32 {
|
||||
*v.last().expect("passed an empty thing")
|
||||
}
|
||||
}
|
||||
|
@ -83,5 +83,77 @@ note: first possible panic found here
|
||||
LL | assert_ne!(x, 0);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:158:5
|
||||
|
|
||||
LL | pub fn option_unwrap<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:160:9
|
||||
|
|
||||
LL | o.unwrap()
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:163:5
|
||||
|
|
||||
LL | pub fn option_expect<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:165:9
|
||||
|
|
||||
LL | o.expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:168:5
|
||||
|
|
||||
LL | pub fn result_unwrap<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:170:9
|
||||
|
|
||||
LL | res.unwrap()
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:173:5
|
||||
|
|
||||
LL | pub fn result_expect<T>(v: &[T]) -> &T {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:175:9
|
||||
|
|
||||
LL | res.expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:178:5
|
||||
|
|
||||
LL | pub fn last_unwrap(v: &[u32]) -> u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:179:10
|
||||
|
|
||||
LL | *v.last().unwrap()
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: docs for function which may panic missing `# Panics` section
|
||||
--> $DIR/missing_panics_doc.rs:182:5
|
||||
|
|
||||
LL | pub fn last_expect(v: &[u32]) -> u32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first possible panic found here
|
||||
--> $DIR/missing_panics_doc.rs:183:10
|
||||
|
|
||||
LL | *v.last().expect("passed an empty thing")
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user