Skip to content

no_std project broken after 9/15 nightly #54589

Closed
@Visic

Description

@Visic

The code below compiles using the 9/15 nightly (nightly-2018-09-15-i686-pc-windows-msvc), but fails to compile since then.

----Code---------------------------------------------------------------------

#![no_std]
#![feature(lang_items, alloc_system, alloc_error_handler)]

extern crate alloc_system;

use alloc_system::System;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::panic::PanicInfo;

#[global_allocator] static GLOBAL: System = System;
#[alloc_error_handler] #[no_mangle] pub extern "C" fn alloc_error(_: core::alloc::Layout) -> ! { loop {} }
#[panic_handler] #[no_mangle] pub extern "C" fn panic(_info: &PanicInfo) -> ! { loop {} }
#[lang = "eh_personality"] #[no_mangle] pub extern "C" fn eh_personality() {}

#[no_mangle]
pub fn hello_world_in_rust() -> i32 {
    let _: Box<[u8]> = Box::new([0; 10]);
    let _: [i32; 3] = [0,1,2];
    let _: Vec<i32> = Vec::new();
    100
}

----Cargo.toml--------------------------------------------------------------------

[package]
edition = '2018'
name = "test_lib"
version = "0.1.0"
authors = (removed)

[lib]
name = "test_lib"
path = "src/lib.rs"
crate-type = ["staticlib"]

[dependencies]

----Build Output---------------------------------------------------------------------

PS D:\Dev\MyProjects\Rust\test_lib> cargo build --release
Compiling test_lib v0.1.0 (D:\Dev\MyProjects\Rust\test_lib)
error[E0433]: failed to resolve. Could not find alloc in {{root}}
--> src/lib.rs:7:5
|
7 | use alloc::boxed::Box;
| ^^^^^ Could not find alloc in {{root}}

error[E0433]: failed to resolve. Could not find alloc in {{root}}
--> src/lib.rs:8:5
|
8 | use alloc::vec::Vec;
| ^^^^^ Could not find alloc in {{root}}

error[E0432]: unresolved import alloc_system
--> src/lib.rs:6:5
|
6 | use alloc_system::System;
| ^^^^^^^^^^^^ Did you mean self::alloc_system?

error[E0433]: failed to resolve. Use of undeclared type or module Box
--> src/lib.rs:18:24
|
18 | let _: Box<[u8]> = Box::new([0; 10]);
| ^^^ Use of undeclared type or module Box

error[E0433]: failed to resolve. Use of undeclared type or module Vec
--> src/lib.rs:20:23
|
20 | let _: Vec = Vec::new();
| ^^^ Use of undeclared type or module Vec

error[E0412]: cannot find type Box in this scope
--> src/lib.rs:18:12
|
18 | let _: Box<[u8]> = Box::new([0; 10]);
| ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
|
6 | use std::boxed::Box;
|
6 | use std::prelude::v1::Box;
|

error[E0412]: cannot find type Vec in this scope
--> src/lib.rs:20:12
|
20 | let _: Vec = Vec::new();
| ^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
|
6 | use std::prelude::v1::Vec;
|
6 | use std::vec::Vec;
|

warning: unused import: alloc::boxed::Box
--> src/lib.rs:7:5
|
7 | use alloc::boxed::Box;
| ^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: unused import: alloc::vec::Vec
--> src/lib.rs:8:5
|
8 | use alloc::vec::Vec;
| ^^^^^^^^^^^^^^^

error[E0152]: duplicate lang item found: oom.
--> src/lib.rs:12:37
|
12 | #[alloc_error_handler] #[no_mangle] pub extern "C" fn alloc_error(_: core::alloc::Layout) -> ! { loop {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: first defined in crate std.

error[E0152]: duplicate lang item found: panic_impl.
--> src/lib.rs:13:31
|
13 | #[panic_handler] #[no_mangle] pub extern "C" fn panic(_info: &PanicInfo) -> ! { loop {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: first defined in crate std.

error[E0152]: duplicate lang item found: eh_personality.
--> src/lib.rs:14:41
|
14 | #[lang = "eh_personality"] #[no_mangle] pub extern "C" fn eh_personality() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: first defined in crate panic_unwind.

error: aborting due to 10 previous errors

Some errors occurred: E0152, E0412, E0432, E0433.
For more information about an error, try rustc --explain E0152.
error: Could not compile test_lib.

To learn more, run the command again with --verbose.

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