about summary refs log tree commit diff
path: root/clippy_lints/src/utils/mod.rs
AgeCommit message (Collapse)AuthorLines
2024-11-05collect attribute spans early for disallowed macrosJonathan Dönszelmann-0/+2
2023-10-24Hide config implementation details from public docsAlex Macleod-33/+0
2023-10-23Move configuration to new `clippy_config` crateAlex Macleod-110/+0
2023-07-24Remove Gha status emitter in compile-testAlex Macleod-1/+1
2023-06-13Now `cargo collect-metadata` updates the `CHANGELOG.md`blyxyas-0/+7
2023-05-09Refresh Lint Configuration's looksblyxyas-7/+2
2023-05-06Minimizing changesblyxyas-0/+140
2023-03-06Add `format_args_collector` internal lintAlex Macleod-0/+1
2022-04-18Add `#[clippy::print_hir]` attribute for debuggingxFrednet-1/+1
2022-01-09Combine internal features in clippy_lintsCameron Steffen-1/+1
2021-05-05Metadata collection lint: Basic lint collectionxFrednet-1/+1
WIP-2021-02-01 WIP-2021-02-01 WIP-2021-02-13
2021-03-17Don't re-export clippy_utils::*Cameron Steffen-2/+0
2021-02-24Move conf.rs back into clippy_lintsSamuel E. Moelius III-0/+1
2021-02-23Move `declare_clippy_lint` back into clippy_lintsSamuel E. Moelius III-0/+6
2021-02-23Factor out `clippy_utils` crateSamuel E. Moelius III-1862/+0
2021-02-21Add: option_manual_map lintJason Newcomb-1/+26
2021-02-11Merge remote-tracking branch 'upstream/master' into rustupflip1995-10/+47
2021-02-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-1/+0
Refactor `PrimitiveTypeTable` for Clippy I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-05Cleanup path to local checksCameron Steffen-8/+21
2021-02-04Auto merge of #6646 - nahuakang:for_loops_over_options_or_results, r=flip1995bors-2/+26
New Lint: Manual Flatten This is a draft PR for [Issue 6564](https://github.com/rust-lang/rust-clippy/issues/6564). r? `@camsteffen` - \[x] Followed [lint naming conventions][lint_naming] - \[x] Added passing UI tests (including committed `.stderr` file) - \[x] `cargo test` passes locally - \[x] Executed `cargo dev update_lints` - \[x] Added lint documentation - \[x] Run `cargo dev fmt` --- *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: Add new lint [`manual_flatten`] to check for loops over a single `if let` expression with `Result` or `Option`.
2021-02-03Use PrimTy in builtin type shadow lintCameron Steffen-1/+0
2021-02-02Merge commit '3e4179766bcecd712824da04356621b8df012ea4' into sync-from-clippyManish Goregaokar-14/+17
2021-02-02Auto merge of #6664 - camsteffen:path-to-res, r=Manishearthbors-13/+15
Remove Option from `path_to_res` return type changelog: none Tiny cleanup for `path_to_res` to return `Res` instead of `Option<Res>`.
2021-02-02Auto merge of #6659 - phlip9:let_and_return_fix, r=phanschbors-1/+2
Fix let_and_return false positive The issue: See this Rust playground link: https://play.rust-lang.org/?edition=2018&gist=12cb5d1e7527f8c37743b87fc4a53748 Run the above with clippy to see the following warning: ``` warning: returning the result of a `let` binding from a block --> src/main.rs:24:5 | 23 | let value = Foo::new(&x).value(); | --------------------------------- unnecessary `let` binding 24 | value | ^^^^^ | = note: `#[warn(clippy::let_and_return)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return help: return the expression directly | 23 | 24 | Foo::new(&x).value() | ``` Implementing the suggested fix, removing the temporary let binding, yields a compiler error: ``` error[E0597]: `x` does not live long enough --> src/main.rs:23:14 | 23 | Foo::new(&x).value() | ---------^^- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... 24 | } | - | | | `x` dropped here while still borrowed | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `Foo` | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block | 23 | let x = Foo::new(&x).value(); x | ^^^^^^^ ^^^ ``` The fix: Of course, clippy looks like it should already handle this edge case; however, it appears `utils::fn_def_id` is not returning a `DefId` for `Foo::new`. Changing the `qpath_res` lookup to use the child Path `hir_id` instead of the parent Call `hir_id` fixes the issue. changelog: none
2021-02-01Implement manual flatten lintnahuakang-2/+26
2021-01-31Remove Option from path_to_res return typeCameron Steffen-13/+15
2021-01-30Merge commit '95c0459217d1661edfa794c8bb122452b92fb485' into clippyupflip1995-61/+76
2021-01-30Merge remote-tracking branch 'upstream/master' into rustupflip1995-61/+76
2021-01-29Fix let_and_return false positivePhilip Hayes-1/+2
The issue: See this Rust playground link: https://play.rust-lang.org/?edition=2018&gist=12cb5d1e7527f8c37743b87fc4a53748 Run the above with clippy to see the following warning: ``` warning: returning the result of a `let` binding from a block --> src/main.rs:24:5 | 23 | let value = Foo::new(&x).value(); | --------------------------------- unnecessary `let` binding 24 | value | ^^^^^ | = note: `#[warn(clippy::let_and_return)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return help: return the expression directly | 23 | 24 | Foo::new(&x).value() | ``` Implementing the suggested fix, removing the temporary let binding, yields a compiler error: ``` error[E0597]: `x` does not live long enough --> src/main.rs:23:14 | 23 | Foo::new(&x).value() | ---------^^- | | | | | borrowed value does not live long enough | a temporary with access to the borrow is created here ... 24 | } | - | | | `x` dropped here while still borrowed | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `Foo` | = note: the temporary is part of an expression at the end of a block; consider forcing this temporary to be dropped sooner, before the block's local variables are dropped help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block | 23 | let x = Foo::new(&x).value(); x | ^^^^^^^ ^^^ ``` The fix: Of course, clippy looks like it should already handle this edge case; however, it appears `utils::fn_def_id` is not returning a `DefId` for `Foo::new`. Changing the `qpath_res` lookup to use the child Path `hir_id` instead of the parent Call `hir_id` fixes the issue.
2021-01-29Rollup merge of #81176 - camsteffen:qpath-res, r=oli-obkYuki Okushi-13/+0
Improve safety of `LateContext::qpath_res` This is my first rustc code change, inspired by hacking on clippy! The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](https://github.com/rust-lang/rust/blob/5e91c4ecc09312d8b63d250a432b0f3ef83f1df7/compiler/rustc_privacy/src/lib.rs#L1300). Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function. Related: rust-lang/rust-clippy#4545 CC ````````````@eddyb```````````` since you've done related work CC ````````````@flip1995```````````` FYI
2021-01-22Fix dogfoodCameron Steffen-2/+1
2021-01-20Auto merge of #6567 - camsteffen:path-to-res-enum, r=Manishearthbors-59/+37
Fix path_to_res for enum inherent items changelog: none I tried to add `Option::is_some` to the paths but got a false positive from the invalid paths lint. Turns out the `path_to_res` function does not find inherent impls for enums. I fixed this and took the liberty to do some additional cleanup in the method.
2021-01-18Remove qpath_res util functionCameron Steffen-13/+0
2021-01-18Use ty::{IntTy,UintTy,FloatTy} in rustdoc and clippyLeSeulArtichaut-7/+6
2021-01-18Rollup merge of #81038 - flip1995:clippyup, r=ManishearthAshley Mannix-11/+24
Update Clippy Biweekly Clippy update r? ``@Manishearth``
2021-01-16Review changesJack Huey-1/+1
2021-01-15Auto merge of #6574 - Jarcho:single_match_eq, r=Manishearthbors-0/+38
single_match: suggest `if` over `if let` when possible fixes: #173 changelog: single_match: suggest `if` over `if let` when possible
2021-01-15Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyupflip1995-11/+24
2021-01-15Merge remote-tracking branch 'upstream/master' into rustupflip1995-11/+24
2021-01-14Rename functionJason Newcomb-1/+1
2021-01-14Address review commentsJason Newcomb-0/+38
Add: attempt to remove address of expressions from the scrutinee expression before adding references to the pattern
2021-01-14Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasperbors-6/+6
Reintroduce hir::ExprKind::If Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications. The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome. - [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051) - [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d) - [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5) - [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691) - [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95) - [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-12Separate out a `hir::Impl` structJoshua Nelson-3/+3
This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases.
2021-01-08Fix path_to_res for enum inherent itemsCameron Steffen-59/+37
2021-01-08Move `is_hir_ty_cfg_dependant` to `util`,rail-0/+12
add stuff on pointer::cast` to the document for `cast_ptr_alignment` and fix line numbers in the test.
2021-01-07Reintroduce hir::ExprKind::IfCaio-6/+6
2021-01-05Tiny Symbol cleanupPhilipp Hansch-5/+5
* Renames `sym.rs` to `sym_helper.rs` so that the `sym as rustc_sym` is no longer needed. * Removes one needless `symbol` from a path
2021-01-02Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyupflip1995-2/+1
2020-12-22remove clone in manual_async_fn lintMatthias Krüger-2/+1
2020-12-20Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyupflip1995-2/+33