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

cannot find type EpisodeMapping in this scope #46

Closed
lucasholder opened this issue May 9, 2020 · 3 comments
Closed

cannot find type EpisodeMapping in this scope #46

lucasholder opened this issue May 9, 2020 · 3 comments

Comments

@lucasholder
Copy link

lucasholder commented May 9, 2020

Something weird happened today. After a clean build, my diesel-derive-enum generated EpisodeMapping suddenly stopped working and I can't figure out why.

table! {
    use diesel::sql_types::*;
    use crate::db::enums::episode::*;

    /// Representation of the `heroes` table.
    ///
    /// (Automatically generated by Diesel.)
    heroes (id) {
        /// The `id` column of the `heroes` table.
        ///
        /// Its SQL type is `Int4`.
        ///
        /// (Automatically generated by Diesel.)
        id -> Int4,
        /// The `name` column of the `heroes` table.
        ///
        /// Its SQL type is `Varchar`.
        ///
        /// (Automatically generated by Diesel.)
        name -> Varchar,
        /// The `appears_in` column of the `heroes` table.
        ///
        /// Its SQL type is `Array<EpisodeMapping>`.
        ///
        /// (Automatically generated by Diesel.)
        appears_in -> Array<EpisodeMapping>,
        /// The `home_planet` column of the `heroes` table.
        ///
        /// Its SQL type is `Varchar`.
        ///
        /// (Automatically generated by Diesel.)
        home_planet -> Varchar,
    }
}
error[E0412]: cannot find type `EpisodeMapping` in this scope
   --> src/db/schema.rs:335:29
    |
335 |         appears_in -> Array<EpisodeMapping>,
    |                             ^^^^^^^^^^^^^^ not found in this scope
    |
    = note: possible candidate is found in another module, you can import it into scope:
            crate::db::enums::episode::db_enum_impl_Episode::EpisodeMapping

error: aborting due to previous error
#[derive(Debug, PartialEq, DbEnum, Clone, GraphQLEnum)]
#[PgType = "episode_enum"]
pub enum Episode {
    NewHope,
    Empire,
    Jedi,
}

For some reason the compiler is finding crate::db::enums::episode::db_enum_impl_Episode::EpisodeMapping but not crate::db::enums::episode::EpisodeMapping. I'm not sure what happened, I don't think I touched those modules at all, I just did a clean build. Any idea why this is happening?

@lucasholder
Copy link
Author

This fixed the problem:

        /// (Automatically generated by Diesel.)
        appears_in -> Array<crate::db::enums::episode::EpisodeMapping>,

I noticed I have a #![feature(proc_macro_hygiene, decl_macro)] in main.rs file, maybe related? But it's been there forever, wWeird that this error seemed to appear suddenly.

@adwhit
Copy link
Owner

adwhit commented May 9, 2020

Curious. I never really got my head around the proc macro hygine. This crate has apparently exposed breakages in proc macros before (e.g. rust-lang/rust#54783) so am inclined to blame rustc here. But would be interested to know the reasons.

@adwhit
Copy link
Owner

adwhit commented Jan 12, 2022

Am assuming this is no longer an issue

@adwhit adwhit closed this as completed Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants