-1

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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
kula
  • 345
  • 1
  • 8

1 Answers1

2

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

Try again with a .rs file extension! :)

Kevin Cantu
  • 807
  • 7
  • 17