Skip to content

Commit 7dfcdca

Browse files
committed
Add compare mode for lower-impl-trait-in-trait-to-assoc-ty
1 parent 4f6a819 commit 7dfcdca

File tree

82 files changed

+961
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+961
-49
lines changed

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ pub enum FailMode {
123123
pub enum CompareMode {
124124
Polonius,
125125
Chalk,
126+
LowerImplTraitInTraitToAssocTy,
126127
NextSolver,
127128
SplitDwarf,
128129
SplitDwarfSingle,
@@ -133,6 +134,7 @@ impl CompareMode {
133134
match *self {
134135
CompareMode::Polonius => "polonius",
135136
CompareMode::Chalk => "chalk",
137+
CompareMode::LowerImplTraitInTraitToAssocTy => "lower-impl-trait-in-trait-to-assoc-ty",
136138
CompareMode::NextSolver => "next-solver",
137139
CompareMode::SplitDwarf => "split-dwarf",
138140
CompareMode::SplitDwarfSingle => "split-dwarf-single",
@@ -143,6 +145,7 @@ impl CompareMode {
143145
match s.as_str() {
144146
"polonius" => CompareMode::Polonius,
145147
"chalk" => CompareMode::Chalk,
148+
"lower-impl-trait-in-trait-to-assoc-ty" => CompareMode::LowerImplTraitInTraitToAssocTy,
146149
"next-solver" => CompareMode::NextSolver,
147150
"split-dwarf" => CompareMode::SplitDwarf,
148151
"split-dwarf-single" => CompareMode::SplitDwarfSingle,

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ impl Config {
710710
match self.compare_mode {
711711
Some(CompareMode::Polonius) => name == "compare-mode-polonius",
712712
Some(CompareMode::Chalk) => name == "compare-mode-chalk",
713+
Some(CompareMode::LowerImplTraitInTraitToAssocTy) => name == "compare-mode-lower-impl-trait-in-trait-to-assoc-ty",
713714
Some(CompareMode::NextSolver) => name == "compare-mode-next-solver",
714715
Some(CompareMode::SplitDwarf) => name == "compare-mode-split-dwarf",
715716
Some(CompareMode::SplitDwarfSingle) => name == "compare-mode-split-dwarf-single",

src/tools/compiletest/src/runtest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,9 @@ impl<'test> TestCx<'test> {
20302030
Some(CompareMode::Chalk) => {
20312031
rustc.args(&["-Ztrait-solver=chalk"]);
20322032
}
2033+
Some(CompareMode::LowerImplTraitInTraitToAssocTy) => {
2034+
rustc.args(&["-Zlower-impl-trait-in-trait-to-assoc-ty"]);
2035+
}
20332036
Some(CompareMode::NextSolver) => {
20342037
rustc.args(&["-Ztrait-solver=next"]);
20352038
}

tests/ui/async-await/async-trait-fn.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
12
// edition:2018
23
trait T {
34
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`

tests/ui/async-await/async-trait-fn.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0706]: functions in traits cannot be declared `async`
2-
--> $DIR/async-trait-fn.rs:3:5
2+
--> $DIR/async-trait-fn.rs:4:5
33
|
44
LL | async fn foo() {}
55
| -----^^^^^^^^^
@@ -12,7 +12,7 @@ LL | async fn foo() {}
1212
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
1313

1414
error[E0706]: functions in traits cannot be declared `async`
15-
--> $DIR/async-trait-fn.rs:4:5
15+
--> $DIR/async-trait-fn.rs:5:5
1616
|
1717
LL | async fn bar(&self) {}
1818
| -----^^^^^^^^^^^^^^
@@ -25,7 +25,7 @@ LL | async fn bar(&self) {}
2525
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
2626

2727
error[E0706]: functions in traits cannot be declared `async`
28-
--> $DIR/async-trait-fn.rs:5:5
28+
--> $DIR/async-trait-fn.rs:6:5
2929
|
3030
LL | async fn baz() {
3131
| -----^^^^^^^^^

tests/ui/async-await/edition-deny-async-fns-2015.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// edition:2015
2+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
23

34
async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015
45

tests/ui/async-await/edition-deny-async-fns-2015.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0670]: `async fn` is not permitted in Rust 2015
2-
--> $DIR/edition-deny-async-fns-2015.rs:3:1
2+
--> $DIR/edition-deny-async-fns-2015.rs:4:1
33
|
44
LL | async fn foo() {}
55
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -8,7 +8,7 @@ LL | async fn foo() {}
88
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
99

1010
error[E0670]: `async fn` is not permitted in Rust 2015
11-
--> $DIR/edition-deny-async-fns-2015.rs:5:12
11+
--> $DIR/edition-deny-async-fns-2015.rs:6:12
1212
|
1313
LL | fn baz() { async fn foo() {} }
1414
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -17,7 +17,7 @@ LL | fn baz() { async fn foo() {} }
1717
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
1818

1919
error[E0670]: `async fn` is not permitted in Rust 2015
20-
--> $DIR/edition-deny-async-fns-2015.rs:7:1
20+
--> $DIR/edition-deny-async-fns-2015.rs:8:1
2121
|
2222
LL | async fn async_baz() {
2323
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -26,7 +26,7 @@ LL | async fn async_baz() {
2626
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
2727

2828
error[E0670]: `async fn` is not permitted in Rust 2015
29-
--> $DIR/edition-deny-async-fns-2015.rs:8:5
29+
--> $DIR/edition-deny-async-fns-2015.rs:9:5
3030
|
3131
LL | async fn bar() {}
3232
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -35,7 +35,7 @@ LL | async fn bar() {}
3535
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
3636

3737
error[E0670]: `async fn` is not permitted in Rust 2015
38-
--> $DIR/edition-deny-async-fns-2015.rs:14:5
38+
--> $DIR/edition-deny-async-fns-2015.rs:15:5
3939
|
4040
LL | async fn foo() {}
4141
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -44,7 +44,7 @@ LL | async fn foo() {}
4444
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
4545

4646
error[E0670]: `async fn` is not permitted in Rust 2015
47-
--> $DIR/edition-deny-async-fns-2015.rs:18:5
47+
--> $DIR/edition-deny-async-fns-2015.rs:19:5
4848
|
4949
LL | async fn foo() {}
5050
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -53,7 +53,7 @@ LL | async fn foo() {}
5353
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
5454

5555
error[E0670]: `async fn` is not permitted in Rust 2015
56-
--> $DIR/edition-deny-async-fns-2015.rs:36:9
56+
--> $DIR/edition-deny-async-fns-2015.rs:37:9
5757
|
5858
LL | async fn bar() {}
5959
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -62,7 +62,7 @@ LL | async fn bar() {}
6262
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
6363

6464
error[E0670]: `async fn` is not permitted in Rust 2015
65-
--> $DIR/edition-deny-async-fns-2015.rs:26:9
65+
--> $DIR/edition-deny-async-fns-2015.rs:27:9
6666
|
6767
LL | async fn foo() {}
6868
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -71,7 +71,7 @@ LL | async fn foo() {}
7171
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
7272

7373
error[E0670]: `async fn` is not permitted in Rust 2015
74-
--> $DIR/edition-deny-async-fns-2015.rs:31:13
74+
--> $DIR/edition-deny-async-fns-2015.rs:32:13
7575
|
7676
LL | async fn bar() {}
7777
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -80,7 +80,7 @@ LL | async fn bar() {}
8080
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
8181

8282
error[E0706]: functions in traits cannot be declared `async`
83-
--> $DIR/edition-deny-async-fns-2015.rs:18:5
83+
--> $DIR/edition-deny-async-fns-2015.rs:19:5
8484
|
8585
LL | async fn foo() {}
8686
| -----^^^^^^^^^

tests/ui/async-await/in-trait/async-default-fn-overridden.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
// edition:2021
3+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
34

45
#![feature(async_fn_in_trait)]
56
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use

tests/ui/async-await/in-trait/async-default-fn-overridden.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/async-default-fn-overridden.rs:4:12
2+
--> $DIR/async-default-fn-overridden.rs:5:12
33
|
44
LL | #![feature(async_fn_in_trait)]
55
| ^^^^^^^^^^^^^^^^^

tests/ui/async-await/in-trait/async-generics-and-bounds.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// check-fail
22
// known-bug: #102682
33
// edition: 2021
4+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
45

56
#![feature(async_fn_in_trait)]
67
#![allow(incomplete_features)]

tests/ui/async-await/in-trait/async-generics-and-bounds.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics-and-bounds.rs:12:28
2+
--> $DIR/async-generics-and-bounds.rs:13:28
33
|
44
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
55
| ^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime defined here...
8-
--> $DIR/async-generics-and-bounds.rs:12:18
8+
--> $DIR/async-generics-and-bounds.rs:13:18
99
|
1010
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1111
| ^^^^^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics-and-bounds.rs:12:28
13+
--> $DIR/async-generics-and-bounds.rs:13:28
1414
|
1515
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
1616
| ^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics-and-bounds.rs:12:28
19+
--> $DIR/async-generics-and-bounds.rs:13:28
2020
|
2121
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
2222
| ^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
25-
--> $DIR/async-generics-and-bounds.rs:12:18
25+
--> $DIR/async-generics-and-bounds.rs:13:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
2828
| ^^^^^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics-and-bounds.rs:12:28
30+
--> $DIR/async-generics-and-bounds.rs:13:28
3131
|
3232
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
3333
| ^^^^^^^

tests/ui/async-await/in-trait/async-generics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// check-fail
22
// known-bug: #102682
33
// edition: 2021
4+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
45

56
#![feature(async_fn_in_trait)]
67
#![allow(incomplete_features)]

tests/ui/async-await/in-trait/async-generics.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
error[E0311]: the parameter type `U` may not live long enough
2-
--> $DIR/async-generics.rs:9:28
2+
--> $DIR/async-generics.rs:10:28
33
|
44
LL | async fn foo(&self) -> &(T, U);
55
| ^^^^^^^
66
|
77
note: the parameter type `U` must be valid for the anonymous lifetime defined here...
8-
--> $DIR/async-generics.rs:9:18
8+
--> $DIR/async-generics.rs:10:18
99
|
1010
LL | async fn foo(&self) -> &(T, U);
1111
| ^^^^^
1212
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
13-
--> $DIR/async-generics.rs:9:28
13+
--> $DIR/async-generics.rs:10:28
1414
|
1515
LL | async fn foo(&self) -> &(T, U);
1616
| ^^^^^^^
1717

1818
error[E0311]: the parameter type `T` may not live long enough
19-
--> $DIR/async-generics.rs:9:28
19+
--> $DIR/async-generics.rs:10:28
2020
|
2121
LL | async fn foo(&self) -> &(T, U);
2222
| ^^^^^^^
2323
|
2424
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
25-
--> $DIR/async-generics.rs:9:18
25+
--> $DIR/async-generics.rs:10:18
2626
|
2727
LL | async fn foo(&self) -> &(T, U);
2828
| ^^^^^
2929
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
30-
--> $DIR/async-generics.rs:9:28
30+
--> $DIR/async-generics.rs:10:28
3131
|
3232
LL | async fn foo(&self) -> &(T, U);
3333
| ^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/dont-project-to-specializable-projection.rs:4:12
3+
|
4+
LL | #![feature(async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0053]: method `foo` has an incompatible type for trait
11+
--> $DIR/dont-project-to-specializable-projection.rs:14:35
12+
|
13+
LL | default async fn foo(_: T) -> &'static str {
14+
| ^^^^^^^^^^^^ expected associated type, found future
15+
|
16+
note: type in trait
17+
--> $DIR/dont-project-to-specializable-projection.rs:10:27
18+
|
19+
LL | async fn foo(_: T) -> &'static str;
20+
| ^^^^^^^^^^^^
21+
= note: expected signature `fn(_) -> MyTrait<T>::{opaque#0}`
22+
found signature `fn(_) -> impl Future<Output = &'static str>`
23+
24+
error[E0277]: the size for values of type `MyTrait<T>::{opaque#0}` cannot be known at compilation time
25+
--> $DIR/dont-project-to-specializable-projection.rs:33:37
26+
|
27+
LL | <MyStruct as MyTrait<T>>::foo(x).await
28+
| --------------------------------^^^^^^ doesn't have a size known at compile-time
29+
| |
30+
| this call returns `MyTrait<T>::{opaque#0}`
31+
|
32+
= help: the trait `Sized` is not implemented for `MyTrait<T>::{opaque#0}`
33+
= note: required for `MyTrait<T>::{opaque#0}` to implement `IntoFuture`
34+
help: remove the `.await`
35+
|
36+
LL - <MyStruct as MyTrait<T>>::foo(x).await
37+
LL + <MyStruct as MyTrait<T>>::foo(x)
38+
|
39+
help: consider further restricting the associated type
40+
|
41+
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Sized {
42+
| +++++++++++++++++++++++++++++++++++
43+
44+
error[E0277]: `MyTrait<T>::{opaque#0}` is not a future
45+
--> $DIR/dont-project-to-specializable-projection.rs:33:37
46+
|
47+
LL | <MyStruct as MyTrait<T>>::foo(x).await
48+
| --------------------------------^^^^^^ `MyTrait<T>::{opaque#0}` is not a future
49+
| |
50+
| this call returns `MyTrait<T>::{opaque#0}`
51+
|
52+
= help: the trait `Future` is not implemented for `MyTrait<T>::{opaque#0}`
53+
= note: MyTrait<T>::{opaque#0} must be a future or must implement `IntoFuture` to be awaited
54+
= note: required for `MyTrait<T>::{opaque#0}` to implement `IntoFuture`
55+
help: remove the `.await`
56+
|
57+
LL - <MyStruct as MyTrait<T>>::foo(x).await
58+
LL + <MyStruct as MyTrait<T>>::foo(x)
59+
|
60+
help: consider further restricting the associated type
61+
|
62+
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Future {
63+
| ++++++++++++++++++++++++++++++++++++
64+
65+
error[E0277]: the size for values of type `MyTrait<T>::{opaque#0}` cannot be known at compilation time
66+
--> $DIR/dont-project-to-specializable-projection.rs:33:5
67+
|
68+
LL | <MyStruct as MyTrait<T>>::foo(x).await
69+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
70+
|
71+
= help: the trait `Sized` is not implemented for `MyTrait<T>::{opaque#0}`
72+
= note: the return type of a function must have a statically known size
73+
help: consider further restricting the associated type
74+
|
75+
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Sized {
76+
| +++++++++++++++++++++++++++++++++++
77+
78+
error: aborting due to 4 previous errors; 1 warning emitted
79+
80+
Some errors have detailed explanations: E0053, E0277.
81+
For more information about an error, try `rustc --explain E0053`.

tests/ui/async-await/in-trait/issue-102310.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// check-pass
22
// edition:2021
3+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
34

45
#![feature(async_fn_in_trait)]
56
#![allow(incomplete_features)]

tests/ui/async-await/in-trait/issue-104678.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// edition:2021
22
// check-pass
3+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
34

45
#![feature(async_fn_in_trait)]
56
#![allow(incomplete_features)]

tests/ui/async-await/in-trait/lifetime-mismatch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// edition:2021
2+
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
23

34
#![feature(async_fn_in_trait)]
45
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes

tests/ui/async-await/in-trait/lifetime-mismatch.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/lifetime-mismatch.rs:3:12
2+
--> $DIR/lifetime-mismatch.rs:4:12
33
|
44
LL | #![feature(async_fn_in_trait)]
55
| ^^^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)]
88
= note: `#[warn(incomplete_features)]` on by default
99

1010
error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration
11-
--> $DIR/lifetime-mismatch.rs:12:17
11+
--> $DIR/lifetime-mismatch.rs:13:17
1212
|
1313
LL | async fn foo<'a>(&self);
1414
| ---- lifetimes in impl do not match this method in trait

0 commit comments

Comments
 (0)