Closed
Description
I tried this code:
use std::{num::ParseFloatError, str::FromStr};
/// Uses the rules from [`f64::from_str()`].
pub struct Number {
pub value: f64,
}
impl FromStr for Number {
type Err = ParseFloatError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let value = s.parse::<f64>()?;
Ok(Self{value})
}
}
I expected to see this happen: the [f64::from_str()]
in the docstring links to https://doc.rust-lang.org/1.56.0/std/primitive.f64.html#method.from_str
Instead, this happened:
cargo doc
Documenting cayenne v0.1.0 (/home/abi/projects/classabbyamp/rspice)
warning: unresolved link to `f64::from_str`
--> src/v.rs:3:27
|
3 | /// Uses the rules from [`f64::from_str()`].
| ^^^^^^^^^^^^^^^ the builtin type `f64` has no function named `from_str`
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: `cayenne` (lib doc) generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.34s
This does not happen for [f64::floor()]
nor for linking to a non-primitive FromStr
implmentation, like [Number::from_str()]
(in the example above).
@jyn514 suggested that resolve_primitive_associated_item()
may be only looking at inherent impls and not trait impls, and that it may need a call to resolve_associated_trait_item()
.
Meta
rustc --version --verbose
:
rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: x86_64-unknown-linux-gnu
release: 1.56.0
LLVM version: 13.0.0
Reproduced on beta:
rustc 1.57.0-beta.3 (708d57e28 2021-11-01)
binary: rustc
commit-hash: 708d57e288d051a6238ed56039ffeac158e10e84
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.57.0-beta.3
LLVM version: 13.0.0
and nightly:
rustc 1.58.0-nightly (46b8e7488 2021-11-07)
binary: rustc
commit-hash: 46b8e7488eae116722196e8390c1bd2ea2e396cf
commit-date: 2021-11-07
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
Backtrace
RUSTC_BOOTSTRAP=1 RUSTDOC_LOG=rustdoc::passes::collect_intra_doc_links=debug cargo rustdoc -- -Dwarnings -Ztreat-err-as-bug
:
Documenting cayenne v0.1.0 (/home/classabbyamp/projects/cayenne)
warning: some trace filter directives would enable traces that are disabled statically
| `rustdoc::passes::collect_intra_doc_links=debug` would enable the DEBUG level for the `rustdoc::passes::collect_intra_doc_links` target
= note: the static max level is `info`
= help: to enable DEBUG logging, remove the `max_level_info` feature
DEBUG rustdoc::passes::collect_intra_doc_links::early doc=" Uses the rules from [`f64::from_str()`]."
DEBUG rustdoc::passes::collect_intra_doc_links::early link.link="`f64::from_str()`"
DEBUG rustdoc::passes::collect_intra_doc_links looking for the `Self` type
DEBUG rustdoc::passes::collect_intra_doc_links using item_name(): Some("cayenne")
DEBUG rustdoc::passes::collect_intra_doc_links looking for the `Self` type
DEBUG rustdoc::passes::collect_intra_doc_links using item_name(): Some("v")
DEBUG rustdoc::passes::collect_intra_doc_links looking for the `Self` type
DEBUG rustdoc::passes::collect_intra_doc_links using item_name(): Some("Number")
DEBUG rustdoc::passes::collect_intra_doc_links combined_docs=Uses the rules from [`f64::from_str()`].
DEBUG rustdoc::passes::collect_intra_doc_links f64::from_str resolved to Err(()) in namespace ValueNS
DEBUG rustdoc::passes::collect_intra_doc_links resolved primitives F64
DEBUG rustdoc::passes::collect_intra_doc_links looking for enum variant f64::from_str
DEBUG rustdoc::passes::collect_intra_doc_links f64::from_str resolved to Err(()) in namespace TypeNS
DEBUG rustdoc::passes::collect_intra_doc_links resolved primitives F64
DEBUG rustdoc::passes::collect_intra_doc_links resolving f64::from_str as a macro in the module DefId(0:3 ~ cayenne[f5be]::v)
DEBUG rustdoc::passes::collect_intra_doc_links f64 resolved to Ok(Primitive(F64)) in namespace TypeNS
DEBUG rustdoc::passes::collect_intra_doc_links found partial_res=Primitive(F64)
error: unresolved link to `f64::from_str`
--> src/v.rs:3:27
|
3 | /// Uses the rules from [`f64::from_str()`].
| ^^^^^^^^^^^^^^^ the builtin type `f64` has no function named `from_str`
|
= note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
thread 'rustc' panicked at 'aborting due to `-Z treat-err-as-bug=1`', compiler/rustc_errors/src/lib.rs:1182:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: internal compiler error: unexpected panic
error: Unrecognized option: 'crate-version'
error: could not document `cayenne`
Caused by:
process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name cayenne src/lib.rs -o /home/classabbyamp/projects/cayenne/target/doc --error-format=json --json=diagnostic-rendered-ansi -Dwarnings -Ztreat-err-as-bug -L dependency=/home/classabbyamp/projects/cayenne/target/debug/deps --crate-version 0.1.0` (exit status: 1)
Metadata
Metadata
Assignees
Labels
Area: Intra-doc links, the ability to link to items in docs by nameCategory: This is a bug.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Relevant to the rustdoc team, which will review and decide on the PR/issue.