Skip to content

Compilation failed with nightly-2021-08-20 #56

@haowqs

Description

@haowqs

rust-toolchain
nightly-2021-08-20
Cargo.toml

[dependencies]
linked_list_allocator = "0.9.1"

src/main.rs

use linked_list_allocator::LockedHeap;

#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();

pub fn init_heap() {
    let heap_start = 0;
    let heap_end = 1024;
    let heap_size = heap_end - heap_start;
    unsafe {
        ALLOCATOR.lock().init(heap_start, heap_size);
    }
}

fn main() {
    println!("Hello, world!");
}

Cargo build

$ cargo build
   Compiling scopeguard v1.1.0
   Compiling lock_api v0.4.7
   Compiling spinning_top v0.2.4
   Compiling linked_list_allocator v0.9.1
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
   --> /home/test/.cargo/registry/src/github.com-1ecc6299db9ec823/linked_list_allocator-0.9.1/src/lib.rs:224:20
    |
224 |         LockedHeap(Spinlock::new(Heap::empty()))
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0015`.
error: could not compile `linked_list_allocator` due to previous error

I lowered the lock_api in cargo.lock from 0.4.7 to 0.4.6, and the compilation was successful

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