How to pass rustc flags to cargo?

You can pass flags through Cargo by several different means: cargo rustc, which only affects your crate and not its dependencies. The RUSTFLAGS environment variable, which affects dependencies as well. Some flags have a proper Cargo option, e.g., -C lto and -C panic=abort can be specified in the Cargo.toml file. Add flags in .cargo/config using … Read more

How do I debug a failing cargo test in GDB?

You can get a test binary to filter the tests it runs by passing additional arguments to it; Cargo exposes this directly, too. Thus, cargo test test_extract_failure will just run that specific case. (This is convenient if you have other tests that panic and are expected to fail, so that they won’t call the rust_panic … Read more

failed to parse manifest – no targets specified

As the error says: either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present So 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 … Read more

How to move tests into a separate file for binaries in Rust’s Cargo?

The Rust Programming Language has a chapter dedicated to testing which you should read to gain a baseline understanding. It’s common to put unit tests (tests that are more allowed to access internals of your code) into a test module in each specific file: fn function_from_main() { println!(“Test OK”); } #[cfg(test)] mod test { use … Read more

Can’t use `-Z macro-backtrace` unstable option with `cargo`

-Z macro-backtrace is a rustc flag, not a cargo flag. You should be able to pass it to rustc using cargo +nightly rustc — -Z macro-backtrace. (The +nightly in the command line is optional if you already switched to the nightly compiler as the default.) Alternatively, you can set the RUSTFLAGS environment variable: export RUSTFLAGS=”-Z … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)