Repository navigation
Description
Question
Google style guides forbid wildcard imports. Should the Rust workspace do the same, and should zackees/ci.yml enforce it across repos with an opt-out?
What Google actually says
- Java: Google Java Style §3.3.1 says "Wildcard imports, static or otherwise, are not used." This is a hard rule.
- Python: Google Python Style §2.2 says to import packages and modules only, not individual names, which rules out
from x import *. - Rust: Google publishes no Rust style rule against globs. Comprehensive Rust itself writes
use super::*;in its#[cfg(test)]examples. The Android and Chromium Rust docs defer to rustfmt/Clippy and have no glob ban. The idiomatic Rust norm, which Clippy encodes, is: avoid globs, exceptuse super::*in test modules and preludes.
So "Google bans wildcards" holds for Java and Python. For Rust, the closest standard is Clippy's wildcard_imports, and that lint already carries the two usual exemptions.
Current state (rust/ + dylints/, target dirs excluded)
There are 153 glob use lines:
| Category | Count | Example |
|---|---|---|
proptest::prelude::* |
98 | Tier 1 property tests. Clippy exempts these (prelude). |
use super::* |
17 | rust/obs-build/src/platform/shared_library.rs:27, rust/obs-media-io/src/ffi/audio_io.rs:130. Exempt when inside #[cfg(test)]. |
pub use x::* re-exports |
11 | rust/obs-build/src/platform/mod.rs:295 (pub use qt_sdk::*), rust/obs-util/src/ffi/threading.rs:11,14 (posix::*/windows::*), rust/obs-util/src/ffi/platform_{windows,cocoa}.rs (shims::*), rust/obs-media-io/src/audio_io.rs:245 |
| Enum-variant globs | ~11 | rust/obs-util/tests/config/cf_tokenizer.rs:62 (use CfTokenType::*), BaseTokenType::*, Op::*, Access::* |
| Crate/FFI-module globs in tests | ~14 | rust/obs-gpu-status/tests/gpu_status/classify.rs:7 (use obs_gpu_status::*, 6 files), obs_c_oracle::array_serializer::*, obs_media_io::ffi::{audio,video}_io::* |
| Macro-generated | 2 | rust/obs-properties/tests/properties/parity.rs:387,774 (use $api::*, selects C vs Rust API for differential tests) |
About 115 of the 153 are already exempt under Clippy's defaults. Roughly 35-40 sites would need either a fix or an opt-out. None are bindgen output. The pub use platform::* re-exports are the deliberate cfg_select! platform boundary facade (testing-policy "Platform boundary").
Tooling
clippy::wildcard_imports(pedantic) coversuse/pub useglobs. By default it skipsuse super::*in test modules and any*::prelude::*. clippy.toml settings:warn-on-all-wildcard-imports(default false, keep it that way) andallowed-wildcard-imports = [...]to allow-list specific crates or modules.clippy::enum_glob_use(pedantic) coversuse Enum::*.- No Dylint is needed. Clippy already handles this, including the exemptions.
- Current workspace config: there is no
[workspace.lints]inCargo.tomland noclippy.toml../lintandci/local_gate.py:366runsoldr cargo clippy --workspace --all-targets --locked -- -D warnings, so both lints are currently off. - Enabling: add to the root
Cargo.tomlplus[workspace.lints.clippy] wildcard_imports = "deny" enum_glob_use = "deny"
[lints] workspace = truein each member crate. Because clippy runs with--all-targets, tests are covered too. - Opt-out syntax: put
#[expect(clippy::wildcard_imports, reason = "...")]on theuseitem or the enclosing module. Prefer#[expect]over#[allow], because a staleexpectbecomes an error once the glob is gone. If many sites share one reason (e.g.obs_c_oracle), list it inallowed-wildcard-importsin clippy.toml instead.
Recommendation
Ban globs, with exemptions:
- Turn on
wildcard_importsandenum_glob_useasdenyin[workspace.lints.clippy]. - Keep Clippy's built-in exemptions:
use super::*in#[cfg(test)]modules and*::prelude::*(proptest). - Use
#[expect(..., reason)]opt-outs for:- the platform facade re-exports (
platform/mod.rs,ffi/threading.rs,shims::*), where the glob is the design; - the
$api::*macro in the differential parity tests.
- the platform facade re-exports (
- Fix the rest with explicit imports. This includes the enum-variant globs in test code (
CfTokenType::*becomesCfTokenType::{Word, ...}orCfTokenType::Wordwritten out) and the crate globs intests/integration files.
Rollout: fix everything in one PR rather than ratcheting. About 35-40 sites is small, mechanical work (cargo clippy --fix does not rewrite globs, but rust-analyzer's "expand glob import" does). A ratchet would cost more to maintain than the fix. Order: land the RED commit (lints enabled, clippy fails), then the GREEN commit (explicit imports and #[expect]s). Under coordination.md this is a focused lint/config change, so local RED evidence is enough.
Cost:
- About an hour of mechanical edits.
- New code pays slightly longer import lists.
- Benefits: no name shadowing or ambiguity when C-API symbol modules grow; grep-able provenance of FFI names (useful when tracking which
obs_*symbol a Rust module provides); and new upstream symbols can't silently change which item resolves.
Cross-repo default (zackees/ci.yml)
This belongs in zackees/ci.yml's docs/policy-rust.md as a candidate rule (next free ID after RUST-018). A follow-up issue there could read:
RUST-019 (candidate): glob imports denied via Clippy, with explicit opt-out. A Rust repo declares
[workspace.lints.clippy] wildcard_imports = "deny"andenum_glob_use = "deny", or the same flags on its clippy invocation. Clippy's default exemptions stay on:use super::*in#[cfg(test)]and*::prelude::*, withwarn-on-all-wildcard-importsleft false. Opt-outs are#[expect(clippy::wildcard_imports, reason = "...")]at the site, orallowed-wildcard-importsin clippy.toml. A repo-wideallowcounts as an exception and goes inci.toml[[exceptions]].ci_lint precheckcan check this statically: parseCargo.toml[workspace.lints.clippy]and flagallow/missing. Needs RED/GREEN fixtures underci_lint/tests/fixtures/RUST-019/. Rationale: Google Java Style §3.3.1 / Python §2.2 forbid wildcard imports, and Clippy encodes the Rust-idiomatic version.
obs-studio should not wait for that. Enable the workspace lints here first, then adopt the ci.yml rule once it exists.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 23, 2026
+1 for the glob ban as proposed. The Clippy defaults and the
#[expect(..., reason)]opt-outs are a good fit.One related point. I suggest a separate issue for it, because the scope and the tooling are different.
In Rust, a glob import cannot silently change behaviour: rustc reports ambiguous names, and explicit items shadow glob items. The higher risk in this workspace is Cargo feature unification. Some features mirror C build options (for example
gio=GIO_FOUND). Cargo unifies features across one build, so the CI lanes do not build the feature sets that CMake ships.Example on master (dc5b192):
libobs-rusthasdefault = ["gio"]→obs-util/gio.NO_DEFAULT_FEATURES, thengioonly if Gio is found (libobs/cmake/os-linux.cmake:82-84,os-freebsd.cmake:77-79).cargo test --workspaceandcargo clippy --workspace --all-targets. In these runs,cargo tree --workspace -e features -i obs-utilshowsgioalways on.#[cfg(not(feature = "gio"))]code inrust/obs-util/src/ffi/platform_nix_inhibit.rsis not compiled, linted or tested by the Rust lanes. A libobs built without GIO ships that code.The opt-in features (
libobs-integration,bundled-native) have the opposite gap: they are off in the--workspacelanes.Second, smaller point:
[workspace.dependencies]has onlylibloading. Other third-party dependencies are declared per crate, with different pins and features (cc,pkg-config,serde,serde_json).If you agree, I will open a separate issue: "CI: build and test the Cargo feature sets that CMake uses" (feature matrix lane with
cargo hack, third-party dependencies in[workspace.dependencies]withdefault-features = false). Aci_lintrule for zackees/ci.yml could go next to the RUST-019 proposal.zackees commentedon Oct 23, 2026
i agree
zackees commentedon Oct 23, 2026
Claiming: #1873 workspace glob-import ban.
Plan (one PR):
[workspace.lints.clippy] wildcard_imports/enum_glob_use = "deny"+[lints] workspace = truein members; record the local clippy failure.#[expect(..., reason)]only for the platform facade re-exports and the$api::*parity macro.First PR expected today.
lint: import Linux-only names only in non_apple (#1873)
zackees commentedon Oct 23, 2026
Fixed by #1956:
wildcard_importsandenum_glob_usearedenyin[workspace.lints.clippy], and everyrust/*crate uses them.Clippy's default exemptions (integration test crates,
#[cfg(test)]modules, preludes,pub usere-exports) covered most of the sites this issue counted. Only six non-testuse super::*sites needed explicit imports, and no#[expect]opt-outs were needed.Left: the cross-repo RUST-019 rule in zackees/ci.yml, and the Cargo feature-matrix issue proposed above. Neither is filed yet.
lint: deny glob imports in the Rust workspace (obs-rust#1873) (obs-ru…
vpacher commentedon Oct 24, 2026
Filed the Cargo feature-matrix part as #2056.