-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc crash with type alias of impl trait #63677
Comments
@shootingsyh: Are you able to provide the repository that reproduces this? |
Sorry it’s still under very early developing, so I haven’t open it. I’m trying to figure out a repro though |
Still cannot find a simple repro. I decided to public my work at https://github.com/shootingsyh/rxstream, and here is patch of my local change: Apply the patch, cargo build with the nightly version, it will crash like that. cc @Aaron1011 |
If I remove that |
@hellow554 how did you get this error? use cargo build? |
|
Hmmm, sorry didn't add the src/operators/transform/overlapped_time_buffer.rs file into my diff... |
This is small-ish, I'm not sure if it can be simplified further: #![feature(type_alias_impl_trait)]
pub trait Trait {}
pub struct S1<T>(T);
pub struct S2<T>(T);
pub type T1 = impl Trait;
pub type T2 = S1<T1>;
pub type T3 = S2<T2>;
impl<T> Trait for S1<T> {}
impl<T: Trait> S2<T> {}
impl T3 {}
pub fn use_t1() -> T1 { S1(()) } (I Hope the names don't confuse you ;) ) |
This comment has been minimized.
This comment has been minimized.
Fixes rust-lang#63677 This commit treats all opaque types as 'remote' with respect to coherence checking, instead of causing an ICE. This ensures that opaque types cannot ever 'leak' information about the underlying type (e.g. whether or not it is a local or remote type)
… r=nikomatsakis Fix coherence checking for impl trait in type aliases **UPDATE**: This PR now treats all opaque types as remote. The original description appears below, but is no longer accurate. Fixes rust-lang#63677 [RFC 2071](rust-lang/rfcs#2071) (impl-trait-existential-types) does not explicitly state how `type_alias_impl_trait` should interact with coherence. However, there's only one choice which makes sense - coherence should look at the underlying type (i.e. the *"defining"* type of the `impl Trait`) of the type alias, just like we do for non-`impl Trait` type aliases. Specifically, `impl Trait` type aliases that resolve to a local type should be treated like a local type with respect to coherence (e.g. `impl Trait` type aliases which resolve to a foreign type should be treated as a foreign type, and those that resolve to a local type should be treated as a local type). Since neither inherent impls nor direct trait impl (i.e. `impl MyType` or `impl MyTrait for MyType`) are allowed for type aliases, this usually does not come up. Before we ever attempt to do coherence checking, we will have errored out if an `impl Trait` type alias was used directly in an `impl` clause. However, during trait selection, we sometimes need to prove bounds like `T: Sized` for some type `T`. If `T` is an impl trait type alias, this requires to know the coherence behavior for `impl Trait` type aliases when we perform coherence checking. Note: Since determining the underlying type of an `impl Trait` type alias requires us to perform body type checking, this commit causes us to type check some bodies easier than we otherwise would have. However, since this is done through a query, this shouldn't cause any problems For completeness, I've added an additional test of the coherence-related behavior of `impl Trait` type aliases. cc rust-lang#63063
I cannot provide a simple repro yet. But what I did is mostly define a type alias of an impl trait and use it as generic parameter of another type. And here is the stack trace
The text was updated successfully, but these errors were encountered: