-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature examples force explicit listing of all [example]'s #5246
Comments
Actually, this is true for all targets. Changing this would cause massive breakage for all crates that have examples built from more than one source file, where shared files reside beside examples in |
Yeah, this behavior defenitelly feels weird to me... On the other hand, we defefenetelly can’t just change it (targets.rs includes all sorts of weird backward compatibility stuff for a reason), and we need to provide some way to opt out of automatic behavior.... I wonder if we could potentially change the way we infer targets in the new epoch? |
I see. I didn't know such sharing was possible. When I needed to share code between different integration However, if changing the default behavior is not feasible, perhaps we could have an opt-in mechanic where you declare that aside from these specific
This could probably be extended to |
Closing in favor of #5330! |
Suppose I have a collection of multiple
examples/
in the form of simple*.rs
files.I can expand it & add more example binaries by simply creating a new file inside the
examples/
directory:However, as soon as I want to write an example that requires one of the crate's
[features]
, I have to declare it in Cargo.toml:Unfortunately, this has a nasty side effect: it is now mandatory to explicitly declare all examples in Cargo.toml, whether they require features or not. Otherwise,
cargo run --example
will not be able to locate the relevant Rust source file, and presumablycargo test
will skip over building it, silently.(I've encountered this issue in my project here).
Is there a reason why
[[example]]
sections work this way? Wouldn't it be more intuitive if the allexamples/*.rs
files were interpreted as standalone examples by default, whilst also allowing for an individual[[example]]
section to override the properties of a particular example without affecting the auto-detected ones?The text was updated successfully, but these errors were encountered: