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

Refactor PrimitiveTypeTable for Clippy #81680

Merged
merged 2 commits into from
Feb 6, 2021
Merged

Conversation

camsteffen
Copy link
Contributor

@camsteffen camsteffen commented Feb 2, 2021

I removed PrimitiveTypeTable and added PrimTy::ALL and PrimTy::from_name in its place. This allows Clippy to use PrimTy::from_name for the builtin_type_shadow lint, and a const list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.

@rust-highfive
Copy link
Collaborator

r? @oli-obk

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2021
@camsteffen camsteffen marked this pull request as ready for review February 2, 2021 21:15
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
Diff in /checkout/compiler/rustc_resolve/src/diagnostics.rs at line 718:
                         );
                     }
                 }
-                Scope::BuiltinTypes => suggestions.extend(PrimTy::ALL.iter().filter_map(|prim_ty| {
-                    let res = Res::PrimTy(*prim_ty);
-                    filter_fn(res).then_some(TypoSuggestion::from_res(prim_ty.name(), res))
-                })),
+                Scope::BuiltinTypes => {
+                    suggestions.extend(PrimTy::ALL.iter().filter_map(|prim_ty| {
+                        let res = Res::PrimTy(*prim_ty);
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/compiler/rustc_resolve/src/diagnostics.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
+                        filter_fn(res).then_some(TypoSuggestion::from_res(prim_ty.name(), res))
+                    }))
             }
 
             None::<()>
failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --stage 2 src/tools/tidy

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great refactoring!

Could you also add some documentation on the new constant and function? Other than those nits, r=me

compiler/rustc_hir/src/hir.rs Show resolved Hide resolved
@camsteffen
Copy link
Contributor Author

Good! I wasn't sure if the associated const was kosher. 😄

Changes made.

@oli-obk
Copy link
Contributor

oli-obk commented Feb 3, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Feb 3, 2021

📌 Commit f66115d has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 3, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 3, 2021
Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2021
…as-schievink

Rollup of 7 pull requests

Successful merges:

 - rust-lang#81402 (tidy: Run tidy style against markdown files.)
 - rust-lang#81434 (BTree: fix documentation of unstable public members)
 - rust-lang#81680 (Refactor `PrimitiveTypeTable` for Clippy)
 - rust-lang#81737 (typeck: Emit structured suggestions for tuple struct syntax)
 - rust-lang#81738 (Miscellaneous small diagnostics cleanup)
 - rust-lang#81766 (Enable 'task list' markdown extension)
 - rust-lang#81812 (Add a test for escaping LLVMisms in inline asm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 85fb5cd into rust-lang:master Feb 6, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 6, 2021
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 11, 2021
Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants