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

Lint request: Warn when importing inside a macro and not using the $ keyword. #4798

Closed
nilscript opened this issue Nov 9, 2019 · 1 comment · Fixed by #8576
Closed

Lint request: Warn when importing inside a macro and not using the $ keyword. #4798

nilscript opened this issue Nov 9, 2019 · 1 comment · Fixed by #8576
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-macros Type: Issues with macros and macro expansion

Comments

@nilscript
Copy link

I suggest adding a lint for when a programmer makes a macro, imports something into said macro and forgets $ before crate keyword. Exporting macros across crates can be a hassel, atleast for me.

@flip1995 flip1995 added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. A-lint Area: New lints T-macros Type: Issues with macros and macro expansion E-hard Call for participation: This a hard problem and requires more experience or effort to work on and removed E-medium Call for participation: Medium difficulty level problem and requires some initial experience. labels Nov 13, 2019
@flip1995
Copy link
Member

flip1995 commented Nov 13, 2019

E-hard: It's really hard (maybe impossible) to determine if use statements refer to the current crate or some dependency inside a macro definition. So doing this right is really hard.
E-medium: A basic implementation (nursery/restriction lint), which triggers on every use statement inside a macro is possible. Currently no lint exists, which checks macro definitions, though.

Macro definitions can be checked with EarlyLintPass::check_mac_def.

The challenge here is, that only a TokenStream is available, instead of AST nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-hard Call for participation: This a hard problem and requires more experience or effort to work on E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-macros Type: Issues with macros and macro expansion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants