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.
This commit is contained in:
Simon Sapin 2018-06-19 20:10:56 +02:00
parent a9a0f4cdd1
commit d2fe6c4527
2 changed files with 5 additions and 3 deletions

View file

@ -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));

View file

@ -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