Repository navigation
Update the error message for a missing global allocator - #51639
Conversation
Don’t mention `#[default_lib_allocator]` (which is an implementation detail irrelevant to most users) and instead suggest using `#[global_allocator]`, which is often the correct fix.
|
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
|
@bors r+ |
|
📌 Commit d2fe6c4 has been approved by |
| @@ -0,0 +1,4 @@ | |||
| error: no global memory allocator found but one is required; link to std or add #[global_allocator] to a static item that implements the GlobalAlloc trait. | |||
|
|
|||
| error: aborting due to previous error | |||
There was a problem hiding this comment.
Nitpick
I'm not really happy with this output. I would prefer something closer to the following, but I'm not sure we can at that stage:
error: no global memory allocator found but one is required
note: link to `std` or add `#[global_allocator]` to a static item that implements the `GlobalAlloc` trait
note: for more information visit <BOOK 2.0 LINK>
error: aborting due to previous error
There was a problem hiding this comment.
How do I output a note from this code?
As to including an URL, the closest we have at the moment is https://doc.rust-lang.org/nightly/std/alloc/index.html#the-global_allocator-attribute but as you can see it includes /nightly, since this change has not reached stable yet.
There was a problem hiding this comment.
I have too look at this, but honestly I would not block on the perfect output precisely because it's nightly. Let's just remember to revise this before stabilizing.
Update the error message for a missing global allocator Don’t mention `#[default_lib_allocator]` (which is an implementation detail irrelevant to most users) and instead suggest using `#[global_allocator]`, which is often the correct fix.
|
☀️ Test successful - status-appveyor, status-travis |
Don’t mention
#[default_lib_allocator](which is an implementation detail irrelevant to most users) and instead suggest using#[global_allocator], which is often the correct fix.