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

Slice syntax and for loops don't compile in a no_std context #21827

Closed
sfackler opened this issue Feb 1, 2015 · 1 comment
Closed

Slice syntax and for loops don't compile in a no_std context #21827

sfackler opened this issue Feb 1, 2015 · 1 comment
Assignees
Labels
A-syntaxext Area: Syntax extensions

Comments

@sfackler
Copy link
Member

sfackler commented Feb 1, 2015

#![no_std]

extern crate core;

fn foo() {
    [0i32][]
}
test.rs:6:5: 6:8 error: failed to resolve. Maybe a missing `extern crate std`?
test.rs:6     [0i32][]
              ^~~
test.rs:6:5: 6:13 error: `std::ops::RangeFull` does not name a structure
test.rs:6     [0i32][]
              ^~~~~~~~
error: aborting due to 2 previous errors
#![no_std]

extern crate core;

fn foo() {
    let i: &[i32] = &[0i32];
    for _ in i {}
}
test.rs:7:5: 7:8 error: failed to resolve. Maybe a missing `extern crate std`?
test.rs:7     for _ in i {}
              ^~~
test.rs:7:5: 8:2 error: unresolved name `std::iter::IntoIterator::into_iter`
test.rs:7     for _ in i {}
test.rs:8 }
test.rs:7:5: 7:8 error: failed to resolve. Maybe a missing `extern crate std`?
test.rs:7     for _ in i {}
              ^~~
test.rs:7:5: 8:2 error: unresolved name `std::iter::Iterator::next`
test.rs:7     for _ in i {}
test.rs:8 }
test.rs:7:9: 7:12 error: failed to resolve. Maybe a missing `extern crate std`?
test.rs:7     for _ in i {}
                  ^~~
test.rs:7:9: 7:10 error: unresolved enum variant, struct or const `Some`
test.rs:7     for _ in i {}
                  ^
test.rs:7:5: 7:8 error: failed to resolve. Maybe a missing `extern crate std`?
test.rs:7     for _ in i {}
              ^~~
test.rs:7:5: 8:2 error: unresolved enum variant, struct or const `None`
test.rs:7     for _ in i {}
test.rs:8 }
error: aborting due to 8 previous errors

You can work around this by adding a std module to your crate root that reexports things properly, but that's not a great way to get basic language features to work.

@kmcallister kmcallister self-assigned this Feb 1, 2015
@kmcallister kmcallister added the A-syntaxext Area: Syntax extensions label Feb 1, 2015
kmcallister added a commit that referenced this issue Feb 3, 2015
…] crate

Fixes #16803.
Fixes #14342.
Fixes half of #21827 -- slice syntax is still broken.
mvdnes added a commit to mvdnes/element76 that referenced this issue Feb 5, 2015
Add hack that can be removed when rust-lang/rust#21827 is solved.
kmcallister added a commit to kmcallister/rust that referenced this issue Feb 5, 2015
kmcallister added a commit to kmcallister/rust that referenced this issue Feb 7, 2015
@kmcallister
Copy link
Contributor

Created #22102 for the slice issue. for loops work after #21988:

#![feature(no_std)]
#![no_std]

extern crate "std" as other;
extern crate core;

fn main() {
    let i: &[i32] = &[0i32];
    for _ in i {}
}

mvdnes added a commit to mvdnes/element76 that referenced this issue Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

2 participants