Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling #![no_std] crates with --test gives unhelpful error message #18843

Closed
veddan opened this issue Nov 10, 2014 · 1 comment
Closed

Compiling #![no_std] crates with --test gives unhelpful error message #18843

veddan opened this issue Nov 10, 2014 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR)

Comments

@veddan
Copy link
Contributor

veddan commented Nov 10, 2014

test-error.rs:

#![no_std]

Compiling:

$> rustc --test test-error.rs 
test-error.rs:1:1: 1:4 error: unresolved import `std::slice::AsSlice`. Maybe a missing `extern crate std`?
test-error.rs:1 #![no_std]
                ^~~
error: aborting due to previous error

This isn't very helpful. Changing the file to

#![no_std]
extern crate core;
mod std { mod slice { pub use core::slice::AsSlice; } }

instead gives the error message

test-error.rs:1:1: 1:1 error: failed to resolve. Could not find `os` in `std`.
test-error.rs:1 #![no_std]
                ^
test-error.rs:1:1: 1:1 error: unresolved name `std::os::args`.
test-error.rs:1 #![no_std]
                ^
error: aborting due to 2 previous errors

The error always refers to the first line of the file, so if you have feature gates before #![no_std], the error will refer to them.

@steveklabnik steveklabnik added A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) labels Jan 27, 2015
@steveklabnik
Copy link
Member

This has been resolved: an empty crate with just ![no_std] compiles fine with --test.

lnicola pushed a commit to lnicola/rust that referenced this issue Jan 7, 2025
fix: Handle newstyle `rustc_intrinsic` safety correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR)
Projects
None yet
Development

No branches or pull requests

2 participants