Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Issue when defining a panic function with #![no_std] #904

@GRVYDEV

Description

@GRVYDEV

Hello,

I am currently trying to write an operating system in Rust. Obviously I can't link to the std lib and I need to write my own panic function. As of right now the plugin is giving me an error saying that it found a duplicate panic_impl item however it compiles fine. Is there a way you could check for #![no_std] and prevent this error from showing up? Or is there any way I can configure the plugin to ignore this error?

Error:
found duplicate lang item `panic_impl` the lang item is first defined in crate `std` (which `test` depends on) first definition in `std` loaded from /home/grvy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-93cbfed54dd1bac8.rlib second definition in the local crate (`grvy_os`)rustc(E0152)

Code:

#![no_std] // don't link to the Rust std library
#![no_main] // disable all Rust-level entry points

use core::panic::PanicInfo;

#[no_mangle] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
    // this function is the entry point, since the linker looks for a function 
    // named '_start' by default
    loop {}
}

// this function is called on panic
#[panic_handler] 
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}```

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