-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.