Skip to content

Missing crates for macro-expanded code produces confusion #14780

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

Closed
kmcallister opened this issue Jun 9, 2014 · 2 comments
Closed

Missing crates for macro-expanded code produces confusion #14780

kmcallister opened this issue Jun 9, 2014 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@kmcallister
Copy link
Contributor

fn main() {
    format!("{:?}", ());
}
foo.rs:2:21: 3:1 error: unresolved import. maybe a missing `extern crate debug`?
foo.rs:2     format!("{:?}", ());
foo.rs:3 }
note: in expansion of format_args!
<std macros>:3:9: 3:51 note: expansion site
<std macros>:1:1: 5:2 note: in expansion of format!
foo.rs:2:5: 2:25 note: expansion site
foo.rs:2:21: 2:23 error: use of undeclared module `::debug::fmt`
foo.rs:2     format!("{:?}", ());
                             ^~
note: in expansion of format_args!
<std macros>:3:9: 3:51 note: expansion site
<std macros>:1:1: 5:2 note: in expansion of format!
foo.rs:2:5: 2:25 note: expansion site
foo.rs:2:21: 2:23 error: unresolved name `debug::fmt::secret_poly`.
foo.rs:2     format!("{:?}", ());
                             ^~
note: in expansion of format_args!
<std macros>:3:9: 3:51 note: expansion site
<std macros>:1:1: 5:2 note: in expansion of format!
foo.rs:2:5: 2:25 note: expansion site
error: aborting due to 3 previous errors

This is a lot of noise which makes it hard to understand the root problem. In a sense, this is a macro hygeine issue; the format! macro wants to "close over" a reference to the crate debug. Macros injecting crate dependencies would probably be bad, but we could allow them (at least procedural syntax extensions) to specify a list of crate dependencies, so that error messages can be more informative.

@reem
Copy link
Contributor

reem commented Jun 10, 2014

I ran into this issue a few days ago. This is extremely annoying because it makes it very hard to package macros as modules because your users need to extern crate not only your library but also all of that libraries dependencies.

@huonw huonw added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-diagnostics Area: Messages for errors, warnings, and lints and removed A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) labels Sep 24, 2014
@alexcrichton
Copy link
Member

I think our diagnostics and story here has improved greatly over time, so I'm going to close this as basically fixed, and new follow-up bugs can certainly be filed if new aspects crop up!

bors pushed a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
Fixes rust-lang#14780 . This commit introduces guards for checking if the client supports ResourceOperations for operations to use them.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
flip1995 added a commit to flip1995/rust that referenced this issue May 15, 2025
This PR update the sample code in the development guide because `ident`
was moved to the struct `Fn` in
rust-lang#138740 .

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

4 participants