When i run rustdoc for a specific.rs file with an async file i get errorerror

the command i ran

rustdoc src/lib.rs --crate-name docs

the errorr


error[E0670]: `async fn` is not permitted in Rust 2015       
 --> src/lib.rs:2:5
  |
2 | pub async fn dummy_async_function() -> String {
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0670]: `async fn` is not permitted in Rust 2015
 --> src/lib.rs:8:5
  |
8 | pub async fn foo() {
  |     ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: pass `--edition 2021` to `rustc`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error: Compilation failed, aborting rustdoc

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0670`.

please help can i use cargo on that specific file

rustdoc src/lib.rs --crate-name docs --edition 2021

Alternatively, if you want to use cargo doc to only document the items in your crate root, you could annotate the public modules you don't want to be documented with #[doc(hidden)].

I haven't really grasped your use-case and what you want to achieve, so it's hard for me to give you good advice on what to do.

3 Likes

cargo doc -p docs

Rustdoc alone doesn’t understand crates and their dependencies. Launch it via Cargo.

2 Likes