about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-4/+4
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-28/+50
patterns.
2022-11-16Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkovbors-77/+90
Use `token::Lit` in `ast::ExprKind::Lit`. Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. r? `@petrochenkov`
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-2/+3
2022-11-16cleanup and dedupe CTFE and Miri error reportingRalf Jung-3/+3
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-77/+90
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-13Fix clippy and rustdocMaybe Waffle-6/+6
please, please, don't match on `Symbol::as_str`s, every time you do, somewhere in the world another waffle becomes sad...
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-4/+4
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-0/+1
2022-11-09bless clippyyukang-0/+5
2022-11-05Rollup merge of #103660 - ozkanonur:master, r=jyn514Dylan DPC-74/+5
improve `filesearch::get_or_default_sysroot` `fn get_or_default_sysroot` is now improved and used in `miri` and `clippy`, and tests are still passing as they should. So we no longer need to implement custom workarounds/hacks to find sysroot in tools like miri/clippy. Resolves https://github.com/rust-lang/rust/issues/98832 re-opened from #103581
2022-11-04improve `filesearch::get_or_default_sysroot` r=ozkanonurOnur Özkan-74/+5
Signed-off-by: Onur Özkan <work@onurozkan.dev>
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+24
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
2022-10-29Use LanguageItems::require lessCameron Steffen-39/+29
2022-10-29Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errorsGuillaume Gomez-91/+134
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions` This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3 r? `@compiler-errors`
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-115/+115
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-29Auto merge of #102233 - petrochenkov:effvis, r=jackh726bors-32/+32
privacy: Rename "accessibility levels" to "effective visibilities" And a couple of other naming and comment tweaks. Related to https://github.com/rust-lang/rust/issues/48054 For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often. So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.
2022-10-28Retain ParamEnv constness when running deferred cast checksDeadbeef-1/+2
Fixes #103677.
2022-10-27Move clippy::uninlined_format_args back to pedanticPhilipp Krones-3/+2
2022-10-27Update toolingMaybe Waffle-91/+134
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-32/+32
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26Adjust normalizationmejrs-3/+3
2022-10-24Add more normalization and testsmejrs-2/+6
2022-10-24Address some commentsmejrs-0/+18
2022-10-23Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyupflip1995-4206/+8511
2022-10-22Introduce subst_iter and subst_iter_copied on EarlyBinderMichael Goulet-11/+5
2022-10-21Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPCbors-137/+67
Rollup of 6 pull requests Successful merges: - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`) - #102922 (Filtering spans when emitting json) - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use) - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names) - #103260 (Fixup a few tests needing asm support) - #103321 (rustdoc: improve appearance of source page navigation bar) Failed merges: - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions) r? `@ghost` `@rustbot` modify labels: rollup
2022-10-21Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-deadDylan DPC-34/+37
Fixup a few tests needing asm support
2022-10-21Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obkDylan DPC-103/+30
Filtering spans when emitting json According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.
2022-10-20rustc_hir_typeck: fix clippylcnr-18/+17
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-103/+30
2022-10-19Fixup a few tests needing asm supportJosh Stone-34/+37
2022-10-19Add testcase for next_point, fix more trivial issues in ↵yukang-2/+1
find_width_of_character_at_span
2022-10-19Implement -Ztrack-diagnosticsmejrs-0/+2
2022-10-14Remove CastCheckResult since it's unusedMichael Goulet-12/+17
2022-10-10Fix unclosed HTML tag in clippy docGuillaume Gomez-3/+3
2022-10-10Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8KiDylan DPC-2/+2
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-deadDylan DPC-351/+36
Uplift `clippy::for_loops_over_fallibles` lint into rustc This PR, as the title suggests, uplifts [`clippy::for_loops_over_fallibles`] lint into rustc. This lint warns for code like this: ```rust for _ in Some(1) {} for _ in Ok::<_, ()>(1) {} ``` i.e. directly iterating over `Option` and `Result` using `for` loop. There are a number of suggestions that this PR adds (on top of what clippy suggested): 1. If the argument (? is there a better name for that expression) of a `for` loop is a `.next()` call, then we can suggest removing it (or rather replacing with `.by_ref()` to allow iterator being used later) ```rust for _ in iter.next() {} // turns into for _ in iter.by_ref() {} ``` 2. (otherwise) We can suggest using `while let`, this is useful for non-iterator, iterator-like things like [async] channels ```rust for _ in rx.recv() {} // turns into while let Some(_) = rx.recv() {} ``` 3. If the argument type is `Result<impl IntoIterator, _>` and the body has a `Result<_, _>` type, we can suggest using `?` ```rust for _ in f() {} // turns into for _ in f()? {} ``` 4. To preserve the original behavior and clear intent, we can suggest using `if let` ```rust for _ in f() {} // turns into if let Some(_) = f() {} ``` (P.S. `Some` and `Ok` are interchangeable depending on the type) I still feel that the lint wording/look is somewhat off, so I'll be happy to hear suggestions (on how to improve suggestions :D)! Resolves #99272 [`clippy::for_loops_over_fallibles`]: https://rust-lang.github.io/rust-clippy/master/index.html#for_loops_over_fallibles
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-2/+2
2022-10-10Rollup merge of #102275 - Urgau:stabilize-half_open_range_patterns, r=cjgillotYuki Okushi-1/+1
Stabilize `half_open_range_patterns` This PR stabilize `feature(half_open_range_patterns)`: ``` Allows using `..=X` as a pattern. ``` And adds a new `feature(half_open_range_patterns_in_slices)` for the slice part, https://github.com/rust-lang/rust/pull/102275#issuecomment-1267422806. The FCP was completed in https://github.com/rust-lang/rust/issues/67264.
2022-10-10Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8KiYuki Okushi-3/+3
rename `ImplItemKind::TyAlias` to `ImplItemKind::Type` The naming of this variant seems inconsistent given that this is not really a "type alias", and the associated type variant for `TraitItemKind` is just called `Type`.
2022-10-09deprecate `clippy::for_loops_over_fallibles`Maybe Waffle-351/+34
2022-10-09fixup lint nameMaybe Waffle-2/+2
2022-10-09Fix clippy tests that trigger `for_loop_over_fallibles` lintMaybe Waffle-1/+3
2022-10-09ImplItemKind::TyAlias => ImplItemKind::TypeMichael Goulet-3/+3
2022-10-08Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obkMatthias Krüger-1/+6
Remove `mir::CastKind::Misc` As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast. r? ````@oli-obk````
2022-10-08Stabilize half_open_range_patternsUrgau-1/+1
2022-10-07Auto merge of #102091 - RalfJung:const_err, r=oli-obkbors-7/+12
make const_err a hard error This lint has been deny-by-default with future incompat wording since [Rust 1.51](https://github.com/rust-lang/rust/pull/80394) and the stable release of this week starts showing it in cargo's future compat reports. I can't wait to finally get rid of at least some of the mess in our const-err-reporting-code. ;) r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/71800 Fixes https://github.com/rust-lang/rust/issues/100114
2022-10-07make const_err a hard errorRalf Jung-7/+12
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-102/+87