You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[chalkify] duplicate predicates with predicates_defined_on #52187
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: Fooand 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.
Activity
scalexm commentedon Jul 27, 2018
Hint: this duplication is only triggered when using the following form for a super trait:
For the alternative syntax
trait Bar: Foo {}as well as any where clause not of the formSelf: ..., the output seems fine.scalexm commentedon Jul 27, 2018
Ok found the culprit:
explicit_predicates_ofcollects the where clauses explicitly written on the trait, and then also adds those returned bysuper_predicates_of. Butsuper_predicates_ofcollects both the « inline » super trait bounds e.g.trait Bar: Fooand the ones included as where clauses e.g.where Self: Foo, but thewhere Self: Foowas already collected before callingsuper_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
HashMaporHashSet) the same clause twice. However for clean outputs, I’d just suggest having an additionalexplicit_super_predicates_ofor something like that (which would not need to be added as a query), which would only return super trait bounds written in the formtrait Bar: Fooand which would be used byexplicit_predicates_of.cc @nikomatsakis
nikomatsakis commentedon Aug 8, 2018
Sounds about right to me
Rollup merge of rust-lang#54780 - scalexm:dup-predicates, r=nikomatsakis
Rollup merge of rust-lang#54780 - scalexm:dup-predicates, r=nikomatsakis