- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Open
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
I tried this code:
//! [`String`][string]
//!
//! [string]: alloc::string::String
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;[package]
name = "reproduction"
version = "0.1.0"
edition = "2021"
[features]
default = ["std"]
std = []And then ran this command:
RUSTDOCFLAGS="-D warnings" cargo +nightly docI 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.
error: redundant explicit link target
 --> src/lib.rs:1:16
  |
1 | //! [`String`][string]
  |      --------  ^^^^^^ explicit target is redundant
  |      |
  |      because label contains path that resolves to same destination
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:
rustc 1.74.0-nightly (e3abbd499 2023-09-06)
binary: rustc
commit-hash: e3abbd4994f72888f9e5e44dc89a4102e48c2a54
commit-date: 2023-09-06
host: aarch64-apple-darwin
release: 1.74.0-nightly
LLVM version: 17.0.0
Metadata
Metadata
Assignees
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.