-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Compiler panic during GAT type bound usage #79636
Comments
Don't feel like this should be closed! It's important and helpful that you filed this so that we can smooth this feature out – even though it's unstable, this is still a bug that should be addressed :) |
@snoyberg Only tangantially related to this issue, but you might be interested in this post of mine on how to do monads in Rust. It does e.g. support writing "join": Example code of "join" that compiles with my approach:fn join<A, M: Monad>(mmx: a!(M:<a!(M:<A>)>)) -> M::Of<A> {
do_!{
mx <- mmx;
x <- mx;
M::pure(x)
}
}
// alternative version, using trivial conversion
// between MT: HasTyCon<Param = T, GetTyCon = M>
// and M::Of<T>
fn join_alternative<A, M: Monad>(mmx: a!(M:<a!(M:<A>)>)) -> M::Of<A> {
do_!{
mx <- mmx;
mx.as_con_ty()
}
}
fn main() {
let xss = vec![vec![1,2,3],vec![],vec![4,5],vec![6]];
// join can be used on concrete monadic types
let xs = join(xss);
print!("{:?}", xs); // [1,2,3,4,5,6]
}
// join can be used in a generic context
fn join_twice<A, M: Monad>(mmmx: a!(M:<a!(M:<a!(M:<A>)>)>)) -> M::Of<A> {
join(join(mmmx))
} |
It is worth noting, that technically this is the wrong syntax. MInner: Monad<Unwrapped = A, Wrapped<A> = MOuter::Wrapped<A>>` which returns correctly (and sadly)
Edit: this means that the crash should of course still be fixed, but to return a syntax error. |
Here's a smaller test-case (I found this bug independently): #![feature(generic_associated_types)]
pub trait SomeTrait {
type Wrapped<A>: SomeTrait;
fn f() -> ();
}
fn program<W>() -> ()
where
W: SomeTrait<Wrapped = W>,
{
return W::f();
}
fn main() {} |
Fixed by #79554 |
Adding a test for this is blocked on #82272 |
No, test can be added as-is. Diagnostics issue is orthogonal. |
…=jackh726 Add GAT related tests Closes rust-lang#79949 Closes rust-lang#79636 Closes rust-lang#78671 Closes rust-lang#70303 Closes rust-lang#70304 Closes rust-lang#71176
…=jackh726 Add GAT related tests Closes rust-lang#79949 Closes rust-lang#79636 Closes rust-lang#78671 Closes rust-lang#70303 Closes rust-lang#70304 Closes rust-lang#71176
Code
Meta
rustc --version --verbose
:Error output
Notes
I recognize this is an unstable compiler feature, and have no problem if it would be better to just close this. Also, if it would be better to include this report elsewhere, please let me know.
The text was updated successfully, but these errors were encountered: