summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
AgeCommit message (Collapse)AuthorLines
2022-10-29Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errorsGuillaume Gomez-89/+132
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-114/+114
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-89/+132
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-23Merge commit '4f142aa1058f14f153f8bfd2d82f04ddb9982388' into clippyupflip1995-2730/+3552
2022-10-21Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPCbors-9/+14
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-20rustc_hir_typeck: fix clippylcnr-9/+10
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-9/+14
2022-10-14Remove CastCheckResult since it's unusedMichael Goulet-12/+17
2022-10-10Rollup merge of #99696 - WaffleLapkin:uplift, r=fee1-deadDylan DPC-129/+6
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-10Rollup merge of #102829 - compiler-errors:rename-impl-item-kind, r=TaKO8KiYuki Okushi-2/+2
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-129/+6
2022-10-09ImplItemKind::TyAlias => ImplItemKind::TypeMichael Goulet-2/+2
2022-10-07Auto merge of #102091 - RalfJung:const_err, r=oli-obkbors-1/+0
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-1/+0
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-63/+52
2022-10-07Introduce TypeErrCtxtCameron Steffen-2/+2
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't need to.
2022-10-06Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyupPhilipp Krones-13/+7
2022-10-06Merge commit 'ac0e10aa68325235069a842f47499852b2dee79e' into clippyupPhilipp Krones-2318/+3300
2022-10-04It's not about types or consts, but the lack of regionsOli Scherer-1/+1
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-10/+9
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01clippy: adopt to the new lint APIMaybe Waffle-10/+9
2022-09-29Shrink `hir::def::Res`.Nicholas Nethercote-3/+8
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-27rustc_typeck to rustc_hir_analysislcnr-23/+23
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-24separate definitions and `HIR` ownersTakayuki Maeda-78/+78
fix a ui test use `into` fix clippy ui test fix a run-make-fulldeps test implement `IntoQueryParam<DefId>` for `OwnerId` use `OwnerId` for more queries change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-23Auto merge of #102056 - b-naber:unevaluated, r=lcnrbors-1/+1
Introduce mir::Unevaluated Previously the distinction between unevaluated constants in the type-system and in mir was not explicit and a little confusing. Probably better to introduce its own type for that. r? `@lcnr`
2022-09-23rename Unevaluated to UnevaluatedConstb-naber-1/+1
2022-09-22Rollup merge of #102123 - schteve:clippy-note, r=ManishearthMatthias Krüger-0/+4
Add note to clippy::non_expressive_names doc Addresses confusion in rust-lang/rust-clippy#9514 by updating the lint docs.
2022-09-22introduce mir::Unevaluatedb-naber-1/+1
2022-09-21Add note to clippy::non_expressive_names docSteve Heindel-0/+4
2022-09-21Merge commit '7248d06384c6a90de58c04c1f46be88821278d8b' into sync-from-clippyDavid Koloski-674/+543
2022-09-19remove the `Subst` trait, always use `EarlyBinder`lcnr-6/+2
2022-09-15Fix clippyest31-1/+1
2022-09-15Auto merge of #101811 - flip1995:clippyup, r=flip1995bors-3/+2
Clippy pre beta branch fix Before beta is branched on Friday, I want to move the `unused_peekable` lint that was added in this release cycle (1.65) to `nursery`. This lint was already reported twice (https://github.com/rust-lang/rust-clippy/issues/9456, https://github.com/rust-lang/rust-clippy/issues/9462) in a short time, so it is probably a good idea to fix it before it hits beta and then stable. r? `@Manishearth`
2022-09-14Temporarily move clippy::unused_peekable to nurseryPhilipp Krones-3/+2
2022-09-14Auto merge of #101212 - eholk:dyn-star, r=compiler-errorsbors-2/+2
Initial implementation of dyn* This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things: * Introduce `dyn_star` feature flag * Adds parsing for `dyn* Trait` types * Defines `dyn* Trait` as a sized type * Adds support for explicit casts, like `42usize as dyn* Debug` * Including const evaluation of such casts * Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope * Adds codegen for method calls, at least for methods that take `&self` Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits. Joint work with `@nikomatsakis` and `@compiler-errors.` r? `@bjorn3`
2022-09-14Auto merge of #101709 - nnethercote:simplify-visitors-more, r=cjgillotbors-10/+10
Simplify visitors more A successor to #100392. r? `@cjgillot`
2022-09-13Address code review commentsEric Holk-19/+8
2022-09-13Auto merge of #100640 - reitermarkus:socket-display-buffer, r=thomccbors-26/+60
Use `DisplayBuffer` for socket addresses. Continuation of https://github.com/rust-lang/rust/pull/100625 for socket addresses. Renames `net::addr` to `net::addr::socket`, `net::ip` to `net::addr::ip` and `net::ip::display_buffer::IpDisplayBuffer` to `net::addr::display_buffer::DisplayBuffer`.
2022-09-12Make x.py check workEric Holk-9/+20
2022-09-12Simplify `clippy` fix.Markus Reiter-37/+22
2022-09-12Fix clippy.Markus Reiter-16/+65
2022-09-12Auto merge of #99334 - NiklasJonsson:84447/error-privacy, r=oli-obkbors-4/+3
rustc_error, rustc_private: Switch to stable hash containers Relates https://github.com/rust-lang/rust/issues/84447
2022-09-12Remove unused argument from `visit_poly_trait_ref`.Nicholas Nethercote-6/+6
2022-09-12Remove unused span argument from `walk_fn`.Nicholas Nethercote-4/+4
2022-09-10Auto merge of #98559 - jackh726:remove-reempty, r=oli-obkbors-1/+1
Remove ReEmpty r? rust-lang/types