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

alloc::System docs contradict "the default global allocator is unspecified" #125870

Closed
QuineDot opened this issue Jun 1, 2024 · 0 comments · Fixed by #126266
Closed

alloc::System docs contradict "the default global allocator is unspecified" #125870

QuineDot opened this issue Jun 1, 2024 · 0 comments · Fixed by #126266
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@QuineDot
Copy link

QuineDot commented Jun 1, 2024

Location

https://doc.rust-lang.org/std/alloc/struct.System.html

https://doc.rust-lang.org/std/alloc/index.html

Summary

System says:

This type implements the GlobalAlloc trait and Rust programs by default work as if they had this definition:

use std::alloc::System;

#[global_allocator]
static A: System = System;

fn main() {
    let a = Box::new(4); // Allocates from the system allocator.
    println!("{a}");
}

But std::alloc says

Currently the default global allocator is unspecified. Libraries, however, like cdylibs and staticlibs are guaranteed to use the System by default.

(And the example was not library-specific.)

@QuineDot QuineDot added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Jun 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 1, 2024
@jieyouxu jieyouxu added T-libs-api Relevant to the library API 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 Jun 3, 2024
tbu- added a commit to tbu-/rust that referenced this issue Jun 11, 2024
`std::alloc` said that the default allocator is unspecified for all
crrate types except `cdylib` and `staticlib`. Adjust
`std::alloc::System` documentation to say the same.

Fixes rust-lang#125870.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 14, 2024
…r=jhpratt

Unify guarantees about the default allocator

`std::alloc` said that the default allocator is unspecified for all crrate types except `cdylib` and `staticlib`. Adjust `std::alloc::System` documentation to say the same.

Fixes rust-lang#125870.
@bors bors closed this as completed in bb8eb44 Jun 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 14, 2024
Rollup merge of rust-lang#126266 - tbu-:pr_doc_alloc_default_system, r=jhpratt

Unify guarantees about the default allocator

`std::alloc` said that the default allocator is unspecified for all crrate types except `cdylib` and `staticlib`. Adjust `std::alloc::System` documentation to say the same.

Fixes rust-lang#125870.
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-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants