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

Misleading "not found in this scope" error #923

Closed
emk opened this issue May 10, 2017 · 2 comments
Closed

Misleading "not found in this scope" error #923

emk opened this issue May 10, 2017 · 2 comments
Labels

Comments

@emk
Copy link

emk commented May 10, 2017

I'm loving the new serde!

This is a bit of an unfortunate error message, and it's probably rustc's fault, but I thought I would report it:

/// A parsed version of our configuration file.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Config {
    /// Configuration for each notifier.
    notifiers: HashMap<String, NotifierConfig>,
}

# No definition of NotifierConfig.

Here, the error[E0412]: is correct, but the brightly colored "not found in this scope" below it points to the wrong thing.

error[E0412]: cannot find type `NotifierConfig` in this scope
 --> src/config.rs:6:35
  |
6 | #[derive(Clone, Debug, Serialize, Deserialize)]
  |                                   ^^^^^^^^^^^ not found in this scope

The fix, of course, is to implement NotifierConfig. I know you can't do much about this error, but I thought you might like to know that there was a minor ergonomic issue.

@dtolnay
Copy link
Member

dtolnay commented May 10, 2017

Thanks! This is a limitation of Macros 1.1 and will be fixed by rust-lang/rust#40939.

@ZelphirKaltstahl
Copy link

This can also happen, when one forgets to add the following in the main module of the application:

// In order to use the Serialize and Deserialize macros in the model,
// we need to declare in the main module, that we are using them.
#[macro_use]
extern crate serde_derive;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants