-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove duplicate predicates in explicit_predicates_of
#54780
Conversation
|
||
fn push(&mut self, value: (ty::Predicate<'tcx>, Span)) { | ||
if self.uniques.insert(value) { | ||
self.predicates.push(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do predicates
need to contain copies of the elements in uniques
? Since both have the same elements and the Vec
is used only (as far as I understand) to keep the order, maybe it could hold just references to the elements in uniques
instead? On the other hand, Predicate
is Copy
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes everything is Copy
(these are references to arena-allocated memory) so I didn’t care to do such an optimization :)
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
966afaf
to
8327976
Compare
/// compile-fail UI tests. | ||
struct UniquePredicates<'tcx> { | ||
predicates: Vec<(ty::Predicate<'tcx>, Span)>, | ||
uniques: FxHashSet<(ty::Predicate<'tcx>, Span)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I wonder if we should add the indexmap crate and use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meh, leave it for now
@bors r+ |
📌 Commit 8327976 has been approved by |
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
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
Rollup of 10 pull requests Successful merges: - #53523 (Add doc for impl From for Std Error) - #54746 (simplify some unused lints code) - #54761 (Make spec_extend use for_each()) - #54769 (Fix typo in CONTRIBUTING.md) - #54773 (Update a FIXME in memory.rs) - #54777 (abolish ICE when pretty-printing async block) - #54780 (Remove duplicate predicates in `explicit_predicates_of`) - #54788 (A handful of cleanups for rustc/mir) - #54789 (Introduce `TyKind::UnnormalizedProjection`) - #54795 (remove padding from multiline format string label) Failed merges: r? @ghost
I took a more brutal approach than described in #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