How to import from /crates/x/tests into /fuzz?

Say for example I have a struct Normalizer here ruff/crates/ruff_python_formatter/tests/normalizer.rs at main · astral-sh/ruff · GitHub and i would like to import that in fuzz target ruff_parse_simple in ruff/fuzz/fuzz_targets/ruff_parse_simple.rs at main · astral-sh/ruff · GitHub
How can i do that ?

There's no way to import private items like your Normalizer, which is pub(crate). There's also no way to import things from integration tests. You can either refactor it into its own crate, or copy the code.

2 Likes

You can make the Normalizer public but hidden:

#[doc(hidden)]
pub struct Normalizer;

This makes it accessible to dependents, but it's generally accepted that hiding it from documentation means “this is an implementation detail and I don't promise it is reasonable to use or semver-stable”. IDE tools like rust-analyzer will also hide it from suggestions.

2 Likes