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

hex_color! macro uses color_hex crate, but it doesn't seem to import it correctly #2644

Closed
Hpmason opened this issue Jan 29, 2023 · 1 comment · Fixed by #4372
Closed

hex_color! macro uses color_hex crate, but it doesn't seem to import it correctly #2644

Hpmason opened this issue Jan 29, 2023 · 1 comment · Fixed by #4372

Comments

@Hpmason
Copy link

Hpmason commented Jan 29, 2023

Trying to use the hex_color! macro gives the following error:

error[E0433]: failed to resolve: use of undeclared crate or module `color_hex`
  --> src\main.rs:29:61
   |
29 |         let frame = egui::containers::Frame::default().fill(hex_color!("#ffffff"));
   |                                                             ^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `color_hex`
   |
   = note: this error originates in the macro `hex_color` (in Nightly builds, run with -Z macro-backtrace for more info)     

For more information about this error, try `rustc --explain E0433`.

From what I can tell, the macro calls another macro from the color_hex crate, but there's no guarantee the crate is in scope. Maybe in version 0.19, the color_hex crate was reexported so it was always in scope?

macro_rules! hex_color {
($s:literal) => {{
let array = color_hex::color_from_hex!($s);

@emilk
Copy link
Owner

emilk commented Feb 8, 2023

Ah, good catch. I guess ecolor would need to re-export color_hex, and the macro would need to call #crate::color_hex::color_from_hex. Maybe? PRs welcome!

emilk pushed a commit that referenced this issue Apr 21, 2024
#4372)

The `hex_color!` macro currently makes an unqualified reference to the
`color_hex` crate, which users may not have in their `Cargo.toml`. This
PR re-exports `color_hex` from the root of `ecolor` and changes the
macro to use the re-exported path.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes #2644
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
emilk#4372)

The `hex_color!` macro currently makes an unqualified reference to the
`color_hex` crate, which users may not have in their `Cargo.toml`. This
PR re-exports `color_hex` from the root of `ecolor` and changes the
macro to use the re-exported path.

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

* Closes emilk#2644
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.

2 participants