The Wayback Machine - https://web.archive.org/web/20211028174817/https://github.com/rust-lang/rust/pull/89558
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

Add rustc lint, warning when iterating over hashmaps #89558

Merged
merged 4 commits into from Oct 24, 2021

Conversation

@lcnr
Copy link
Contributor

@lcnr lcnr commented Oct 5, 2021

r? rust-lang/wg-incr-comp

@rust-highfive
Copy link
Collaborator

@rust-highfive rust-highfive commented Oct 5, 2021

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@lcnr lcnr changed the title Add lint warning against iterating over hashmaps Add rustc lint warning against iterating over hashmaps Oct 5, 2021
@lcnr lcnr changed the title Add rustc lint warning against iterating over hashmaps Add rustc lint warning when iterating over hashmaps Oct 5, 2021
@@ -0,0 +1,39 @@
error: using `drain` can result in unstable query results
Copy link
Contributor

@estebank estebank Oct 5, 2021

The lint looks useful in general for end users (I'm sure it's already in clippy). It'd be nice if we uplifted it someday.

@estebank
Copy link
Contributor

@estebank estebank commented Oct 5, 2021

@bors r+

We don't need to mark the Fx versions?

@bors
Copy link
Contributor

@bors bors commented Oct 5, 2021

📌 Commit 82fea72 has been approved by estebank

@lcnr
Copy link
Contributor Author

@lcnr lcnr commented Oct 5, 2021

@bors r-

somehow CI doesn't run at all for this PR and this lint causes a lot of warnings which is why i've opened rust-lang/compiler-team#465 for this.

We don't need to mark the `Fx versions?

The Fx versions are only type aliases, which are pretty much ignored by rustc (as you probably also painfully aware)

@petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented Oct 5, 2021

@lcnr
We have some lint naming conventions - https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints.
As you can see allow(query_stability) doesn't make much sense as a sentence.

@rust-log-analyzer

This comment has been hidden.

@cjgillot cjgillot self-assigned this Oct 5, 2021
@lcnr lcnr changed the title Add rustc lint warning when iterating over hashmaps Add rustc lint, warning when iterating over hashmaps Oct 5, 2021
@lqd
Copy link
Member

@lqd lqd commented Oct 7, 2021

Should we wait for the FCP to complete on rust-lang/compiler-team#465, or at least for the MCP to be announced in the t-compiler meeting ? (not that they would be controversial, of course; just opportunities for discussion and possible improvements)

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Oct 8, 2021

Bookkeeping: #84447

@lcnr lcnr force-pushed the query-stable-lint branch from 2cad766 to 0031ac8 Oct 13, 2021
@rust-log-analyzer

This comment has been hidden.

@lcnr
Copy link
Contributor Author

@lcnr lcnr commented Oct 13, 2021

@petrochenkov renamed the lint to potential_query_instability.

and explicitly allowed this lint in every crate that is affected. Fixing all warnings as part of this PR is a lot of work, especially as some of those warnings don't seems trivial to fix

@rust-log-analyzer

This comment has been hidden.

@lcnr lcnr force-pushed the query-stable-lint branch from f1a64d7 to 729fa25 Oct 13, 2021
@rust-log-analyzer

This comment has been hidden.

@lcnr lcnr force-pushed the query-stable-lint branch from 729fa25 to 1e13c75 Oct 13, 2021
@rust-log-analyzer

This comment has been hidden.

@rust-log-analyzer

This comment has been hidden.

@lcnr lcnr force-pushed the query-stable-lint branch from 613fd07 to 4724ee5 Oct 21, 2021
@lcnr lcnr force-pushed the query-stable-lint branch from 4724ee5 to 22e1798 Oct 21, 2021
@lcnr
Copy link
Contributor Author

@lcnr lcnr commented Oct 23, 2021

this should be ready for merge now 🤔 going to deal with the FIXME(rustdoc) in a followup PR

@@ -830,6 +830,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx.type_of(def_id)
};
let substs = self.infcx.fresh_substs_for_item(span, def_id);
self.write_substs(hir_id, substs);
Copy link
Contributor

@estebank estebank Oct 23, 2021

This change seems unrelated to the lint, right? It seems correct to do, I'm just surprised it was either not needed until now or exposed as needed in this PR.

@cjgillot cjgillot removed their assignment Oct 23, 2021
@estebank
Copy link
Contributor

@estebank estebank commented Oct 23, 2021

We are allowing these in a lot of modules. Do we have plans to fix them at a later point?

@bors r+

@bors
Copy link
Contributor

@bors bors commented Oct 23, 2021

📌 Commit 22e1798 has been approved by estebank

@lcnr
Copy link
Contributor Author

@lcnr lcnr commented Oct 23, 2021

We are allowing these in a lot of modules. Do we have plans to fix them at a later point?

I am allowing these for all compiler crates rn and intend to slowly remove these crate in the future.
Fixing all the cases (or figuring out whether they are correct) isn't always trivial, so I didn't do that in this PR

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 23, 2021
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2021
…askrgr

Rollup of 3 pull requests

Successful merges:

 - rust-lang#85254 (Normalize MIR with RevealAll before optimizations.)
 - rust-lang#89558 (Add rustc lint, warning when iterating over hashmaps)
 - rust-lang#90205 (Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 24, 2021
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2021
…askrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#85254 (Normalize MIR with RevealAll before optimizations.)
 - rust-lang#89558 (Add rustc lint, warning when iterating over hashmaps)
 - rust-lang#90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - rust-lang#90155 (Fix alignment of method headings for scannability)
 - rust-lang#90205 (Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 24, 2021
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 24, 2021
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2021
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#85254 (Normalize MIR with RevealAll before optimizations.)
 - rust-lang#89558 (Add rustc lint, warning when iterating over hashmaps)
 - rust-lang#90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - rust-lang#90155 (Fix alignment of method headings for scannability)
 - rust-lang#90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn)
 - rust-lang#90205 (Repace use of `static_nobundle` with `native_link_modifiers` within Rust codebase)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 24, 2021
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2021
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#89558 (Add rustc lint, warning when iterating over hashmaps)
 - rust-lang#90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin)
 - rust-lang#90155 (Fix alignment of method headings for scannability)
 - rust-lang#90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn)
 - rust-lang#90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call)
 - rust-lang#90234 (Temporarily turn overflow checks off for rustc-rayon-core)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 87822b2 into rust-lang:master Oct 24, 2021
10 checks passed
@rustbot rustbot added this to the 1.58.0 milestone Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment