Warn on unreachable_pub#7762
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded a workspace Rust lint and performed a repository-wide visibility tightening: many ChangesVisibility & Linting Sweep
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (5)
crates/vm/src/stdlib/_stat.rs (2)
229-249:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winWindows-specific constants still use
pubvisibility.These Windows-specific items retain
pubvisibility while all other platform-agnostic constants were changed topub(super). This will triggerunreachable_pubwarnings when building on Windows. The lint likely wasn't caught because you rancargo clippyon a non-Windows platform.Proposed fix
#[cfg(windows)] #[pyattr] -pub use windows_sys::Win32::Storage::FileSystem::{ +pub(super) use windows_sys::Win32::Storage::FileSystem::{ FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_COMPRESSED, FILE_ATTRIBUTE_DEVICE, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_ENCRYPTED, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_INTEGRITY_STREAM, FILE_ATTRIBUTE_NO_SCRUB_DATA, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, FILE_ATTRIBUTE_OFFLINE, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_SPARSE_FILE, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_TEMPORARY, FILE_ATTRIBUTE_VIRTUAL, }; // Windows reparse point tags #[cfg(windows)] #[pyattr] -pub const IO_REPARSE_TAG_SYMLINK: u32 = 0xA000000C; +pub(super) const IO_REPARSE_TAG_SYMLINK: u32 = 0xA000000C; #[cfg(windows)] #[pyattr] -pub const IO_REPARSE_TAG_MOUNT_POINT: u32 = 0xA0000003; +pub(super) const IO_REPARSE_TAG_MOUNT_POINT: u32 = 0xA0000003; #[cfg(windows)] #[pyattr] -pub const IO_REPARSE_TAG_APPEXECLINK: u32 = 0x8000001B; +pub(super) const IO_REPARSE_TAG_APPEXECLINK: u32 = 0x8000001B;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/vm/src/stdlib/_stat.rs` around lines 229 - 249, The Windows-specific exported items and constants (the re-exported FILE_ATTRIBUTE_* group and the IO_REPARSE_TAG_* constants) are still declared pub and should match the platform-agnostic change to restrict visibility; change their visibility from pub to pub(super) for the windows-specific #[pyattr] block and for the three consts IO_REPARSE_TAG_SYMLINK, IO_REPARSE_TAG_MOUNT_POINT, and IO_REPARSE_TAG_APPEXECLINK so they no longer trigger unreachable_pub warnings when building on Windows.
340-346:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winmacOS-specific constants also retain
pubvisibility.Similarly, these macOS-specific constants will trigger
unreachable_pubwarnings when building on macOS.Proposed fix
#[cfg(target_os = "macos")] #[pyattr] -pub const SF_SUPPORTED: u32 = 0x009f0000; +pub(super) const SF_SUPPORTED: u32 = 0x009f0000; #[cfg(target_os = "macos")] #[pyattr] -pub const SF_SYNTHETIC: u32 = 0xc0000000; +pub(super) const SF_SYNTHETIC: u32 = 0xc0000000;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/vm/src/stdlib/_stat.rs` around lines 340 - 346, The two macOS-only constants SF_SUPPORTED and SF_SYNTHETIC are declared pub and cause unreachable_pub warnings; make them private by removing the pub modifier (keep the existing #[cfg(target_os = "macos")] and #[pyattr] attributes) so change "pub const SF_SUPPORTED" and "pub const SF_SYNTHETIC" to "const SF_SUPPORTED" and "const SF_SYNTHETIC".crates/vm/src/stdlib/_signal.rs (1)
75-81:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winIncomplete
unreachable_pubfix: non-unix/non-windows stubs remainpub.The unix equivalents of
SIG_DFL,SIG_IGN, andSIG_ERRwere correctly narrowed topub(crate)(Lines 60, 66), but the#[cfg(not(unix))]counterparts (Lines 75–81) still carrypub. Likewise, the#[cfg(not(any(unix, windows)))]stub ofsignal(Lines 200–206) remainspubwhile the unix/windows version was changed topub(crate). All of these sit insidepub(crate) mod _signal, sounreachable_pubwill still fire on non-unix/non-windows targets (e.g., WASM).🔧 Proposed fix
#[cfg(not(unix))] #[pyattr] -pub const SIG_DFL: sighandler_t = 0; +pub(crate) const SIG_DFL: sighandler_t = 0; #[cfg(not(unix))] #[pyattr] -pub const SIG_IGN: sighandler_t = 1; +pub(crate) const SIG_IGN: sighandler_t = 1; #[cfg(not(unix))] #[allow(dead_code)] -pub const SIG_ERR: sighandler_t = -1 as _; +pub(crate) const SIG_ERR: sighandler_t = -1 as _;#[cfg(not(any(unix, windows)))] #[pyfunction] -pub fn signal( +pub(crate) fn signal( _signalnum: i32, _handler: PyObjectRef, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>> {Also applies to: 200-206
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/vm/src/stdlib/_signal.rs` around lines 75 - 81, The non-unix/non-windows stubs for signal symbols are still declared public, causing unreachable_pub warnings; change the visibility of SIG_DFL, SIG_IGN, and SIG_ERR in the #[cfg(not(unix))] block to pub(crate) (matching the unix variants) and likewise change the #[cfg(not(any(unix, windows)))] stub of the signal function to pub(crate) so all declarations inside pub(crate) mod _signal have consistent, non-public visibility; update the declarations for the symbols SIG_DFL, SIG_IGN, SIG_ERR and the signal function accordingly.crates/vm/src/getpath.rs (1)
46-66:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winWindows
mod platformitems still use barepub, which will re-triggerunreachable_pubon Windows builds.The non-Windows
mod platform(lines 15–43) was correctly updated topub(super), but the#[cfg(windows)]variant (lines 46–66) still exposes all items as plainpub. Sincemod platformis a private module in both cfg branches, the Windows items are equally unreachable from outside this file, and the newly-enabledunreachable_pub = "warn"lint will fire when building on Windows.🛠️ Proposed fix
#[cfg(windows)] mod platform { use crate::version; - pub const BUILDDIR_TXT: &str = "pybuilddir.txt"; - pub const BUILD_LANDMARK: &str = "Modules\\Setup.local"; - pub const VENV_LANDMARK: &str = "pyvenv.cfg"; - pub const BUILDSTDLIB_LANDMARK: &str = "Lib\\os.py"; - pub const STDLIB_SUBDIR: &str = "Lib"; + pub(super) const BUILDDIR_TXT: &str = "pybuilddir.txt"; + pub(super) const BUILD_LANDMARK: &str = "Modules\\Setup.local"; + pub(super) const VENV_LANDMARK: &str = "pyvenv.cfg"; + pub(super) const BUILDSTDLIB_LANDMARK: &str = "Lib\\os.py"; + pub(super) const STDLIB_SUBDIR: &str = "Lib"; - pub fn stdlib_landmarks() -> [String; 2] { + pub(super) fn stdlib_landmarks() -> [String; 2] { ["Lib\\os.py".into(), "Lib\\os.pyc".into()] } - pub fn platstdlib_landmark() -> String { + pub(super) fn platstdlib_landmark() -> String { "DLLs".into() } - pub fn zip_landmark() -> String { + pub(super) fn zip_landmark() -> String { format!("python{}{}.zip", version::MAJOR, version::MINOR) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/vm/src/getpath.rs` around lines 46 - 66, The Windows-specific mod platform currently exposes items with plain pub which triggers unreachable_pub; change the visibility of all public items in the #[cfg(windows)] platform module to pub(super) (i.e., BUILDDIR_TXT, BUILD_LANDMARK, VENV_LANDMARK, BUILDSTDLIB_LANDMARK, STDLIB_SUBDIR and the functions stdlib_landmarks, platstdlib_landmark, zip_landmark) so they mirror the non-Windows branch and remain reachable only within the parent module.crates/stdlib/src/ssl/cert.rs (1)
1262-1281:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
validate_cert_key_match()never validates the key pair.This returns
Ok(())for any non-empty cert chain plus any parseable private key; it never compares the certificate’s public key to the private key. So mismatched cert/key pairs are only caught later, despite the helper name and docs claiming they were validated here. Either perform the public-key check in this helper or rename/document it as a private-key sanity check instead.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/stdlib/src/ssl/cert.rs` around lines 1262 - 1281, The helper validate_cert_key_match currently only checks the private key parses (any_supported_type) and doesn't verify the cert's public key matches the private key; update it to actually compare keys: parse the first certificate's public key (from CertificateDer<'_>) and derive the public key from private_key (via any_supported_type or the signing key API), then compare their raw public-key bytes (or use rustls/ring APIs to verify equality) and return Err(...) if they differ; reference validate_cert_key_match, CertificateDer, PrivateKeyDer, and any_supported_type (or use CertifiedKey creation) so the function fails on mismatched pairs, or if you prefer not to change behavior, rename/document validate_cert_key_match to reflect it only checks private-key parseability.
🧹 Nitpick comments (1)
crates/host_env/src/select.rs (1)
5-5: ⚡ Quick winAvoid exposing
platformas public API unless this is intentional.Making
platformpublic exports unsafe, low-level OS bindings as part of the crate interface. If this was only for lint cleanup, prefer crate-local visibility.Proposed adjustment
-#[cfg(unix)] -pub mod platform { +#[cfg(unix)] +pub(crate) mod platform { ... -#[cfg(windows)] -pub mod platform { +#[cfg(windows)] +pub(crate) mod platform { ... -#[cfg(target_os = "wasi")] -pub mod platform { +#[cfg(target_os = "wasi")] +pub(crate) mod platform {Also applies to: 16-16, 52-52
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/host_env/src/select.rs` at line 5, The module `platform` is unnecessarily exported; remove `pub` so the low-level OS bindings are crate-private (change `pub mod platform` to `mod platform`) to avoid leaking unsafe internals in the public API, and apply the same visibility change for any other `pub mod platform` occurrences (e.g., the other declarations found in this file) so all platform bindings remain crate-local; update any internal references to use the now-private module path if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/vm/src/builtins/type.rs`:
- Line 411: The public API exposes the crate-private type PyAttributes which
triggers private_in_public; to fix, make visibility consistent: either change
the type alias PyAttributes to pub type PyAttributes = ... so it can be used in
public signatures, or keep PyAttributes as pub(crate) and change the three
methods on PyType (new_heap, new_static, and get_attributes) from pub to
pub(crate). Locate the type alias named PyAttributes and the methods new_heap,
new_static, and get_attributes in the PyType impl and apply one of these two
consistent-visibility fixes so the compiler lint is satisfied.
---
Outside diff comments:
In `@crates/stdlib/src/ssl/cert.rs`:
- Around line 1262-1281: The helper validate_cert_key_match currently only
checks the private key parses (any_supported_type) and doesn't verify the cert's
public key matches the private key; update it to actually compare keys: parse
the first certificate's public key (from CertificateDer<'_>) and derive the
public key from private_key (via any_supported_type or the signing key API),
then compare their raw public-key bytes (or use rustls/ring APIs to verify
equality) and return Err(...) if they differ; reference validate_cert_key_match,
CertificateDer, PrivateKeyDer, and any_supported_type (or use CertifiedKey
creation) so the function fails on mismatched pairs, or if you prefer not to
change behavior, rename/document validate_cert_key_match to reflect it only
checks private-key parseability.
In `@crates/vm/src/getpath.rs`:
- Around line 46-66: The Windows-specific mod platform currently exposes items
with plain pub which triggers unreachable_pub; change the visibility of all
public items in the #[cfg(windows)] platform module to pub(super) (i.e.,
BUILDDIR_TXT, BUILD_LANDMARK, VENV_LANDMARK, BUILDSTDLIB_LANDMARK, STDLIB_SUBDIR
and the functions stdlib_landmarks, platstdlib_landmark, zip_landmark) so they
mirror the non-Windows branch and remain reachable only within the parent
module.
In `@crates/vm/src/stdlib/_signal.rs`:
- Around line 75-81: The non-unix/non-windows stubs for signal symbols are still
declared public, causing unreachable_pub warnings; change the visibility of
SIG_DFL, SIG_IGN, and SIG_ERR in the #[cfg(not(unix))] block to pub(crate)
(matching the unix variants) and likewise change the #[cfg(not(any(unix,
windows)))] stub of the signal function to pub(crate) so all declarations inside
pub(crate) mod _signal have consistent, non-public visibility; update the
declarations for the symbols SIG_DFL, SIG_IGN, SIG_ERR and the signal function
accordingly.
In `@crates/vm/src/stdlib/_stat.rs`:
- Around line 229-249: The Windows-specific exported items and constants (the
re-exported FILE_ATTRIBUTE_* group and the IO_REPARSE_TAG_* constants) are still
declared pub and should match the platform-agnostic change to restrict
visibility; change their visibility from pub to pub(super) for the
windows-specific #[pyattr] block and for the three consts
IO_REPARSE_TAG_SYMLINK, IO_REPARSE_TAG_MOUNT_POINT, and
IO_REPARSE_TAG_APPEXECLINK so they no longer trigger unreachable_pub warnings
when building on Windows.
- Around line 340-346: The two macOS-only constants SF_SUPPORTED and
SF_SYNTHETIC are declared pub and cause unreachable_pub warnings; make them
private by removing the pub modifier (keep the existing #[cfg(target_os =
"macos")] and #[pyattr] attributes) so change "pub const SF_SUPPORTED" and "pub
const SF_SYNTHETIC" to "const SF_SUPPORTED" and "const SF_SYNTHETIC".
---
Nitpick comments:
In `@crates/host_env/src/select.rs`:
- Line 5: The module `platform` is unnecessarily exported; remove `pub` so the
low-level OS bindings are crate-private (change `pub mod platform` to `mod
platform`) to avoid leaking unsafe internals in the public API, and apply the
same visibility change for any other `pub mod platform` occurrences (e.g., the
other declarations found in this file) so all platform bindings remain
crate-local; update any internal references to use the now-private module path
if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: b2de1c61-f0f8-482f-8dd8-210842562825
📒 Files selected for processing (106)
Cargo.tomlcrates/codegen/src/symboltable.rscrates/codegen/src/unparse.rscrates/derive-impl/src/compile_bytecode.rscrates/derive-impl/src/error.rscrates/derive-impl/src/from_args.rscrates/derive-impl/src/pymodule.rscrates/derive-impl/src/pystructseq.rscrates/derive-impl/src/util.rscrates/host_env/src/select.rscrates/stdlib/src/_tokenize.rscrates/stdlib/src/array.rscrates/stdlib/src/compression.rscrates/stdlib/src/faulthandler.rscrates/stdlib/src/hashlib.rscrates/stdlib/src/json/machinery.rscrates/stdlib/src/mmap.rscrates/stdlib/src/openssl/ssl_data_31.rscrates/stdlib/src/pyexpat.rscrates/stdlib/src/select.rscrates/stdlib/src/ssl.rscrates/stdlib/src/ssl/cert.rscrates/stdlib/src/ssl/compat.rscrates/stdlib/src/ssl/error.rscrates/stdlib/src/ssl/oid.rscrates/stdlib/src/unicodedata.rscrates/vm/src/anystr.rscrates/vm/src/buffer.rscrates/vm/src/builtins/asyncgenerator.rscrates/vm/src/builtins/builtin_func.rscrates/vm/src/builtins/bytearray.rscrates/vm/src/builtins/bytes.rscrates/vm/src/builtins/capsule.rscrates/vm/src/builtins/code.rscrates/vm/src/builtins/complex.rscrates/vm/src/builtins/coroutine.rscrates/vm/src/builtins/descriptor.rscrates/vm/src/builtins/dict.rscrates/vm/src/builtins/enumerate.rscrates/vm/src/builtins/filter.rscrates/vm/src/builtins/float.rscrates/vm/src/builtins/frame.rscrates/vm/src/builtins/function.rscrates/vm/src/builtins/generator.rscrates/vm/src/builtins/genericalias.rscrates/vm/src/builtins/int.rscrates/vm/src/builtins/interpolation.rscrates/vm/src/builtins/list.rscrates/vm/src/builtins/map.rscrates/vm/src/builtins/mappingproxy.rscrates/vm/src/builtins/memory.rscrates/vm/src/builtins/module.rscrates/vm/src/builtins/namespace.rscrates/vm/src/builtins/object.rscrates/vm/src/builtins/range.rscrates/vm/src/builtins/set.rscrates/vm/src/builtins/singletons.rscrates/vm/src/builtins/slice.rscrates/vm/src/builtins/staticmethod.rscrates/vm/src/builtins/str.rscrates/vm/src/builtins/super.rscrates/vm/src/builtins/template.rscrates/vm/src/builtins/traceback.rscrates/vm/src/builtins/type.rscrates/vm/src/builtins/union.rscrates/vm/src/builtins/weakproxy.rscrates/vm/src/builtins/weakref.rscrates/vm/src/builtins/zip.rscrates/vm/src/bytes_inner.rscrates/vm/src/codecs.rscrates/vm/src/coroutine.rscrates/vm/src/dict_inner.rscrates/vm/src/exceptions.rscrates/vm/src/function/getset.rscrates/vm/src/getpath.rscrates/vm/src/intern.rscrates/vm/src/object/core.rscrates/vm/src/object/traverse_object.rscrates/vm/src/ospath.rscrates/vm/src/readline.rscrates/vm/src/stdlib/_ast.rscrates/vm/src/stdlib/_ast/pyast.rscrates/vm/src/stdlib/_ctypes.rscrates/vm/src/stdlib/_ctypes/array.rscrates/vm/src/stdlib/_ctypes/base.rscrates/vm/src/stdlib/_ctypes/function.rscrates/vm/src/stdlib/_ctypes/library.rscrates/vm/src/stdlib/_ctypes/pointer.rscrates/vm/src/stdlib/_ctypes/simple.rscrates/vm/src/stdlib/_ctypes/structure.rscrates/vm/src/stdlib/_ctypes/union.rscrates/vm/src/stdlib/_functools.rscrates/vm/src/stdlib/_imp.rscrates/vm/src/stdlib/_io.rscrates/vm/src/stdlib/_signal.rscrates/vm/src/stdlib/_sre.rscrates/vm/src/stdlib/_stat.rscrates/vm/src/stdlib/_symtable.rscrates/vm/src/stdlib/_thread.rscrates/vm/src/stdlib/_typing.rscrates/vm/src/stdlib/builtins.rscrates/vm/src/stdlib/os.rscrates/vm/src/stdlib/sys.rscrates/vm/src/stdlib/sys/monitoring.rscrates/vm/src/stdlib/time.rscrates/vm/src/vm/method.rs
| /// that maintains order and is compatible with the standard HashMap This is probably | ||
| /// faster and only supports strings as keys. | ||
| pub type PyAttributes = IndexMap<&'static PyStrInterned, PyObjectRef, ahash::RandomState>; | ||
| pub(crate) type PyAttributes = IndexMap<&'static PyStrInterned, PyObjectRef, ahash::RandomState>; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 1. Check how (and whether) the builtins::type module is re-exported at the vm crate root
rg -n "pub.*builtins|pub use.*type" crates/vm/src/lib.rs
# 2. Look for public re-exports of PyAttributes or the three affected methods
rg -n "PyAttributes|new_heap|new_static|get_attributes" crates/vm/src/lib.rs
# 3. Check if the builtins module itself is pub or pub(crate)
rg -n "mod builtins" crates/vm/src/lib.rs crates/vm/src/
# 4. Confirm whether any crate outside vm references PyAttributes
rg -rn "PyAttributes" --type rust --glob "!crates/vm/*"Repository: RustPython/RustPython
Length of output: 269
Fix visibility inconsistency: pub(crate) PyAttributes type cannot be used in public method signatures.
Line 411 narrows PyAttributes to pub(crate), but three methods in the same PyType struct remain pub and expose this private type:
new_heap(line 528): parameterattrs: PyAttributesnew_static(line 749): parameterattrs: PyAttributesget_attributes(line 1157): return type-> PyAttributes
Since builtins module is re-exported as pub mod at the crate root (crates/vm/src/lib.rs:46), these pub methods are part of the public API. Exposing a private type in their signatures triggers Rust's private_in_public lint and prevents compilation.
Either make PyAttributes public again or narrow those three methods to pub(crate) to match the visibility of the type they expose.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/vm/src/builtins/type.rs` at line 411, The public API exposes the
crate-private type PyAttributes which triggers private_in_public; to fix, make
visibility consistent: either change the type alias PyAttributes to pub type
PyAttributes = ... so it can be used in public signatures, or keep PyAttributes
as pub(crate) and change the three methods on PyType (new_heap, new_static, and
get_attributes) from pub to pub(crate). Locate the type alias named PyAttributes
and the methods new_heap, new_static, and get_attributes in the PyType impl and
apply one of these two consistent-visibility fixes so the compiler lint is
satisfied.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/vm/src/readline.rs`:
- Line 22: The modules basic_readline and rustyline_readline are currently
declared public which unnecessarily exposes backend internals; make these
modules private (remove the pub modifier) and then tighten the visibility of the
inner Readline types and their methods to pub(super) or pub(crate) as
appropriate so only the outer wrapper API can access them; update any uses in
the outer wrapper to match the new visibility (e.g., reference the types via the
parent module) and ensure any items truly needed externally retain only the
minimal pub(super)/pub(crate) visibility.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: b3e6e9dc-ce58-4631-bfb7-1741e35dee6f
📒 Files selected for processing (2)
crates/vm/src/builtins/dict.rscrates/vm/src/readline.rs
✅ Files skipped from review due to trivial changes (1)
- crates/vm/src/builtins/dict.rs
|
|
||
| #[allow(unused)] | ||
| mod basic_readline { | ||
| pub mod basic_readline { |
There was a problem hiding this comment.
Avoid exposing backend modules publicly to satisfy unreachable_pub.
Making basic_readline and rustyline_readline public widens the crate API with backend-specific internals. Prefer keeping these modules private and tightening inner visibility (pub(super)/pub(crate)) for only what the outer wrapper needs.
Suggested direction
-#[allow(unused)]
-pub mod basic_readline {
+#[allow(unused)]
+mod basic_readline { #[cfg(not(target_arch = "wasm32"))]
-pub mod rustyline_readline {
+mod rustyline_readline {Then reduce inner Readline type/method visibility to pub(super) (or pub(crate) where needed) instead of exposing modules.
Also applies to: 69-69
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/vm/src/readline.rs` at line 22, The modules basic_readline and
rustyline_readline are currently declared public which unnecessarily exposes
backend internals; make these modules private (remove the pub modifier) and then
tighten the visibility of the inner Readline types and their methods to
pub(super) or pub(crate) as appropriate so only the outer wrapper API can access
them; update any uses in the outer wrapper to match the new visibility (e.g.,
reference the types via the parent module) and ensure any items truly needed
externally retain only the minimal pub(super)/pub(crate) visibility.
|
@youknowone can you please approve this PR? it will be auto-merged |
How is this not enabled by default? 😕
Summary by CodeRabbit