summary refs log tree commit diff
path: root/src/tools/clippy/clippy_utils
AgeCommit message (Collapse)AuthorLines
2022-08-15Revert let_chains stabilizationNilstrieb-1/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. It was discovered that they are not implemented correctly, which does not make them ready for stabilization.
2022-08-01Auto merge of #99884 - nnethercote:lexer-improvements, r=matkladbors-2/+2
Lexer improvements Some cleanups and small speed improvements. r? `@matklad`
2022-08-01Shrink `Token`.Nicholas Nethercote-2/+2
From 72 bytes to 12 bytes (on x86-64). There are two parts to this: - Changing various source code offsets from 64-bit to 32-bit. This is not a problem because the rest of rustc also uses 32-bit source code offsets. This means `Token` is no longer `Copy` but this causes no problems. - Removing the `RawStrError` from `LiteralKind`. Raw string literal invalidity is now indicated by a `None` value within `RawStr`/`RawByteStr`, and the new `validate_raw_str` function can be used to re-lex an invalid raw string literal to get the `RawStrError`. There is one very small change in behaviour. Previously, if a raw string literal matched both the `InvalidStarter` and `TooManyHashes` cases, the latter would override the former. This has now changed, because `raw_double_quoted_string` now uses `?` and so returns immediately upon detecting the `InvalidStarter` case. I think this is a slight improvement to report the earlier-detected error, and it explains the change in the `test_too_many_hashes` test. The commit also removes a couple of comments that refer to #77629 and say that the size of these types don't affect performance. These comments are wrong, though the performance effect is small.
2022-07-31Rollup merge of #99186 - camsteffen:closure-localdefid, r=cjgillotDylan DPC-1/+1
Use LocalDefId for closures more
2022-07-30Use LocalDefId for closures moreCameron Steffen-1/+1
2022-07-29Change enclosing_body_owner to return LocalDefIdMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-28Merge commit '3c7e7dbc1583a0b06df5bd7623dd354a4debd23d' into clippyupPhilipp Krones-44/+12
2022-07-20Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"Oli Scherer-1/+0
This reverts commit 6f8fb911ad504b77549cf3256a09465621beab9d, reversing changes made to 7210e46dc69a4b197a313d093fe145722c248b7d.
2022-07-18Merge commit 'fdb84cbfd25908df5683f8f62388f663d9260e39' into clippyupPhilipp Krones-39/+253
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-15Introduce opaque type to hidden type projectionOli Scherer-0/+1
2022-07-14Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillotbors-1/+1
Support unstable moves via stable in unstable items part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328. The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge. This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillotDylan DPC-13/+22
Implement `for<>` lifetime binder for closures This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362)) and allows code like the following: ```rust let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) }; // ^^^^^^^^^^^--- new! ``` cc ``@Aaron1011`` ``@cjgillot``
2022-07-13Auto merge of #99210 - Dylan-DPC:rollup-879cp1t, r=Dylan-DPCbors-2/+6
Rollup of 5 pull requests Successful merges: - #98574 (Lower let-else in MIR) - #99011 (`UnsafeCell` blocks niches inside its nested type from being available outside) - #99030 (diagnostics: error messages when struct literals fail to parse) - #99155 (Keep unstable target features for asm feature checking) - #99199 (Refactor: remove an unnecessary `span_to_snippet`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-12Fix clippy buildMaybe Waffle-13/+22
2022-07-12add new rval, pull deref earlyouz-a-0/+1
2022-07-11move else block into the `Local` structDing Xiang Fei-5/+5
2022-07-11lower let-else in MIR insteadDing Xiang Fei-3/+7
2022-07-08add opt in attribute for stable-in-unstable itemsJane Lusby-1/+1
2022-07-07Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisabors-2/+2
Suggest using block for `extern "abi" fn` with no body `@rustbot` modify labels: +A-diagnostics
2022-07-06Update TypeVisitor pathsAlan Egerton-1/+1
2022-07-05Relax constrained generics to TypeVisitableAlan Egerton-2/+2
2022-07-02ast: Add span to `Extern`Nixon Enraght-Moony-2/+2
2022-07-01Factor out hir::Node::BindingCameron Steffen-1/+1
2022-06-30Merge commit '0cb0f7636851f9fcc57085cf80197a2ef6db098f' into clippyupPhilipp Krones-88/+446
2022-06-19remove `span_lint_and_sugg_for_edges` from clippy utilsMaybe Waffle-90/+1
2022-06-19Rollup merge of #98165 - WaffleLapkin:once_things_renamings, r=m-ou-seMatthias Krüger-2/+2
once cell renamings This PR does the renamings proposed in https://github.com/rust-lang/rust/issues/74465#issuecomment-1153703128 - Move/rename `lazy::{OnceCell, Lazy}` to `cell::{OnceCell, LazyCell}` - Move/rename `lazy::{SyncOnceCell, SyncLazy}` to `sync::{OnceLock, LazyLock}` (I used `Lazy...` instead of `...Lazy` as it seems to be more consistent, easier to pronounce, etc) ```@rustbot``` label +T-libs-api -T-libs
2022-06-17remove the rest of unnecessary `to_string`Takayuki Maeda-1/+1
2022-06-16Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock`Maybe Waffle-2/+2
2022-06-16Merge commit 'd7b5cbf065b88830ca519adcb73fad4c0d24b1c7' into clippyupflip1995-6/+20
2022-06-15Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011Yuki Okushi-13/+15
Make `ExprKind::Closure` a struct variant. Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`. r? ``@Aaron1011``
2022-06-14fix wrong evaluation in clippyb-naber-2/+2
2022-06-14address reviewb-naber-15/+5
2022-06-14fix clippy test failuresb-naber-51/+74
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-64/+52
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-1/+1
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-1/+1
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-13/+15
2022-06-04Merge commit 'd9ddce8a223cb9916389c039777b6966ea448dc8' into clippyupPhilipp Krones-27/+71
2022-06-03Rollup merge of #97415 - cjgillot:is-late-bound-solo, r=estebankDylan DPC-5/+3
Compute `is_late_bound_map` query separately from lifetime resolution This query is actually very simple, and is only useful for functions and method. It can be computed directly by fetching the HIR, with no need to embed it within the lifetime resolution visitor. Based on https://github.com/rust-lang/rust/pull/96296
2022-06-03Manipulate lifetimes by LocalDefId for region resolution.Camille GILLOT-5/+3
2022-06-03Rollup merge of #97653 - RalfJung:int-to-ptr, r=oli-obkDylan DPC-1/+6
add cast kind of from_exposed_addr (int-to-ptr casts) This is basically the dual to https://github.com/rust-lang/rust/pull/97582, for int2ptr casts. Cc `@tmiasko` https://github.com/rust-lang/rust/issues/97649
2022-06-02Auto merge of #97575 - nnethercote:lazify-SourceFile-lines, r=Mark-Simulacrumbors-3/+3
Lazify `SourceFile::lines`. `SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `RefCell` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice. r? `@Mark-Simulacrum`
2022-06-02add cast kind of from_exposed_addr (int-to-ptr casts)Ralf Jung-1/+6
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-1/+1
2022-06-01Lazify `SourceFile::lines`.Nicholas Nethercote-3/+3
`SourceFile::lines` is a big part of metadata. It's stored in a compressed form (a difference list) to save disk space. Decoding it is a big fraction of compile time for very small crates/programs. This commit introduces a new type `SourceFileLines` which has a `Lines` form and a `Diffs` form. The latter is used when the metadata is first read, and it is only decoded into the `Lines` form when line data is actually needed. This avoids the decoding cost for many files, especially in `std`. It's a performance win of up to 15% for tiny crates/programs where metadata decoding is a high part of compilation costs. A `Lock` is needed because the methods that access lines data (which can trigger decoding) take `&self` rather than `&mut self`. To allow for this, `SourceFile::lines` now takes a `FnMut` that operates on the lines slice rather than returning the lines slice.
2022-05-31Add a pointer to address cast kindTomasz Miąsko-10/+5
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-24Auto merge of #96098 - JakobDegen:always-return-place, r=oli-obkbors-0/+1
Refactor call terminator to always include destination place In #71117 people seemed to agree that call terminators should always have a destination place, even if the call was guaranteed to diverge. This implements that. Unsurprisingly, the diff touches a lot of code, but thankfully I had to do almost nothing interesting. The only interesting thing came up in const prop, where the stack frame having no return place was also used to indicate that the layout could not be computed (or similar). I replaced this with a ZST allocation, which should continue to do the right things. cc `@RalfJung` `@eddyb` who were involved in the original conversation r? rust-lang/mir-opt
2022-05-24Rollup merge of #97289 - compiler-errors:tcxify-clippy, r=Mark-SimulacrumYuki Okushi-2/+2
Lifetime variance fixes for clippy #97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be shortened to some common lifetime. This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`. Split out from #97287 so the clippy team can review independently.
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-0/+1