I was unable to reproduce the issue in the defining scope (that doesn't mean it's not possible, just that I gave up for now ^^). I found this absolutely useless diagnostic though: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b80473c86172959763c139535154c3f9
Did some more thinking and I'm wondering now if the did.is_local() check should actually be infcx.opaque_type_origin(did).is_some() so we only generate those generalized inference vars if we're actually able to handle the opaque type. I was kinda hoping to keep that isolated in handle_opaque_type, but that appears to have been a misplaced hope.
One more thing is that we're using eq inside handle_opaque_types when it should probably be using the relation that is calling handle_opaque_types. So maybe we could scrap the entire generalization logic and just always invoke handle_opaque_types by passing the relation as an argument and forwarding to that instead of using eq.
so many possibilities to try out. Let's merge this PR for now and I'm moving this comment to an issue so we can continue there.
Originally posted by @oli-obk in #99928 (comment)
I was unable to reproduce the issue in the defining scope (that doesn't mean it's not possible, just that I gave up for now ^^). I found this absolutely useless diagnostic though: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b80473c86172959763c139535154c3f9
Did some more thinking and I'm wondering now if the
did.is_local()check should actually beinfcx.opaque_type_origin(did).is_some()so we only generate those generalized inference vars if we're actually able to handle the opaque type. I was kinda hoping to keep that isolated inhandle_opaque_type, but that appears to have been a misplaced hope.One more thing is that we're using
eqinsidehandle_opaque_typeswhen it should probably be using the relation that is callinghandle_opaque_types. So maybe we could scrap the entire generalization logic and just always invokehandle_opaque_typesby passing the relation as an argument and forwarding to that instead of usingeq.so many possibilities to try out. Let's merge this PR for now and I'm moving this comment to an issue so we can continue there.
Originally posted by @oli-obk in #99928 (comment)