-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE with GAT, TAIT + async{} when missing bound in the GAT. #90400
Comments
Interesting. So, the problem here is that the type of |
Update: the below examples are no longer ICEs. Some "reductions" that should have the same root cause as described above, although they error slightly differently (they all produce some kind of complaint that Using closures instead of async: #![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
trait Bar {
fn bar(&self);
}
trait Foo {
type FooFn<B>: FnOnce();
fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>;
}
struct MyFoo;
impl Foo for MyFoo {
type FooFn<B> = impl FnOnce();
fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
move || { bar.bar() }
}
}
fn main() {
let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() };
boom();
} Output
Using a custom trait instead of #![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
trait Bar {
fn bar(&self);
}
trait Baz {
fn baz(&self);
}
trait Foo {
type FooFn<B>: Baz;
fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B>;
}
struct MyFoo;
impl Foo for MyFoo {
type FooFn<B> = impl Baz;
fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
MyBaz(bar)
}
}
struct MyBaz<B: Bar>(B);
impl <B: Bar> Baz for MyBaz<B> {
fn baz(&self) {}
}
fn main() {
let boom: <MyFoo as Foo>::FooFn<u32> = unsafe { core::mem::zeroed() };
boom.baz();
} Output
|
If you use a non-associated type alias instead of a GAT, the async and |
GATs issue triage: not blocking. Given that there are similar repros without GATs, this basically confirms my suspicion that this isn't a GAT issue, but a TAIT one. |
The custom trait version no longer ICEs since #90948, the rest still do |
Triage: All the examples on the comment (#90400 (comment)) are no longer ICE, I'm going to mark as |
Triage: the original code still triggers an ICE. In #97309, I've added some tests based on #90400 (comment). |
…rrors Add some regression tests for rust-lang#90400 This adds two regression tests taken from rust-lang#90400 (comment). Note that we cannot close the issue right now as the [original code](rust-lang#90400 (comment)) still triggers an ICE. r? `@compiler-errors`
Rollup of 4 pull requests Successful merges: - rust-lang#96129 (Document rounding for floating-point primitive operations and string parsing) - rust-lang#97286 (Add new eslint rule to prevent whitespace before function call paren) - rust-lang#97292 (Lifetime variance fixes for rustc) - rust-lang#97309 (Add some regression tests for rust-lang#90400) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The original doesn't ICE anymore on playground, it reports a few errors, but fixing them produces no ICEs at any stage |
any reason why this is not closed yet? we do have tests for this inside rustc |
Code
I think the cause is the code is incorrect: FooFuture should require
where B: Bar
. It doesn't, somehow the compiler doesn't catch this, and then ICEs at codegen if you try to useFooFuture<u32>
because u32 is not Bar.playground
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: