Skip to content

Conversation

@jonas-schievink
Copy link
Contributor

@jonas-schievink jonas-schievink commented Nov 26, 2020

This adds 2 new diagnostics, emitted during name resolution:

  • unresolved-proc-macro, a weak warning that is emitted when a proc macro is supposed to be expanded, but was not provided by the build system. This usually means that proc macro support is turned off, but may also indicate setup issues when using rust-project.json. Being a weak warning, this should help set expectations when users see it, while not being too obstructive. We do not yet emit this for attribute macros though, just custom derives and ! macros.
  • macro-error, which is emitted when any macro (procedural or macro_rules!) fails to expand due to some error. This is an error-level diagnostic, but currently still marked as experimental, because there might be spurious errors and this hasn't been tested too well.

This does not yet emit diagnostics when expansion in item bodies fails, just for module-level macros.

Known bug: The "proc macro not found" diagnostic points at the whole item for custom derives, it should just point at the macro's name in the #[derive] list, but I haven't found an easy way to do that.

Screenshots:

screenshot-2020-11-26-19:54:14
screenshot-2020-11-26-19:55:39

@jonas-schievink
Copy link
Contributor Author

Now with more accurate diagnostics placement:

screenshot-2020-11-27-16:30:53

@matklad
Copy link
Contributor

matklad commented Nov 28, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 28, 2020

@bors bors bot merged commit 7f3ba7d into rust-lang:master Nov 28, 2020
@jonas-schievink jonas-schievink deleted the macro-shenanigans branch November 30, 2020 13:57
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 this pull request may close these issues.

2 participants