-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 recursive type using GAT. #87750
Comments
Minimized a bit #![feature(generic_associated_types)]
trait PointerFamily {
type Pointer<T>;
}
struct Rc<T>(Box<T>);
struct RcFamily;
impl PointerFamily for RcFamily {
type Pointer<T> = Rc<T>;
}
#[allow(dead_code)]
enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized {
Cons(P::Pointer<Node<T, P>>),
}
fn main() {
let _list: <RcFamily as PointerFamily>::Pointer<Node<i32, RcFamily>>;
} |
Okay so this works: Cons(<RcFamily as PointerFamily>::Pointer<Node<T>>, T), this fails: Cons(T, <RcFamily as PointerFamily>::Pointer<Node<T>>), |
Another even more minimized example#![feature(generic_associated_types)]
trait PointerFamily {
type Pointer<T>;
}
struct RcFamily;
impl PointerFamily for RcFamily {
type Pointer<T> = Box<T>;
}
enum Node<T> where <RcFamily as PointerFamily>::Pointer<Node<T>>: Sized {
//Cons(<RcFamily as PointerFamily>::Pointer<Node<T>>, T),
Cons(T, <RcFamily as PointerFamily>::Pointer<Node<T>>),
}
fn main() {
let _list: Box<Node<i32>>;
} Okay, so ultimately, this ends up being very similar to #80626. At some point or another, depending on specific variations of this test, we require that rust/compiler/rustc_middle/src/ty/layout.rs Line 574 in ae90dcf
We probably should be giving a smarter error here; enums should always be sized. Okay, so now to explain why we can't prove that enum Node<T> where <RcFamily as PointerFamily>::Pointer<Node<T>>: Sized {
Cons(T, <RcFamily as PointerFamily>::Pointer<Node<T>>),
} to prove this is There's a few problems here. But one problem is that when we collect the size predicates, we try to eagerly normalize them here. That alone isn't a problem, but it means we can't use that where clause. But, to normalize, we have to check that A simple solution here is to change the associated type definition to be I'm not sure removing the eager normalization call above would itself be enough. We theoretically can normalize, we specifically don't want to (and anywhere else that tries will run into more problems; this includes if the |
No longer ICEs since #85868 |
Woah. Unexpected. |
add some more testcases resolves rust-lang#52893 resolves rust-lang#68295 resolves rust-lang#87750 resolves rust-lang#88071 All these issues have been fixed according to glacier. Just adding a test so it can be closed. Can anybody tell me why the github keywords do not work? 🤔 Please edit this post if you can fix it.
add some more testcases resolves rust-lang#52893 resolves rust-lang#68295 resolves rust-lang#87750 resolves rust-lang#88071 All these issues have been fixed according to glacier. Just adding a test so it can be closed. Can anybody tell me why the github keywords do not work? 🤔 Please edit this post if you can fix it.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: