Www.rust-lang.org: Example code does not compile.

Created on 14 Dec 2018  Â·  6Comments  Â·  Source: rust-lang/www.rust-lang.org

Technical Bug Report

Your Environment

| Software | Version(s) |
| Rust | 1.30.1 |
| Form Factor | Desktop |
| Browser Type | Chrome |
| Browser Version | 70.0.3538.110 |

Is this an issue with Rust, CSS, or HTML (or a combination)?

I'm going to say HTML.

Expected Behavior

If i correctly followed (or copy/pasted) the code example under the heading "A Small Rust Application" then i should be able to compile and run the sample program.

Current Behavior

Compiling the sample code results in:

error[E0432]: unresolved import `ferris_says`
 --> src/main.rs:1:5
  |
1 | use ferris_says::say; // from the previous step
  |     ^^^^^^^^^^^ Maybe a missing `extern crate ferris_says;`?

error: aborting due to previous error

Step to Reproduce

Follow the instructions on the /learn/get-started page through the "A Small Rust Application" section.

Most helpful comment

My point was that a new user, following the instructions on the page, will be left with code that does not compile. That seems like a poor initial experience for potential rustaceans.

All 6 comments

This is due to your version of Rust. Rust 1.31 introduced a new concept called “Editions,” explained in detail here. The basic gist of it is that Rust 2018 Edition introduces a number of breaking changes that are not available in the Rust 2015 Edition. As Rust 2018 is completely opt-in, and is a new feature as of Rust 1.31, any crate created with Rust 1.30.x and earlier will default to Rust 2015. In Rust 2015, an extern crate ferris_sys is needed in main.rs; in Rust 2018, it isn’t. Rust versions are specified in Cargo.toml by inserting edition = “year” under the [package] header.

TLDR: Two ways of solving the problem:

  1. Update Rust to 1.31.x or higher, and insert edition = “2018” under the authors line of Cargo.toml
  2. Insert extern crate ferris_sys at the top of main.rs

Something concisely explaining this might be useful at the bottom of the learn/get-started page.

My point was that a new user, following the instructions on the page, will be left with code that does not compile. That seems like a poor initial experience for potential rustaceans.

That makes more sense. Sorry. And I completely agree.

My point was that a new user, following the instructions on the page, will be left with code that does not compile. That seems like a poor initial experience for potential rustaceans.

It wlll work if they are using the current stable version of Rust.

I went through the example again and it does indeed now compile and run just fine. Thanks.

  1. Cargo.toml

where is the path of Cargo.toml?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevensonmt picture stevensonmt  Â·  4Comments

ashleygwilliams picture ashleygwilliams  Â·  3Comments

Veedrac picture Veedrac  Â·  5Comments

yoshuawuyts picture yoshuawuyts  Â·  4Comments

Manishearth picture Manishearth  Â·  6Comments