Make type_of for RPITITs GAT on traits return a ty::Error if no default provided#113461
Make type_of for RPITITs GAT on traits return a ty::Error if no default provided#113461spastorino wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
Why exactly do we even try to call |
Something interesting is that ... #![feature(return_position_impl_trait_in_trait)]
struct Wrapper<G: Send>();
trait Foo {
fn bar() -> Wrapper<impl Send>;
}
fn main() {}This example doesn't ICE, so I guess doesn't call |
So from what I see we're trying to check This is the process we follow with the RPITIT def_id This process seems reasonable to me but I'm not sure if we should change something and what exactly. So we select an auto impl candidate because of |
|
Another interesting thing is that this example: #![feature(return_position_impl_trait_in_trait)]
struct Wrapper<G: Sized>(G);
trait Foo {
fn bar() -> Wrapper<impl Send>;
}
fn main() {}Doesn't produce any issue. We need the impl trait to be an impl auto trait in return position in order to reproduce this. |
|
I don't think that's enough of an explanation for why this is happening. All you've provided is the call stack of the ICE and a couple of examples that don't ICE 😅 doesn't explain why we're registering this obligation and why we're actually getting the opaque that has no hidden type. This at least needs a bit more of an explanation so I can be convinced there's some better place to put this fix, without having to actually investigate it myself... @rustbot author |
|
Closing in favor of #113741 |
…-missing-opaque, r=spastorino Don't install default projection bound for return-position `impl Trait` in trait methods with no body This ensures that we never try to project to an opaque type in a trait method that has no body to infer its hidden type, which means we never later call `type_of` on that opaque. This is because opaque types try to reveal their hidden type when proving auto traits. I thought about this a lot, and I think this is a fix that's less likely to introduce other strange downstream ICEs than rust-lang#113461. r? `@spastorino`
…-missing-opaque, r=spastorino Don't install default projection bound for return-position `impl Trait` in trait methods with no body This ensures that we never try to project to an opaque type in a trait method that has no body to infer its hidden type, which means we never later call `type_of` on that opaque. This is because opaque types try to reveal their hidden type when proving auto traits. I thought about this a lot, and I think this is a fix that's less likely to introduce other strange downstream ICEs than rust-lang#113461. Fixes rust-lang#113434 r? `@spastorino`
Fixes #113434
This one is interesting because it ICEs on both master and in the new RPITIT impl.
I think the code is self-explanatory but we want to avoid delaying a bug and calling
opaque::find_opaque_ty_constraints_for_rpit(tcx, def_id, owner)when we already know we can't build a type.r? @compiler-errors