-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error about redundant_explicit_links with conditional no_std #115637
Comments
cc @ChAoSUnItY (#113167) |
It seems that the warning is true, since Additionally, if this is not intentional, perhaps before you move on and makes |
Perhaps I'm misunderstanding, but is this true? After all, this compiles fine: extern crate alloc;
fn main() {
let _ = std::string::String::new();
} |
Try remove error[E0433]: failed to resolve: use of undeclared crate or module `std`
--> src\main.rs:9:13
|
9 | let _ = std::string::String::new();
| ^^^ use of undeclared crate or module `std`
|
help: consider importing this struct
|
5 + use alloc::string::String;
|
help: if you import `String`, refer to it directly
|
9 - let _ = std::string::String::new();
9 + let _ = String::new();
| |
Yeah sure, because of the |
After testing with few different approaches with the following code: //! Unspecified: [`String`]
//!
//! Std String: [`String`][std::string::String]
//! Alloc String: [`String`][alloc::string::String]
//! Std referenced String: [`String`][std_string]
//! Alloc referenced String: [`String`][alloc_string]
//!
//! [std_string]: std::string::String
//! [alloc_string]: alloc::string::String
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
fn main() {
} All links link to |
This issue is related to a newer issue about The root cause of the issue is often that people conditionally depend on #![cfg_attr(not(feature = "std"), no_std)] Which will result in the #![no_std]
#[cfg(feature = "std")]
extern crate std; |
I tried this code:
And then ran this command:
RUSTDOCFLAGS="-D warnings" cargo +nightly doc
I expected to see this happen: Documents without errors.
Instead, this happened: Error that link target is redundant. Only happens if std feature is enabled because
String
is in scope then. However, the explicit anchor is required for no_std.Perhaps, this is just an unfortunate situation where I need to use
#![allow(rustdoc::redundant_explicit_links)]
, but it was confusing at first.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: