Auto merge of #62253 - Centril:rollup-115uuuq, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #62062 (Use a more efficient iteration order for forward dataflow)
 - #62063 (Use a more efficient iteration order for backward dataflow)
 - #62224 (rustdoc: remove unused derives and variants)
 - #62228 (Extend the #[must_use] lint to boxed types)
 - #62235 (Extend the `#[must_use]` lint to arrays)
 - #62239 (Fix a typo)
 - #62241 (Always parse 'async unsafe fn' + properly ban in 2015)
 - #62248 (before_exec actually will only get deprecated with 1.37)

Failed merges:

r? @ghost
This commit is contained in:
bors 2019-07-01 06:41:48 +00:00
commit 765eebf064
27 changed files with 359 additions and 119 deletions

View file

@ -134,11 +134,15 @@ trait Bar {
}
impl Foo {
async fn async_method(x: u8) -> u8 {
async fn async_assoc_item(x: u8) -> u8 {
unsafe {
unsafe_async_fn(x).await
}
}
async unsafe fn async_unsafe_assoc_item(x: u8) -> u8 {
unsafe_async_fn(x).await
}
}
fn test_future_yields_once_then_returns<F, Fut>(f: F)
@ -180,12 +184,17 @@ fn main() {
async_fn,
generic_async_fn,
async_fn_with_internal_borrow,
Foo::async_method,
Foo::async_assoc_item,
|x| {
async move {
unsafe { unsafe_async_fn(x).await }
}
},
|x| {
async move {
unsafe { Foo::async_unsafe_assoc_item(x).await }
}
},
}
test_with_borrow! {
async_block_with_borrow_named_lifetime,

View file

@ -28,6 +28,12 @@ fn main() {
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
}
accept_item! {
impl Foo {
async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
}
}
let inside_closure = || {
async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
};

View file

@ -23,7 +23,19 @@ LL | async fn async_baz() {
| ^^^^^
error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:32:9
--> $DIR/edition-deny-async-fns-2015.rs:16:5
|
LL | async fn foo() {}
| ^^^^^
error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:20:5
|
LL | async fn foo() {}
| ^^^^^
error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:38:9
|
LL | async fn bar() {}
| ^^^^^
@ -35,10 +47,10 @@ LL | async fn foo() {}
| ^^^^^
error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:16:5
--> $DIR/edition-deny-async-fns-2015.rs:33:13
|
LL | async fn foo() {}
| ^^^^^
LL | async fn bar() {}
| ^^^^^
error[E0706]: trait fns cannot be declared `async`
--> $DIR/edition-deny-async-fns-2015.rs:20:5
@ -46,12 +58,6 @@ error[E0706]: trait fns cannot be declared `async`
LL | async fn foo() {}
| ^^^^^^^^^^^^^^^^^
error[E0670]: `async fn` is not permitted in the 2015 edition
--> $DIR/edition-deny-async-fns-2015.rs:20:5
|
LL | async fn foo() {}
| ^^^^^
error: aborting due to 9 previous errors
error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0670`.

View file

@ -0,0 +1,11 @@
// edition:2018
struct S;
impl S {
#[cfg(FALSE)]
unsafe async fn g() {} //~ ERROR expected one of `extern` or `fn`, found `async`
}
#[cfg(FALSE)]
unsafe async fn f() {} //~ ERROR expected one of `extern`, `fn`, or `{`, found `async`

View file

@ -0,0 +1,14 @@
error: expected one of `extern` or `fn`, found `async`
--> $DIR/no-unsafe-async.rs:7:12
|
LL | unsafe async fn g() {}
| ^^^^^ expected one of `extern` or `fn` here
error: expected one of `extern`, `fn`, or `{`, found `async`
--> $DIR/no-unsafe-async.rs:11:8
|
LL | unsafe async fn f() {}
| ^^^^^ expected one of `extern`, `fn`, or `{` here
error: aborting due to 2 previous errors

View file

@ -0,0 +1,47 @@
#![deny(unused_must_use)]
#[must_use]
struct S;
struct A;
#[must_use]
trait T {}
impl T for A {}
fn empty() -> [S; 0] {
[]
}
fn singleton() -> [S; 1] {
[S]
}
fn many() -> [S; 4] {
[S, S, S, S]
}
fn array_of_impl_trait() -> [impl T; 2] {
[A, A]
}
fn impl_array() -> [(u8, Box<dyn T>); 2] {
[(0, Box::new(A)), (0, Box::new(A))]
}
fn array_of_arrays_of_arrays() -> [[[S; 1]; 2]; 1] {
[[[S], [S]]]
}
fn main() {
empty(); // ok
singleton(); //~ ERROR unused array of `S` that must be used
many(); //~ ERROR unused array of `S` that must be used
([S], 0, ()); //~ ERROR unused array of `S` in tuple element 0 that must be used
array_of_impl_trait(); //~ ERROR unused array of implementers of `T` that must be used
impl_array();
//~^ ERROR unused array of boxed `T` trait objects in tuple element 1 that must be used
array_of_arrays_of_arrays();
//~^ ERROR unused array of arrays of arrays of `S` that must be used
}

View file

@ -0,0 +1,44 @@
error: unused array of `S` that must be used
--> $DIR/must_use-array.rs:39:5
|
LL | singleton();
| ^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/must_use-array.rs:1:9
|
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
error: unused array of `S` that must be used
--> $DIR/must_use-array.rs:40:5
|
LL | many();
| ^^^^^^^
error: unused array of `S` in tuple element 0 that must be used
--> $DIR/must_use-array.rs:41:6
|
LL | ([S], 0, ());
| ^^^
error: unused array of implementers of `T` that must be used
--> $DIR/must_use-array.rs:42:5
|
LL | array_of_impl_trait();
| ^^^^^^^^^^^^^^^^^^^^^^
error: unused array of boxed `T` trait objects in tuple element 1 that must be used
--> $DIR/must_use-array.rs:43:5
|
LL | impl_array();
| ^^^^^^^^^^^^^
error: unused array of arrays of arrays of `S` that must be used
--> $DIR/must_use-array.rs:45:5
|
LL | array_of_arrays_of_arrays();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors

View file

@ -17,6 +17,23 @@ fn get_critical() -> impl NotSoCritical + Critical + DecidedlyUnimportant {
Anon {}
}
fn get_boxed_critical() -> Box<dyn Critical> {
Box::new(Anon {})
}
fn get_nested_boxed_critical() -> Box<Box<dyn Critical>> {
Box::new(Box::new(Anon {}))
}
fn get_critical_tuple() -> (u32, Box<dyn Critical>, impl Critical, ()) {
(0, get_boxed_critical(), get_critical(), ())
}
fn main() {
get_critical(); //~ ERROR unused implementer of `Critical` that must be used
get_boxed_critical(); //~ ERROR unused boxed `Critical` trait object that must be used
get_nested_boxed_critical();
//~^ ERROR unused boxed boxed `Critical` trait object that must be used
get_critical_tuple(); //~ ERROR unused boxed `Critical` trait object in tuple element 1
//~^ ERROR unused implementer of `Critical` in tuple element 2
}

View file

@ -1,5 +1,5 @@
error: unused implementer of `Critical` that must be used
--> $DIR/must_use-trait.rs:21:5
--> $DIR/must_use-trait.rs:33:5
|
LL | get_critical();
| ^^^^^^^^^^^^^^^
@ -10,5 +10,29 @@ note: lint level defined here
LL | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^
error: aborting due to previous error
error: unused boxed `Critical` trait object that must be used
--> $DIR/must_use-trait.rs:34:5
|
LL | get_boxed_critical();
| ^^^^^^^^^^^^^^^^^^^^^
error: unused boxed boxed `Critical` trait object that must be used
--> $DIR/must_use-trait.rs:35:5
|
LL | get_nested_boxed_critical();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unused boxed `Critical` trait object in tuple element 1 that must be used
--> $DIR/must_use-trait.rs:37:5
|
LL | get_critical_tuple();
| ^^^^^^^^^^^^^^^^^^^^^
error: unused implementer of `Critical` in tuple element 2 that must be used
--> $DIR/must_use-trait.rs:37:5
|
LL | get_critical_tuple();
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors