You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a docstring that had a url in it. The code looked something like this:
#![forbid(unsafe_code)]#![deny(missing_docs)]#![deny(unused_must_use)]#![deny(unused_mut)]//! seed implements functions for moving between a seed and a seed phrase. This blog post provides//! a full specification for the code presented here://!//! https://blog.sia.tech/a-technical-breakdown-of-mysky-seeds-ba9964505978use anyhow::{bail,Error,Result};use sha2::{Digest,Sha256};// ...
When I ran cargo test, the output looked something like this:
Doc-tests seed_manager
running 1 test
test src/seed.rs - seed (line 9) ... FAILED
failures:
---- src/seed.rs - seed (line 9) stdout ----
error: expected expression, found `}`
--> src/seed.rs:11:1
|
2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_seed_rs_9_0() {
| - while parsing this struct
3 | https://blog.sia.tech/a-technical-breakdown-of-mysky-seeds-ba9964505978
4 | } _doctest_main_src_seed_rs_9_0() }
| ^ expected expression
error: struct literal body without path
--> src/seed.rs:9:73
|
2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_seed_rs_9_0() {
| _________________________________________________________________________^
3 | | https://blog.sia.tech/a-technical-breakdown-of-mysky-seeds-ba9964505978
4 | | } _doctest_main_src_seed_rs_9_0() }
| |_^
|
help: you might have forgotten to add the struct literal inside the block
|
2 ~ fn main() { #[allow(non_snake_case)] fn _doctest_main_src_seed_rs_9_0() { SomeStruct {
3 | https://blog.sia.tech/a-technical-breakdown-of-mysky-seeds-ba9964505978
4 ~ } } _doctest_main_src_seed_rs_9_0() }
|
error: aborting due to 2 previous errors
Couldn't compile the test.
failures:
src/seed.rs - seed (line 9)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
error: test failed, to rerun pass '--doc'
With some help, I was able to determine that the problem was my URL was being interpreted as code due to having 4 preceding spaces. The compiler error presented here was not remotely helpful to me (I'm relatively new to rust) in determining what the problem was. I think this issue has two potential resolutions:
don't interpret something as code if it's clearly not code
present a more helpful error message to suggest that my docstring is being interpreted as code and that I should remove the 4 spaces
I wrote a docstring that had a url in it. The code looked something like this:
When I ran
cargo test
, the output looked something like this:With some help, I was able to determine that the problem was my URL was being interpreted as code due to having 4 preceding spaces. The compiler error presented here was not remotely helpful to me (I'm relatively new to rust) in determining what the problem was. I think this issue has two potential resolutions:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: