Skip to content

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

Closed
@haata

Description

@haata
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())),
         }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions