Skip to content

Commit

Permalink
Update the error message for a missing global allocator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SimonSapin committed Jun 19, 2018
1 parent a9a0f4c commit d2fe6c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,10 @@ impl<'a> CrateLoader<'a> {
},
None => {
if !attr::contains_name(&krate.attrs, "default_lib_allocator") {
self.sess.err("no #[default_lib_allocator] found but one is \
required; is libstd not linked?");
self.sess.err("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.");
return;
}
self.sess.allocator_kind.set(Some(AllocatorKind::DefaultLib));
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/missing-allocator.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: no #[default_lib_allocator] found but one is required; is libstd not linked?
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

0 comments on commit d2fe6c4

Please sign in to comment.