Open
Description
Code
pub fn parse_config() {
let _json = jso::parse::Null;
}
Current output
error[E0603]: unit variant `Null` is private
--> src/lib.rs:2:27
|
2 | let _json = jso::parse::Null;
| ^^^^ private unit variant
|
note: the unit variant `Null` is defined here
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jso-1.0.0/src/parse.rs:11:24
|
11 | use crate::Val::{self, *};
| ^
help: consider importing this unit variant instead
|
2 - let _json = jso::parse::Null;
2 + let _json = jso::Val::Null;
|
help: import `Null` directly
|
2 - let _json = jso::parse::Null;
2 + let _json = jso::val::Val::Null::Null;
|
Desired output
error[E0603]: unit variant `Null` is private
--> src/lib.rs:2:27
|
2 | let _json = jso::parse::Null;
| ^^^^ private unit variant
|
note: the unit variant `Null` is defined here
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jso-1.0.0/src/parse.rs:11:24
|
11 | use crate::Val::{self, *};
| ^
help: consider importing this unit variant instead
|
2 - let _json = jso::parse::Null;
2 + let _json = jso::Val::Null;
|
Rationale and extra context
The first suggestion to use Val::Null
is fine. The second suggestion has 2 issues:
- the
val
module is private Val::Null::Null
is not a valid path
thus it is not needed in this case
Other cases
Rust Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Anything else?
Stumbled upon this because I noticed rust-analyzer was only suggesting types in type position. Wanted to see if it would suggest functions where applicable, and noticed it was also suggesting imported (but not re-exported) items in the scope of the parse
module of the crate.
If you use the suggestion of val::Val::Null:Null
, it will tell you the val
mod is private, but once again also suggests to use an invalid path, Val::Null::Null
:
[...]
error[E0603]: module `val` is private
--> src/lib.rs:2:20
|
2 | let _json = jso::val::Val::Null::Null;
| ^^^ private module
|
note: the module `val` is defined here
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jso-1.0.0/src/lib.rs:14:1
|
14 | mod val;
| ^^^^^^^
help: consider importing this variant instead
|
2 - let _json = jso::val::Val::Null::Null;
2 + let _json = jso::Val::Null::Null;
|