Trying to complete the small Rust app

on the Rustlang site. It works in the terminal, but cant get it working in VSC. any ideas? I have tried different things.

It works in the terminal:

The same code doesn’t work in VSC:

Does your Cargo.toml have edition = "2018" in it?

Your VSC shows an error that is specific to 2015 edition of Rust, so it’s either an old version, or configured to behave like the old version.

[package]
name = “ferris_says”
version = “0.1.0”
authors = [“Paul”]
edition = “2018”

[dependencies]
ferris-says = “0.1”

I have 1.35.0

Is there anything I can do ?

How are you compiling in VSC, with the default task generated by the plugin?

I have the RLS extension, should I look at its settings and change something ?

Can you copy/paste your task.json? I think it’s calling rustc directly and with the 2015 edition, this is not something you want in general.

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
{
“type”: “cargo”,
“subcommand”: “build”,
“problemMatcher”: [
“$rustc”
],
“group”: {
“kind”: “build”,
“isDefault”: true
}
}
]
}

As a side note, you can format your code to look like so:

fn hello_world() {
    println!("Howdy!");
}

If you surround your code in code fences:

```rust
fn hello_world() {
    println!("Howdy!");
}
```

Or for toml:

```toml
foo = "bar"
```

Looks like I have the most current version - 2019

I have the same task and it works for me so it’s not it. The big difference is that I open the project folder with VSC and not the parent so ferris_says and not Rust but in theory the plugin should work with workspace, I don’t know.

As a previous vscode user, I’d just recommend using the terminal for everything as though I’ve found it rather easy to accidentally break the vscode config. The only real time I ever needed to have a config is when I was trying to debug using lldb, but hey, println!() works just fine :grin:

Could having these two extensions be causing a problem ? which one should I keep ?

The RLS extension is the official/most up-to-date one. I’d recommend just using that one.

Oh, I see. Your VSCode compiles the lone file directly, rather than build it properly via Cargo. The terminal shows rustc main.rs - that’s wrong, and it won’t work. Whatever tool/extension is issuing that command, is useless, because it’s unaware of your project configuration, and won’t see any dependencies.

I’m using the official Rust (rls) extension. do I change something in it’s settings and /or something in VSC like task.json ?

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
{
“type”: “cargo”,
“subcommand”: “build”,
“problemMatcher”: [
“$rustc”
],
“group”: {
“kind”: “build”,
“isDefault”: true
}
}
]
}