Skip to content

Commit 35f93c5

Browse files
committed
update tests
1 parent daab765 commit 35f93c5

14 files changed

+103
-111
lines changed

tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
use std::fmt::Debug;
33

44
fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
5-
//~^ ERROR cannot resolve opaque type
6-
//~| WARNING elided lifetime has a name
5+
//~^ WARNING elided lifetime has a name
76
|x| x
87
//~^ ERROR expected generic lifetime parameter, found `'_`
98
}

tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr

+4-14
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,14 @@ LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
77
= note: `#[warn(elided_named_lifetimes)]` on by default
88

99
error[E0792]: expected generic lifetime parameter, found `'_`
10-
--> $DIR/impl-fn-predefined-lifetimes.rs:7:9
10+
--> $DIR/impl-fn-predefined-lifetimes.rs:6:9
1111
|
1212
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
1313
| -- this generic parameter must be used with a generic lifetime parameter
14-
...
14+
LL |
1515
LL | |x| x
1616
| ^
1717

18-
error[E0720]: cannot resolve opaque type
19-
--> $DIR/impl-fn-predefined-lifetimes.rs:4:35
20-
|
21-
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
22-
| ^^^^^^^^^^^^^^^ recursive opaque type
23-
...
24-
LL | |x| x
25-
| ----- returning here with type `{closure@$DIR/impl-fn-predefined-lifetimes.rs:7:5: 7:8}`
26-
27-
error: aborting due to 2 previous errors; 1 warning emitted
18+
error: aborting due to 1 previous error; 1 warning emitted
2819

29-
Some errors have detailed explanations: E0720, E0792.
30-
For more information about an error, try `rustc --explain E0720`.
20+
For more information about this error, try `rustc --explain E0792`.

tests/ui/impl-trait/issues/issue-86800.rs

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ impl Context {
4040
f: impl FnOnce(&mut dyn Transaction) -> TransactionFuture<'_, O>,
4141
) -> TransactionResult<O> {
4242
//~^ ERROR expected generic lifetime parameter, found `'_`
43-
//~| ERROR: item does not constrain
4443
let mut conn = Connection {};
4544
let mut transaction = TestTransaction { conn: &mut conn };
4645
f(&mut transaction).await

tests/ui/impl-trait/issues/issue-86800.stderr

+1-22
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ note: this opaque type is supposed to be constrained
2424
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626

27-
error: item does not constrain `TransactionFuture::{opaque#0}`
28-
--> $DIR/issue-86800.rs:41:31
29-
|
30-
LL | ) -> TransactionResult<O> {
31-
| _______________________________^
32-
LL | |
33-
LL | |
34-
LL | | let mut conn = Connection {};
35-
LL | | let mut transaction = TestTransaction { conn: &mut conn };
36-
LL | | f(&mut transaction).await
37-
LL | | }
38-
| |_____^
39-
|
40-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
41-
note: this opaque type is supposed to be constrained
42-
--> $DIR/issue-86800.rs:21:34
43-
|
44-
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
45-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46-
4727
error[E0792]: expected generic lifetime parameter, found `'_`
4828
--> $DIR/issue-86800.rs:31:5
4929
|
@@ -62,13 +42,12 @@ LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionRe
6242
LL | ) -> TransactionResult<O> {
6343
| _______________________________^
6444
LL | |
65-
LL | |
6645
LL | | let mut conn = Connection {};
6746
LL | | let mut transaction = TestTransaction { conn: &mut conn };
6847
LL | | f(&mut transaction).await
6948
LL | | }
7049
| |_____^
7150

72-
error: aborting due to 5 previous errors
51+
error: aborting due to 4 previous errors
7352

7453
For more information about this error, try `rustc --explain E0792`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ edition:2021
2+
3+
struct AnyOption<T>(T);
4+
impl<T> AnyOption<T> {
5+
const NONE: Option<T> = None;
6+
}
7+
8+
// This is an unfortunate side-effect of borrowchecking nested items
9+
// together with their parent. Evaluating the `AnyOption::<_>::NONE`
10+
// pattern for exhaustiveness checking relies on the layout of the
11+
// async block. This layout relies on `optimized_mir` of the nested
12+
// item which is now borrowck'd together with its parent. As
13+
// borrowck of the parent requires us to have already lowered the match,
14+
// this is a query cycle.
15+
16+
fn uwu() {}
17+
fn defines() {
18+
match Some(async {}) {
19+
AnyOption::<_>::NONE => {}
20+
//~^ ERROR cycle detected when building THIR for `defines`
21+
_ => {}
22+
}
23+
}
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
error[E0391]: cycle detected when building THIR for `defines`
2+
--> $DIR/non-structural-match-types-cycle-err.rs:19:9
3+
|
4+
LL | AnyOption::<_>::NONE => {}
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
|
7+
note: ...which requires evaluating type-level constant...
8+
--> $DIR/non-structural-match-types-cycle-err.rs:5:5
9+
|
10+
LL | const NONE: Option<T> = None;
11+
| ^^^^^^^^^^^^^^^^^^^^^
12+
note: ...which requires const-evaluating + checking `<impl at $DIR/non-structural-match-types-cycle-err.rs:4:1: 4:21>::NONE`...
13+
--> $DIR/non-structural-match-types-cycle-err.rs:5:5
14+
|
15+
LL | const NONE: Option<T> = None;
16+
| ^^^^^^^^^^^^^^^^^^^^^
17+
= note: ...which requires computing layout of `core::option::Option<{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}>`...
18+
= note: ...which requires computing layout of `{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}`...
19+
note: ...which requires optimizing MIR for `defines::{closure#0}`...
20+
--> $DIR/non-structural-match-types-cycle-err.rs:18:16
21+
|
22+
LL | match Some(async {}) {
23+
| ^^^^^
24+
note: ...which requires elaborating drops for `defines::{closure#0}`...
25+
--> $DIR/non-structural-match-types-cycle-err.rs:18:16
26+
|
27+
LL | match Some(async {}) {
28+
| ^^^^^
29+
note: ...which requires borrow-checking `defines`...
30+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
31+
|
32+
LL | fn defines() {
33+
| ^^^^^^^^^^^^
34+
note: ...which requires promoting constants in MIR for `defines`...
35+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
36+
|
37+
LL | fn defines() {
38+
| ^^^^^^^^^^^^
39+
note: ...which requires checking if `defines` contains FFI-unwind calls...
40+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
41+
|
42+
LL | fn defines() {
43+
| ^^^^^^^^^^^^
44+
note: ...which requires building MIR for `defines`...
45+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
46+
|
47+
LL | fn defines() {
48+
| ^^^^^^^^^^^^
49+
note: ...which requires match-checking `defines`...
50+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
51+
|
52+
LL | fn defines() {
53+
| ^^^^^^^^^^^^
54+
= note: ...which again requires building THIR for `defines`, completing the cycle
55+
note: cycle used when unsafety-checking `defines`
56+
--> $DIR/non-structural-match-types-cycle-err.rs:17:1
57+
|
58+
LL | fn defines() {
59+
| ^^^^^^^^^^^^
60+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
61+
62+
error: aborting due to 1 previous error
63+
64+
For more information about this error, try `rustc --explain E0391`.

tests/ui/pattern/non-structural-match-types.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ edition:2021
2-
#![feature(const_async_blocks)]
32

43
struct AnyOption<T>(T);
54
impl<T> AnyOption<T> {
@@ -19,11 +18,5 @@ fn defines() {
1918
//~^ ERROR constant of non-structural type
2019
_ => {}
2120
}
22-
23-
match Some(async {}) {
24-
AnyOption::<_>::NONE => {}
25-
//~^ ERROR constant of non-structural type
26-
_ => {}
27-
}
2821
}
2922
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: constant of non-structural type `Option<fn() {uwu}>` in a pattern
2-
--> $DIR/non-structural-match-types.rs:12:9
2+
--> $DIR/non-structural-match-types.rs:11:9
33
|
44
LL | impl<T> AnyOption<T> {
55
| --------------------
@@ -11,8 +11,8 @@ LL | AnyOption::<_>::NONE => {}
1111
|
1212
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
1313

14-
error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:17:16: 17:18}>` in a pattern
15-
--> $DIR/non-structural-match-types.rs:18:9
14+
error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:16:16: 16:18}>` in a pattern
15+
--> $DIR/non-structural-match-types.rs:17:9
1616
|
1717
LL | impl<T> AnyOption<T> {
1818
| --------------------
@@ -24,19 +24,5 @@ LL | AnyOption::<_>::NONE => {}
2424
|
2525
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
2626

27-
error: constant of non-structural type `Option<{async block@$DIR/non-structural-match-types.rs:23:16: 23:21}>` in a pattern
28-
--> $DIR/non-structural-match-types.rs:24:9
29-
|
30-
LL | impl<T> AnyOption<T> {
31-
| --------------------
32-
LL | const NONE: Option<T> = None;
33-
| --------------------- constant defined here
34-
...
35-
LL | AnyOption::<_>::NONE => {}
36-
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
37-
|
38-
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
39-
= note: `ResumeTy` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
40-
41-
error: aborting due to 3 previous errors
27+
error: aborting due to 2 previous errors
4228

tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr

+1-18
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,5 @@ note: this opaque type is supposed to be constrained
1919
LL | type Bar = impl std::fmt::Display;
2020
| ^^^^^^^^^^^^^^^^^^^^^^
2121

22-
error: item does not constrain `Bar::{opaque#0}`
23-
--> $DIR/const_generic_type.rs:8:31
24-
|
25-
LL | async fn test<const N: Bar>() {
26-
| _______________________________^
27-
... |
28-
LL | | let x: u32 = N;
29-
LL | | }
30-
| |_^
31-
|
32-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
33-
note: this opaque type is supposed to be constrained
34-
--> $DIR/const_generic_type.rs:5:12
35-
|
36-
LL | type Bar = impl std::fmt::Display;
37-
| ^^^^^^^^^^^^^^^^^^^^^^
38-
39-
error: aborting due to 3 previous errors
22+
error: aborting due to 2 previous errors
4023

tests/ui/type-alias-impl-trait/const_generic_type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ type Bar = impl std::fmt::Display;
88
async fn test<const N: Bar>() {
99
//~^ ERROR: `Bar` is forbidden as the type of a const generic parameter
1010
//[no_infer]~^^ ERROR item does not constrain
11-
//[no_infer]~| ERROR item does not constrain
1211
#[cfg(infer)]
1312
let x: u32 = N;
1413
}

tests/ui/type-alias-impl-trait/hkl_forbidden4.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ where
2222
for<'any> F: FnMut(&'any mut ()) -> FutNothing<'any>,
2323
{
2424
//~^ ERROR: expected generic lifetime parameter, found `'any`
25-
//~| ERROR item does not constrain
2625
}
2726

2827
fn main() {}

tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr

+2-17
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ note: this opaque type is supposed to be constrained
1111
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

14-
error: item does not constrain `FutNothing::{opaque#0}`
15-
--> $DIR/hkl_forbidden4.rs:23:1
16-
|
17-
LL | / {
18-
... |
19-
LL | | }
20-
| |_^
21-
|
22-
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
23-
note: this opaque type is supposed to be constrained
24-
--> $DIR/hkl_forbidden4.rs:10:23
25-
|
26-
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
27-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28-
2914
error: concrete type differs from previous defining opaque type use
3015
--> $DIR/hkl_forbidden4.rs:12:1
3116
|
@@ -54,10 +39,10 @@ LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
5439
| -- this generic parameter must be used with a generic lifetime parameter
5540
...
5641
LL | / {
57-
... |
42+
LL | |
5843
LL | | }
5944
| |_^
6045

61-
error: aborting due to 5 previous errors
46+
error: aborting due to 4 previous errors
6247

6348
For more information about this error, try `rustc --explain E0792`.

tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trait Foo {
66
}
77

88
impl Foo for () {
9-
type Assoc<'a> = impl Sized; //~ ERROR unconstrained opaque type
9+
type Assoc<'a> = impl Sized;
1010
fn bar<'a: 'a>()
1111
where
1212
Self::Assoc<'a>:,

tests/ui/type-alias-impl-trait/in-assoc-ty-early-bound2.stderr

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ LL | fn bar<'a: 'a>()
99
LL | let _: Self::Assoc<'a> = x;
1010
| ^^^^^^^^^^^^^^^
1111

12-
error: unconstrained opaque type
13-
--> $DIR/in-assoc-ty-early-bound2.rs:9:22
14-
|
15-
LL | type Assoc<'a> = impl Sized;
16-
| ^^^^^^^^^^
17-
|
18-
= note: `Assoc` must be used in combination with a concrete type within the same impl
19-
20-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
2113

2214
For more information about this error, try `rustc --explain E0700`.

0 commit comments

Comments
 (0)