-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add missing potential_query_instability for keys and values in hashmap #120485
add missing potential_query_instability for keys and values in hashmap #120485
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
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.
Thanks for the PR, @chenyukang!
That's a great catch about the missing query instability attributes on the HashMap methods. That was definitely a bug.
I've left a few comments below where it should not be too hard to fix the problem in a cleaner way.
@@ -267,6 +267,7 @@ impl CguReuseTracker { | |||
|
|||
fn check_expected_reuse(&self, sess: &Session) { | |||
if let Some(ref data) = self.data { | |||
#[allow(rustc::potential_query_instability)] | |||
let mut keys = data.expected_reuse.keys().collect::<Vec<_>>(); |
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.
We can fix this properly by using UnordMap
instead of FxHashMap
for the actual_reuse
and expected_reuse
fields in TrackerData
. That has the to_sorted_stable_ord method that does exactly what we want.
@@ -403,6 +403,7 @@ fn codegenned_and_inlined_items(tcx: TyCtxt<'_>) -> DefIdSet { | |||
let mut result = items.clone(); | |||
|
|||
for cgu in cgus { | |||
#[allow(rustc::potential_query_instability)] |
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.
Can you try turning the items
field in CodegenUnit
into an FxIndexMap
. That should make iteration stable (if the collection is built in a deterministic order). An UnordMap
would be even better, but I suspect that that would be more work.
@@ -682,6 +682,7 @@ fn link_dwarf_object<'a>( | |||
} | |||
|
|||
// Input rlibs contain .o/.dwo files from dependencies. | |||
#[allow(rustc::potential_query_instability)] | |||
let input_rlibs = cg_results | |||
.crate_info | |||
.used_crate_source |
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.
Can you turn the used_crate_source
field into an UnordMap
? Then you should be able to do this:
// Input rlibs contain .o/.dwo files from dependencies.
let input_rlibs = cg_results
.crate_info
.used_crate_source
.items()
.filter_map(|(_, csource)| csource.rlib.as_ref())
.map(|(path, _)| path)
.into_sorted_stable_ord();
@@ -1950,6 +1950,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
) { | |||
let len = remaining_fields.len(); | |||
|
|||
#[allow(rustc::potential_query_instability)] |
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.
It should be straightforward to make remaining_fields
and UnordMap
.
There was an issue to track these kinds of cleanups: I may create a separate PR to clean up those replacements? |
This is also closely related: rust-lang/compiler-team#533 It is where the unord collections were proposed. They've been implemented meanwhile and are quite mature (although it seems that
Sure, you can r? @michaelwoerister on that. Let me know if you plan to do any further changes to this PR, otherwise I'm happy to approve it. |
Ok, please approve this one, I may work on cleanups in the weekend. |
@bors r+ rollup |
debug!( | ||
"is_lint_group(lint_name={:?}, lint_groups={:?})", | ||
lint_name, | ||
self.lint_groups.keys().collect::<Vec<_>>() | ||
); | ||
#[allow(rustc::potential_query_instability)] | ||
let lint_groups = self.lint_groups.keys().collect::<Vec<_>>(); | ||
debug!("is_lint_group(lint_name={:?}, lint_groups={:?})", lint_name, lint_groups); |
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.
Will collect things on release now, instead of debug only, next one too. cfg(debug_assertions)
?
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.
you are right, I will clean this up when I replace HashMap.
…llaumeGomez Rollup of 11 pull requests Successful merges: - rust-lang#117906 (Improve display of crate name when hovered) - rust-lang#118533 (Suppress unhelpful diagnostics for unresolved top level attributes) - rust-lang#120293 (Deduplicate more sized errors on call exprs) - rust-lang#120295 (Remove `raw_os_nonzero` feature.) - rust-lang#120310 (adapt test for v0 symbol mangling) - rust-lang#120342 (Remove various `has_errors` or `err_count` uses) - rust-lang#120434 (Revert outdated version of "Add the wasm32-wasi-preview2 target") - rust-lang#120445 (Fix some `Arc` allocator leaks) - rust-lang#120475 (Improve error message when `cargo build` is used to build the compiler) - rust-lang#120476 (Remove some unnecessary check logic for lang items in HIR typeck) - rust-lang#120485 (add missing potential_query_instability for keys and values in hashmap) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120485 - chenyukang:yukang-add-query-instability-check, r=michaelwoerister add missing potential_query_instability for keys and values in hashmap From rust-lang#120435 (comment), These API are also returning iterator, so we need add `potential_query_instability` for them?
…=<try> Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…=<try> Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…=<try> Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…=<try> Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…=michaelwoerister Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…=michaelwoerister Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang#120485 (comment) r? `@michaelwoerister`
…oerister Clean up potential_query_instability with FxIndexMap and UnordMap From rust-lang/rust#120485 (comment) r? `@michaelwoerister`
From #120435 (comment),
These API are also returning iterator, so we need add
potential_query_instability
for them?