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

Use root prefix to access crates #14

Closed
mamins1376 opened this issue Aug 1, 2021 · 0 comments · Fixed by #26
Closed

Use root prefix to access crates #14

mamins1376 opened this issue Aug 1, 2021 · 0 comments · Fixed by #26

Comments

@mamins1376
Copy link

I'm working on a project which defines a core module for itself in the codebase and does not use the core crate directly. The module is frequently used, so it's imported alongside other common stuff everywhere through use crate::*.

However, when I tried using serde_repr I hit an strange error:

error[E0433]: failed to resolve: could not find `result` in `core`
 --> src/lib.rs:7:26
  |
7 | #[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug)]
  |                          ^^^^^^^^^^^^^^^^ could not find `result` in `core`
  |
  = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
  |
1 | use core::fmt::Result;
  |
1 | use core::result::Result;
  |
1 | use serde::__private::Result;
  |
1 | use serde::__private::fmt::Result;
  |
    and 4 other candidates

After taking a look in the source code it turns out no :: prefix is being used (e.g. ::core::result::Result instead of core::result::Result), which seems to be the cause.

To reproduce:

use serde_repr::{Serialize_repr, Deserialize_repr};

mod core {}

#[derive(Serialize_repr, Deserialize_repr, PartialEq, Eq, Debug)]
#[repr(u8)]
enum E { V = 0 }

A temporary fix I currently use in the modules I use serde_repr:

use ::core;

Which is less than ideal.

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

Successfully merging a pull request may close this issue.

1 participant