Skip to content

[chalkify] duplicate predicates with predicates_defined_on #52187

Closed

Description

@scalexm

It seems like I missed this one when reviewing #51895:

= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).

(same duplicate just below in that same file)

I'm just opening this issue for reference, I'll take some time to investigate later.

cc @nikomatsakis if it's still there when you get back, cc @tmandry

Activity

  1. self-assigned this
    on Jul 9, 2018
  2. scalexm commented on Jul 27, 2018

    @scalexm
    ContributorAuthor

    Hint: this duplication is only triggered when using the following form for a super trait:

    trait Bar where Self: Foo {}

    For the alternative syntax trait Bar: Foo {} as well as any where clause not of the form Self: ..., the output seems fine.

  3. scalexm commented on Jul 27, 2018

    @scalexm
    ContributorAuthor

    Ok found the culprit: explicit_predicates_of collects the where clauses explicitly written on the trait, and then also adds those returned by super_predicates_of. But super_predicates_of collects both the « inline » super trait bounds e.g. trait Bar: Foo and the ones included as where clauses e.g. where Self: Foo, but the where Self: Foo was already collected before calling super_predicates_of, hence the duplicate.

    Overall, this is not a big problem apart from giving chalk (and maybe some parts of rustc not using e.g. a HashMap or HashSet) the same clause twice. However for clean outputs, I’d just suggest having an additional explicit_super_predicates_of or something like that (which would not need to be added as a query), which would only return super trait bounds written in the form trait Bar: Foo and which would be used by explicit_predicates_of.

    cc @nikomatsakis

  4. nikomatsakis commented on Aug 8, 2018

    @nikomatsakis
    Contributor

    Sounds about right to me

  5. added 2 commits that reference this issue on Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions