Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chalkify] duplicate predicates with predicates_defined_on #52187

Closed
scalexm opened this issue Jul 9, 2018 · 3 comments
Closed

[chalkify] duplicate predicates with predicates_defined_on #52187

scalexm opened this issue Jul 9, 2018 · 3 comments
Assignees
Labels
WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

Comments

@scalexm
Copy link
Member

scalexm commented Jul 9, 2018

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

@scalexm scalexm self-assigned this Jul 9, 2018
@scalexm
Copy link
Member Author

scalexm commented Jul 27, 2018

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.

@scalexm
Copy link
Member Author

scalexm commented Jul 27, 2018

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

@nikomatsakis
Copy link
Contributor

Sounds about right to me

pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 3, 2018
Remove duplicate predicates in `explicit_predicates_of`

I took a more brutal approach than described in rust-lang#52187. I could have used the `linked_hash_map` crate but this seems overkill, especially as we need a vec storage in the end.

r? @nikomatsakis
pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 4, 2018
Remove duplicate predicates in `explicit_predicates_of`

I took a more brutal approach than described in rust-lang#52187. I could have used the `linked_hash_map` crate but this seems overkill, especially as we need a vec storage in the end.

r? @nikomatsakis
@bors bors closed this as completed in 8327976 Oct 4, 2018
@tmandry tmandry added the WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 label May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804
Projects
None yet
Development

No branches or pull requests

3 participants