Rust Error E0780: Cannot use doc(inline) with anonymous imports
Understanding Rust Error E0780
Rust Error E0780 occurs when you attempt to use the #[doc(inline)] attribute with an anonymous import. The error prevents the unnecessary use of #[doc(inline)] when Rust would always render the import with the #[doc(no_inline)] attribute. This article will explain the cause of the error, how to resolve it, and showcase examples.
Causing Rust Error E0780
To demonstrate Rust Error E0780, consider the following erroneous code example:
mod foo {
pub struct Foo;
}
#[doc(inline)] // error: invalid doc argument
pub use foo::Foo as _;
In this example, the #[doc(inline)] attribute is applied incorrectly to an anonymous import statement. This will result in an error:
error[E0780]: Cannot use doc(inline) with anonymous imports
Fixing Rust Error E0780
To fix Rust Error E0780, you need to remove the #[doc(inline)] attribute from the anonymous import statement. The corrected code will look like this:
mod foo {
pub struct Foo;
}
pub use foo::Foo as _;
With this change, the code compiles successfully, and Rust will render the anonymous import using the #[doc(no_inline)] attribute, as intended.
Conclusion
Rust Error E0780 arises when attempting to use #[doc(inline)] with an anonymous import. To resolve this error, simply remove the #[doc(inline)] attribute from the import statement. Remember that anonymous imports are always rendered using the #[doc(no_inline)] attribute, which makes the improper use of #[doc(inline)] unnecessary and leads to the error.