Question

Editor's note: This question was asked before Rust 1.0 was released and the syntax, error messages, and even how crates are bundled have changed since then.

i wrote a rust example program. code is this:

use std;
import std::io;
fn main() {
    io::println("hello world");
}

i try to compile it, but the rustc compile tell me some error message .

hello.rc:4:0: 4:2 error: expected crate directive
hello.rc:4 fn main() {
       ^~

my rustc version is

macmatoMacBook-Air:test kula$ rustc -v
rustc 0.1.1 (a0f0a70 2012-03-10 00:35:02 -0800)
host: x86_64-apple-darwin

and my os is mac osx 10.7

anyone know what happened? i think my rust code has no problem on it.

Was it helpful?

Solution

The compiler is trying to be smart and behaves differently for .rs (source) and .rc (crate) files.

Try again with a .rs file extension! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top