Skip to content

Commit

Permalink
Add compare mode for lower-impl-trait-in-trait-to-assoc-ty
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Mar 3, 2023
1 parent 4f6a819 commit 7dfcdca
Show file tree
Hide file tree
Showing 82 changed files with 961 additions and 49 deletions.
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub enum FailMode {
pub enum CompareMode {
Polonius,
Chalk,
LowerImplTraitInTraitToAssocTy,
NextSolver,
SplitDwarf,
SplitDwarfSingle,
Expand All @@ -133,6 +134,7 @@ impl CompareMode {
match *self {
CompareMode::Polonius => "polonius",
CompareMode::Chalk => "chalk",
CompareMode::LowerImplTraitInTraitToAssocTy => "lower-impl-trait-in-trait-to-assoc-ty",
CompareMode::NextSolver => "next-solver",
CompareMode::SplitDwarf => "split-dwarf",
CompareMode::SplitDwarfSingle => "split-dwarf-single",
Expand All @@ -143,6 +145,7 @@ impl CompareMode {
match s.as_str() {
"polonius" => CompareMode::Polonius,
"chalk" => CompareMode::Chalk,
"lower-impl-trait-in-trait-to-assoc-ty" => CompareMode::LowerImplTraitInTraitToAssocTy,
"next-solver" => CompareMode::NextSolver,
"split-dwarf" => CompareMode::SplitDwarf,
"split-dwarf-single" => CompareMode::SplitDwarfSingle,
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ impl Config {
match self.compare_mode {
Some(CompareMode::Polonius) => name == "compare-mode-polonius",
Some(CompareMode::Chalk) => name == "compare-mode-chalk",
Some(CompareMode::LowerImplTraitInTraitToAssocTy) => name == "compare-mode-lower-impl-trait-in-trait-to-assoc-ty",
Some(CompareMode::NextSolver) => name == "compare-mode-next-solver",
Some(CompareMode::SplitDwarf) => name == "compare-mode-split-dwarf",
Some(CompareMode::SplitDwarfSingle) => name == "compare-mode-split-dwarf-single",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,9 @@ impl<'test> TestCx<'test> {
Some(CompareMode::Chalk) => {
rustc.args(&["-Ztrait-solver=chalk"]);
}
Some(CompareMode::LowerImplTraitInTraitToAssocTy) => {
rustc.args(&["-Zlower-impl-trait-in-trait-to-assoc-ty"]);
}
Some(CompareMode::NextSolver) => {
rustc.args(&["-Ztrait-solver=next"]);
}
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/async-trait-fn.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty
// edition:2018
trait T {
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/async-await/async-trait-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:3:5
--> $DIR/async-trait-fn.rs:4:5
|
LL | async fn foo() {}
| -----^^^^^^^^^
Expand All @@ -12,7 +12,7 @@ LL | async fn foo() {}
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable

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

error[E0706]: functions in traits cannot be declared `async`
--> $DIR/async-trait-fn.rs:5:5
--> $DIR/async-trait-fn.rs:6:5
|
LL | async fn baz() {
| -----^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/edition-deny-async-fns-2015.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// edition:2015
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

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

Expand Down
20 changes: 10 additions & 10 deletions tests/ui/async-await/edition-deny-async-fns-2015.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0670]: `async fn` is not permitted in Rust 2015
--> $DIR/edition-deny-async-fns-2015.rs:3:1
--> $DIR/edition-deny-async-fns-2015.rs:4:1
|
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
Expand All @@ -8,7 +8,7 @@ LL | async fn foo() {}
= note: for more on editions, read https://doc.rust-lang.org/edition-guide

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

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

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

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

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

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

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

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

error[E0706]: functions in traits cannot be declared `async`
--> $DIR/edition-deny-async-fns-2015.rs:18:5
--> $DIR/edition-deny-async-fns-2015.rs:19:5
|
LL | async fn foo() {}
| -----^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-pass
// edition:2021
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/async-default-fn-overridden.rs:4:12
--> $DIR/async-default-fn-overridden.rs:5:12
|
LL | #![feature(async_fn_in_trait)]
| ^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/async-generics-and-bounds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// check-fail
// known-bug: #102682
// edition: 2021
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/async-await/in-trait/async-generics-and-bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
error[E0311]: the parameter type `U` may not live long enough
--> $DIR/async-generics-and-bounds.rs:12:28
--> $DIR/async-generics-and-bounds.rs:13:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
note: the parameter type `U` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics-and-bounds.rs:12:18
--> $DIR/async-generics-and-bounds.rs:13:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:12:28
--> $DIR/async-generics-and-bounds.rs:13:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^

error[E0311]: the parameter type `T` may not live long enough
--> $DIR/async-generics-and-bounds.rs:12:28
--> $DIR/async-generics-and-bounds.rs:13:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics-and-bounds.rs:12:18
--> $DIR/async-generics-and-bounds.rs:13:18
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics-and-bounds.rs:12:28
--> $DIR/async-generics-and-bounds.rs:13:28
|
LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash;
| ^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/async-generics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// check-fail
// known-bug: #102682
// edition: 2021
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/async-await/in-trait/async-generics.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
error[E0311]: the parameter type `U` may not live long enough
--> $DIR/async-generics.rs:9:28
--> $DIR/async-generics.rs:10:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
note: the parameter type `U` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics.rs:9:18
--> $DIR/async-generics.rs:10:18
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:9:28
--> $DIR/async-generics.rs:10:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^

error[E0311]: the parameter type `T` may not live long enough
--> $DIR/async-generics.rs:9:28
--> $DIR/async-generics.rs:10:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
|
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
--> $DIR/async-generics.rs:9:18
--> $DIR/async-generics.rs:10:18
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^
note: ...so that the reference type `&(T, U)` does not outlive the data it points at
--> $DIR/async-generics.rs:9:28
--> $DIR/async-generics.rs:10:28
|
LL | async fn foo(&self) -> &(T, U);
| ^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/dont-project-to-specializable-projection.rs:4:12
|
LL | #![feature(async_fn_in_trait)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
= note: `#[warn(incomplete_features)]` on by default

error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/dont-project-to-specializable-projection.rs:14:35
|
LL | default async fn foo(_: T) -> &'static str {
| ^^^^^^^^^^^^ expected associated type, found future
|
note: type in trait
--> $DIR/dont-project-to-specializable-projection.rs:10:27
|
LL | async fn foo(_: T) -> &'static str;
| ^^^^^^^^^^^^
= note: expected signature `fn(_) -> MyTrait<T>::{opaque#0}`
found signature `fn(_) -> impl Future<Output = &'static str>`

error[E0277]: the size for values of type `MyTrait<T>::{opaque#0}` cannot be known at compilation time
--> $DIR/dont-project-to-specializable-projection.rs:33:37
|
LL | <MyStruct as MyTrait<T>>::foo(x).await
| --------------------------------^^^^^^ doesn't have a size known at compile-time
| |
| this call returns `MyTrait<T>::{opaque#0}`
|
= help: the trait `Sized` is not implemented for `MyTrait<T>::{opaque#0}`
= note: required for `MyTrait<T>::{opaque#0}` to implement `IntoFuture`
help: remove the `.await`
|
LL - <MyStruct as MyTrait<T>>::foo(x).await
LL + <MyStruct as MyTrait<T>>::foo(x)
|
help: consider further restricting the associated type
|
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Sized {
| +++++++++++++++++++++++++++++++++++

error[E0277]: `MyTrait<T>::{opaque#0}` is not a future
--> $DIR/dont-project-to-specializable-projection.rs:33:37
|
LL | <MyStruct as MyTrait<T>>::foo(x).await
| --------------------------------^^^^^^ `MyTrait<T>::{opaque#0}` is not a future
| |
| this call returns `MyTrait<T>::{opaque#0}`
|
= help: the trait `Future` is not implemented for `MyTrait<T>::{opaque#0}`
= note: MyTrait<T>::{opaque#0} must be a future or must implement `IntoFuture` to be awaited
= note: required for `MyTrait<T>::{opaque#0}` to implement `IntoFuture`
help: remove the `.await`
|
LL - <MyStruct as MyTrait<T>>::foo(x).await
LL + <MyStruct as MyTrait<T>>::foo(x)
|
help: consider further restricting the associated type
|
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Future {
| ++++++++++++++++++++++++++++++++++++

error[E0277]: the size for values of type `MyTrait<T>::{opaque#0}` cannot be known at compilation time
--> $DIR/dont-project-to-specializable-projection.rs:33:5
|
LL | <MyStruct as MyTrait<T>>::foo(x).await
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `MyTrait<T>::{opaque#0}`
= note: the return type of a function must have a statically known size
help: consider further restricting the associated type
|
LL | async fn indirection<T>(x: T) -> &'static str where MyTrait<T>::{opaque#0}: Sized {
| +++++++++++++++++++++++++++++++++++

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0053, E0277.
For more information about an error, try `rustc --explain E0053`.
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/issue-102310.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// check-pass
// edition:2021
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/issue-104678.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// edition:2021
// check-pass
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
#![allow(incomplete_features)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/lifetime-mismatch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// edition:2021
// ignore-compare-mode-lower-impl-trait-in-trait-to-assoc-ty

#![feature(async_fn_in_trait)]
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/async-await/in-trait/lifetime-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/lifetime-mismatch.rs:3:12
--> $DIR/lifetime-mismatch.rs:4:12
|
LL | #![feature(async_fn_in_trait)]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)]
= note: `#[warn(incomplete_features)]` on by default

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

0 comments on commit 7dfcdca

Please sign in to comment.