Skip to content

Compiling --test with #[no_std] produces error span at first line #21021

@nagisa

Description

@nagisa
#![crate_name="odd_span"]
#![no_std]

#[test]
fn t(){
}

will result in

test.rs:1:1: 1:4 error: unresolved import `std::slice::AsSlice`. Maybe a missing `extern crate std`?
test.rs:1 #![crate_name="odd_span"]
          ^~~
error: aborting due to previous error

Note the odd span and error location.

Since --test depends on libstd, maybe a following error message would be better?

test.rs:2:1: 1:4 error: Test harness binaries require std crate. Maybe a missing `extern crate std`?
test.rs:2 #![no_std]
          ^~~~~~~~~~
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions