Comments (9)
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.
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.
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.
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.
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.
@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.
@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.
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.
The latest merged PR #82 makes this issue go away (as well as similar issues in other lints)
from rust-clippy.
Related Issues (20)
- `unused_async` doesn't work if an async fn without await has attribute HOT 2
- `mut_mutex_lock` emitted on a `&mut &Mutex<T>`
- Don't pass `vec![]` to `IntoIterator` arguments when not needed HOT 5
- Respect `#[allow(clippy::inconsistent_struct_constructor)]` on adt definition. HOT 7
- Suggest using `eq_ignore_ascii_case` on non case-sensitive string comparision
- `nonminimal_bool` can take excessive time
- Clippy doesn't warn on `self` parameter for lints `pass-by-value-size-limit` and `trivial-copy-size-limit` HOT 2
- missing_transmute_annotations wrong order of Src and Dst HOT 1
- needless_borrows_for_generic_arg seems to have introduced suggestions that break compilation for 1.80.0 HOT 1
- `macro_metavars_in_unsafe` does not lint "without a statement".
- Slow and biased rounding
- unnecessary_lazy_evaluations suggests running `unsafe` code eagerly HOT 6
- redundant_locals incorrectly emitted when binding in new local scope for early drop
- Print_* family of lints fail to match on `async_trait` functions with a return value
- indexing does not trigger missing_panics_doc HOT 4
- declare_interior_mutable_const fires for static pointer types
- Lint against Arc<impl Copy> HOT 1
- duplicated_attributes: false positive with apistos crate
- Clippy to fix warnings when they are converted to errors HOT 1
- Incorrectly printed suggestion for `map(<f>).unwrap_or(false)` on multiple lines HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-clippy.