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

macro expn detection in mut_mut.rs #68

Merged
merged 3 commits into from
Jun 1, 2015
Merged

macro expn detection in mut_mut.rs #68

merged 3 commits into from
Jun 1, 2015

Conversation

llogiq
Copy link
Contributor

@llogiq llogiq commented May 25, 2015

This relates to issue #67. We should add more tests, but I'm not too versed in macros, I'll have to learn them first.

  1. &mut &mut by internal macro should warn
  2. `&mut &mut' by external macro should not warn

@Manishearth
Copy link
Member

Can we refactor this so that the expn-checking bit is more generic (and can be used by other lints)?

@Manishearth
Copy link
Member

Oh wait it is, I see.

@Manishearth
Copy link
Member

I'd like to have extensive tests for this macro detection thingy btw; it seems like something that could go wrong easily.

@llogiq
Copy link
Contributor Author

llogiq commented May 25, 2015

Agreed. Are you OK with including regexp as a dev-dependency?

@Manishearth
Copy link
Member

sure :)

@llogiq
Copy link
Contributor Author

llogiq commented May 26, 2015

I removed the macro origin check because the regex! compiler plugin makes the callee something within the current code, which is pretty bad. The current version gets rid of the regex! warnings, but surprisingly still catches my mut_ptr! macro invocation.

So, this needs more tests. I'll see if I can create a copy of the mut_ptr! macro in another sub-crate and see if this still triggers mut_mut.

@llogiq
Copy link
Contributor Author

llogiq commented May 26, 2015

For what it's worth, I have another uncommitted version that filters out everything that is not a simple macro_rules! definition and leaves mut_mut to check everything else. I'm now adding another run_pass test to check with a "normal" extra-crate macro.

…latter have no working source (note: may fail in the face of compiler plugins doing whatever they like with spans), also one more run-pass test
@llogiq
Copy link
Contributor Author

llogiq commented May 26, 2015

This was surprisingly easy, as extra-crate macros either don't have source at all or (in the case of regex! and builtins) have synthesized source that does not start with macro_rules.

@Manishearth barring any pain points from your site, I think this should be ready to merge and close issue #67.

@llogiq llogiq changed the title first prototype of macro expn detection in mut_mut.rs macro expn detection in mut_mut.rs Jun 1, 2015
llogiq added a commit that referenced this pull request Jun 1, 2015
macro expn detection in mut_mut.rs
@llogiq llogiq merged commit 4c76465 into master Jun 1, 2015
@llogiq llogiq deleted the macro_expn branch June 1, 2015 05:44
toidiu pushed a commit to toidiu/rust-clippy that referenced this pull request Jan 13, 2023
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.

None yet

2 participants