Skip to content
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

Incorrect Result reference in core::error. #134169

Closed
bjoernager opened this issue Dec 11, 2024 · 4 comments · Fixed by #134255
Closed

Incorrect Result reference in core::error. #134169

bjoernager opened this issue Dec 11, 2024 · 4 comments · Fixed by #134255
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@bjoernager
Copy link
Contributor

Location

core::error

Summary

The docs for core::error contain the following passage:

The following are the primary interfaces of the error system and the responsibilities they cover:

  • Result (Propagating, Reacting)
  • The Error trait (Reporting)

...

The entry for Result links to the docs for core::fmt::Result even though it should actually point to core::result::Result. The docs for std::error, however, do correctly link to std::result::Result in this case, despite using the same markup.

This issue is present on stable, beta, and nightly branches.

@bjoernager bjoernager added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Dec 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 11, 2024
@bjoernager
Copy link
Contributor Author

bjoernager commented Dec 11, 2024

My first though was to simply change the link in /library/core/src/error.md from [`Result`] to [`Result`](crate::result::Result). Would this suffice?

@clubby789
Copy link
Contributor

If that fixes the issue, please feel free to submit a PR

@jieyouxu jieyouxu added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 11, 2024
@clubby789
Copy link
Contributor

The specific cause here, by the way, is that core/src/error.rs begins:

#![doc = include_str!("error.md")]
#![stable(feature = "error_in_core", since = "1.81.0")]

use crate::any::TypeId;
use crate::fmt::{Debug, Display, Formatter, Result};

So [Result] is resolved as the imported fmt::Result. The version in std does not import this, and uses the regular Result from the prelude

@bjoernager
Copy link
Contributor Author

bjoernager commented Dec 13, 2024

Yes, I suspected that was the case. It appears I somehow completely missed that use statement.

@bors bors closed this as completed in 0b5003e Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 14, 2024
Rollup merge of rust-lang#134255 - bjoernager:master, r=Noratrieb

Update includes in `/library/core/src/error.rs`.

This PR removes the `crate::fmt::Result` include in `/library/core/src/error.rs`.

The main issue with this `use` statement is that it shadows the `Result` type from the prelude (i.e. `crate::result::Result`). This indirectly makes all docs references to `Result` in this module point to the wrong type (but only in `core::error` - not `std::error`, wherein this include isn't present to begin with).

Fixes: rust-lang#134169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants