Stream: wg-traits

Topic: Handling of unresolved where clauses


Florian Diebold (Dec 21 2019 at 16:51, on Zulip):

I'm refactoring the Chalk lowering code in rust-analyzer a bit (preparing for the chalk-ir changes), and I was wondering what the best way to handle errors in where clauses is (e.g. where T: UnknownTrait). We used to lower them to a clause that can never be met by 'making up' a trait without impls, but that is kind of an ugly hack. We could also just leave them out, i.e. make them always succeed. Or we could add a WhereClause::Error variant and have the Chalk program clause code decide on a case-by-case basis.

I'm not actually sure what the best behavior is; I think it should be 'whatever makes the most code type-check', but actually both approaches can lead to errors (leaving out the clause can cause more ambiguities).

Finally, this problem probably becomes much less important the more correct rust-analyzer's name resolution becomes, so maybe the best answer is 'whatever is simplest' ;)

Jack Huey (Dec 21 2019 at 17:00, on Zulip):

Sounds a bit like Goal::CannotProve?

Florian Diebold (Dec 21 2019 at 17:07, on Zulip):

Sure, that's not something that's available on the chalk-ir level though (if we introduce a WhereClause::Error, that might get involved)

matklad (Dec 21 2019 at 17:26, on Zulip):

We could also just leave them out, i.e. make them always succeed.

Seems like one can't get simpler than this? :)

Florian Diebold (Dec 21 2019 at 18:05, on Zulip):

Seems like one can't get simpler than this? :)

Yeah, and that's what I've implemented now, I'm just wondering whether the potential fallout from that is acceptable

Florian Diebold (Dec 21 2019 at 18:21, on Zulip):

it's really probably fine, doesn't change much in analysis-stats actually :)

nikomatsakis (Dec 23 2019 at 11:21, on Zulip):

I think leaving them out is probably what you want

nikomatsakis (Dec 23 2019 at 11:21, on Zulip):

Cannot prove etc feels too strong

nikomatsakis (Dec 23 2019 at 11:21, on Zulip):

That would make it an error to invoke those functions (because we cannot prove that they are callable)

Last update: Jun 07 2020 at 09:25UTC