Skip to content

Document path stability of f64::abs in no std crates #139066

Open
@lopopolo

Description

@lopopolo
Contributor

I tried this code:

#![no_std]

pub fn xxx() {
    f64::abs(1.0);
}

In Rust older than 1.84.

I expected to see this happen: successful compilation since f64::abs is documented to be available since Rust 1.0.

Instead, this happened: compilation failure since f64::abs in no std programs wasn't stabilized until Rust 1.84. This isn't documented anywhere and I had to go issue diving on GitHub.

@RalfJung said the keywords here are documenting path stability vs item stability.

#131304 (comment)

Opening this issue to explore how to document the limited availability of items in no std programs.

In the absence of compiler infrastructure for this, free form text in the prose of the doc comment for the f64 primitive or its abs method would have solved this for me. Maybe in a # Caveats section?

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 28, 2025
changed the title [-]Document item stability of `f64::abs` in no std crates[/-] [+]Document path stability of `f64::abs` in no std crates[/+] on Mar 28, 2025
RalfJung

RalfJung commented on Mar 28, 2025

@RalfJung
Member

Cc @rust-lang/rustdoc @rust-lang/libs-api

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
A-stabilityArea: `#[stable]`, `#[unstable]` etc.
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
C-bugCategory: This is a bug.
on Mar 28, 2025
GuillaumeGomez

GuillaumeGomez commented on Mar 31, 2025

@GuillaumeGomez
Member

This is indeed pretty bad. I'll try to take a look whenever I have time if no one did until then.

DJMcNab

DJMcNab commented on May 20, 2025

@DJMcNab
Contributor

Linking to #137578 and #50145, which are both are recent cases where this kind of issue can occur.

I talked about this with @joshtriplett at the RustWeek unconference - in Linebender we have run into similar issues.
Josh also suggested that the other way around would be helpful. That is, somehow displaying in std::f64::abs that it is also available in core. This would be a natural extension of this issue, as this would want to use the same MSRV-awareness infrastructure in that display.
(Ideally, something like Clippy would also suggest that you use are using an item from std which is also in core, which it can only correctly do if it knows when it moved to core).

tgross35

tgross35 commented on May 28, 2025

@tgross35
Contributor

A note in the docs is probably sufficient to cover this case until we get something first class (if we decide we still need that), since the circumstances here are relatively uncommon. E.g: This method is available in core only since 1.x.0. Before then, it was only usable in std.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-stabilityArea: `#[stable]`, `#[unstable]` etc.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @RalfJung@lopopolo@GuillaumeGomez@tgross35@DJMcNab

        Issue actions

          Document path stability of `f64::abs` in no std crates · Issue #139066 · rust-lang/rust