Skip to content

Commit 4208c19

Browse files
DetachHeadmeta-codesync[bot]
authored andcommitted
enable the dbg_macro clippy rule (#4821)
Summary: after connernilsen pointed out that i accidentally committed a `dbg!` macro, i wondered if there was a clippy rule to prevent such mistakes (see #4729 (comment)). turns out there is! note that enabling a rule globally seems to be nowhere near as straightforward as it is in most other linters, so i had to make some other changes: - i had to set `workspace = true` in each package (rust-lang/rust-clippy#16541 (comment)) - i also had to move the existing `unexpected_cfgs` config out of the individual packages into the global config, to workaround rust-lang/cargo#13157 Pull Request resolved: #4821 Test Plan: intentionally inserted a `dbg!` macro and ran `cargo clippy`: ``` error: the `dbg!` macro is intended as a debugging tool --> crates/pyrefly_config/src/migration/error_codes.rs:72:9 | 72 | dbg!(&pyright_cfg.type_checking_mode); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#dbg_macro = note: requested on the command line with `-D clippy::dbg-macro` help: remove the invocation before committing it to a version control system | 72 - dbg!(&pyright_cfg.type_checking_mode); 72 + &pyright_cfg.type_checking_mode; | error: could not compile `pyrefly_config` (lib) due to 1 previous error ``` Reviewed By: samwgoldman Differential Revision: D118959745 Pulled By: stroxler fbshipit-source-id: fca410967f9edfeb2defa2225a5cad4dd8962ea1
1 parent ce6b61e commit 4208c19

14 files changed

Lines changed: 42 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ resolver = "2"
4141
[workspace.package]
4242
license = "MIT"
4343
repository = "https://github.com/facebook/pyrefly"
44+
45+
[workspace.lints.clippy]
46+
dbg_macro = { level = "deny" }
47+
48+
[workspace.lints.rust]
49+
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fbcode_build)"]}

crates/pyrefly_bench_harness/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ license = "MIT"
1212
pyrefly = { path = "../../pyrefly" }
1313
pyrefly_config = { path = "../pyrefly_config" }
1414
pyrefly_util = { path = "../pyrefly_util" }
15+
16+
[lints]
17+
workspace = true

crates/pyrefly_build/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ pretty_assertions = { version = "1.4.1", features = ["alloc"], default-features
2929
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
3030
which = "8.0.5"
3131

32-
[lints.rust]
33-
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(fbcode_build)"]}
32+
[lints]
33+
workspace = true

crates/pyrefly_bundled/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ zstd = "0.13.3"
1919
sha2 = "0.10.6"
2020
tar = "0.4.46"
2121
zstd = { version = "0.13.3", features = ["experimental", "zstdmt"] }
22+
23+
[lints]
24+
workspace = true

crates/pyrefly_config/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ tempfile = "3.27.0"
4242
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
4343
uv-pep440 = "0.0.76"
4444
which = "8.0.5"
45+
46+
[lints]
47+
workspace = true

crates/pyrefly_derive/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ proc-macro = true
1717
proc-macro2 = { version = "1.0.107", features = ["span-locations"] }
1818
quote = "1.0.47"
1919
syn = { version = "3", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] }
20+
21+
[lints]
22+
workspace = true

crates/pyrefly_glean_schema/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ license = "MIT"
1212
serde = { version = "1.0.229", features = ["derive", "rc"] }
1313
serde_json = { version = "1.0.151", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] }
1414
serde_repr = "0.1.21"
15+
16+
[lints]
17+
workspace = true

crates/pyrefly_graph/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ license = "MIT"
1212
dupe = "0.9.1"
1313
pyrefly_util = { path = "../pyrefly_util" }
1414
starlark_map = "0.14.2"
15+
16+
[lints]
17+
workspace = true

crates/pyrefly_lsp_test/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ pretty_assertions = { version = "1.4.1", features = ["alloc"], default-features
1818
pyrefly = { path = "../../pyrefly" }
1919
pyrefly_util = { path = "../pyrefly_util" }
2020
serde_json = { version = "1.0.151", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] }
21+
22+
[lints]
23+
workspace = true

crates/pyrefly_python/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ vec1 = { version = "1.12.1", features = ["serde"] }
3434
[dev-dependencies]
3535
serde_json = { version = "1.0.151", features = ["alloc", "float_roundtrip", "raw_value", "unbounded_depth"] }
3636
toml = { version = "1.1.4", features = ["preserve_order"] }
37+
38+
[lints]
39+
workspace = true

0 commit comments

Comments
 (0)