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

error[E0015]: calls in constant functions are limited to constant functions #40

Closed
haata opened this issue Dec 13, 2020 · 1 comment · Fixed by #41
Closed

error[E0015]: calls in constant functions are limited to constant functions #40

haata opened this issue Dec 13, 2020 · 1 comment · Fixed by #41

Comments

@haata
Copy link

haata commented Dec 13, 2020

rustc 1.50.0-nightly (7efc097c4 2020-12-12)

cargo build

   Compiling alloc-cortex-m v0.4.0 (/home/jacob/git/alloc-cortex-m)

Error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
  --> src/lib.rs:29:43
   |
29 |             heap: Mutex::new(RefCell::new(Heap::empty())),
   |                                           ^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0015`.
error: could not compile `alloc-cortex-m`

This fixes the error, but I'm not sure if this follows the original intent:

diff --git a/src/lib.rs b/src/lib.rs
index 56d2305..338aa0a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -24,7 +24,7 @@ impl CortexMHeap {
     ///
     /// You must initialize this heap using the
     /// [`init`](struct.CortexMHeap.html#method.init) method before using the allocator.
-    pub const fn empty() -> CortexMHeap {
+    pub fn empty() -> CortexMHeap {
         CortexMHeap {
             heap: Mutex::new(RefCell::new(Heap::empty())),
         }
@thalesfragoso
Copy link
Member

It seems that it was caused by rust-osdev/linked-list-allocator#43, I guess we could just enable the const_mut_refs feature on the linked-list-allocator crate, since this crate is basically nightly only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants