Code Monkey home page Code Monkey logo

Comments (9)

llogiq avatar llogiq commented on August 23, 2024

I think it may not be too problematic and in fact makes a lot of sense: We should watch out for macro expansion and (perhaps optionally) if the macro is external to the current crate, omit the warning.

from rust-clippy.

Manishearth avatar Manishearth commented on August 23, 2024

That sounds good.

We can pick up the syntaxcontext of idents and stuff I think. If an ident is not doc.rust-lang.org/syntax/ast/constant.EMPTY_CTXT.html, we ignore it. Not sure though.

from rust-clippy.

llogiq avatar llogiq commented on August 23, 2024

We may want to look up if the macro is defined in the current crate, and issue a warning in that case anyway.

from rust-clippy.

Manishearth avatar Manishearth commented on August 23, 2024

I'm not sure if that info is kept around post-expansion in an easy-to-access manner.

The spans might help here.

from rust-clippy.

llogiq avatar llogiq commented on August 23, 2024

I'm curious how the compiler does it when reporting errors – it always tells me which macro was expanded.

Looking into the code, the code map has a function we may be able to use. I'll push an untested prototype into a 'macro_expn' branch. However, I'm not sure if we should include regex! as a test dependency or if there is another alternative.

from rust-clippy.

llogiq avatar llogiq commented on August 23, 2024

@killercup: Are you ok with me reusing your line of code as a test case? I may be able to reduce it, but it's the best starting point we have.

from rust-clippy.

killercup avatar killercup commented on August 23, 2024

@llogiq Sure, you can reproduce about a gazillion lines of this when you compile trpl-ebook with cargo run --features "dev" --release :)

from rust-clippy.

llogiq avatar llogiq commented on August 23, 2024

In PR #68 I have added a better in_macro check that we should be able to reuse for other lints (btw. we should even be able to create a basic check_expr(…) to closure adapter that will only trigger when not within an external macro expansion.

Note that this enables you to write e.g. let mut zero = &mut &mut "zero"; within a macro invocation without the lint triggering, but I'm ok with paying that price for getting rid of the false positives.

from rust-clippy.

llogiq avatar llogiq commented on August 23, 2024

The latest merged PR #82 makes this issue go away (as well as similar issues in other lints)

from rust-clippy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.