-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cannot resolve TAIT when used with impl/dyn Trait inside RPIT #101750
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@rustbot label F-type_alias_impl_trait |
https://github.com/rust-lang/rust/commits/master?since=2022-08-18&until=2022-08-18 |
trait Trait {}
type TAIT = impl Trait;
struct Bar;
impl Trait for Bar {}
fn foo() -> TAIT {
Bar
}
// ok
async fn bar() -> (TAIT, Bar) {
(foo(), Bar)
}
// err: concrete type differs
// async fn bar() -> (TAIT, impl Trait) {
// (foo(), Bar)
// }
// err: concrete type differs
// async fn bar() -> (TAIT, Box<dyn Trait>) {
// (foo(), Box::new(Bar))
// } |
Caused by #99860 Any ideas? cc @oli-obk @compiler-errors |
TAIT and RPIT were made to work the same in the revert, thus TAIT was changed from before #97346 instead of just reverting to the old behaviour. I will need to look at some typeck logs to see what's goin on here |
FYI, it seems that the bug is not related to // err: concrete type differs
fn bar() -> impl Iterator<Item = (TAIT, impl Trait)> {
std::iter::once((foo(), Bar))
} |
I've tested with the following codes: #![feature(type_alias_impl_trait)]
trait Trait {}
type TAIT = impl Trait;
struct Bar;
impl Trait for Bar {}
fn foo() -> TAIT {
Bar
}
fn haha() -> (impl Iterator<Item = TAIT>, impl Trait) {
(std::iter::empty::<Bar>(), Bar)
}
fn bar() -> impl Iterator<Item = (TAIT, impl Trait)> {
std::iter::once((foo(), Bar))
} It seems that the result of
It seems that |
Just tested it and I can confirm it works now! Thanks! BTW, what about adding this issue as a test cast? |
Yes a minimized test PR would be appreciated. |
@rustbot claim |
…mpiler-errors Add a test for TAIT used with impl/dyn Trait inside RPIT close rust-lang#101750
The condition seems complex, but a practical instance is
async fn foo() -> Result<TAIT>
I tried this code:
I expected to see this happen: it compiles
Instead, this happened: error:
Notes:
nightly-2022-08-12
, but failed innightly-2022-09-13
fn() -> Result<TAIT>
works, andasync fn() -> Option<TAIT>
worksMeta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: