snippetrustMajor
failed to parse manifest - no targets specified
Viewed 0 times
specifiedtargetsparsemanifestfailed
Problem
I am new to Rust and attempting to build a test project with Cargo. My
(but the actual TOML file doesn't omit my email). When I
error: failed to parse manifest at
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
My
to no avail.
Cargo.toml looks like:[package]
name = "rust-play"
version = "0.0.1"
authors = [ "Bradley Wogsland " ](but the actual TOML file doesn't omit my email). When I
cargo build I am getting the following error:error: failed to parse manifest at
/Users/wogsland/Projects/rust-play/Cargo.tomlCaused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
My
main function is in a src/test.rs file. Do I need to specify that in the TOML file? If so, how? I tried addingtarget = "src/test.rs"to no avail.
Solution
As the error says:
either
So the direct answer is to add a
However, it's far more usual to just place the file in the expected location:
If it's actually for testing your code, then unit tests go in the same file as the code they are testing and integration tests go in
either
src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be presentSo the direct answer is to add a
[[bin]] section:[[bin]]
name = "test"
path = "src/test.rs"However, it's far more usual to just place the file in the expected location:
src/main.rs. You could also place it in src/bin/test.rs if you plan on having multiple binaries.If it's actually for testing your code, then unit tests go in the same file as the code they are testing and integration tests go in
tests/foo.rs.Code Snippets
[[bin]]
name = "test"
path = "src/test.rs"Context
Stack Overflow Q#37491436, score: 67
Revisions (0)
No revisions yet.