about summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
AgeCommit message (Collapse)AuthorLines
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-9/+6
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-05-28Make EarlyBinder's inner value private; and fix all of the resulting errorsKyle Matsuda-1/+1
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-5/+5
2023-05-27Drop uplifted clippy::invalid_utf8_in_uncheckedUrgau-77/+1
2023-05-21Rename `forget_ref` lint to `forgetting_references`Urgau-2/+2
2023-05-21Rename `drop_ref` lint to `dropping_references`Urgau-2/+2
2023-05-21Rename `forget_copy` lint to `forgetting_copy_types`Urgau-2/+2
2023-05-21Rename `drop_copy` lint to `dropping_copy_types`Urgau-2/+2
2023-05-20Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyupPhilipp Krones-446/+956
2023-05-17Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkinDylan DPC-4/+5
Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-16Remove `LangItems::require`Nilstrieb-4/+5
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-10Drop uplifted clippy::forget_copyUrgau-34/+3
2023-05-10Drop uplifted clippy::forget_refUrgau-28/+3
2023-05-10Drop uplifted clippy::drop_copyUrgau-28/+3
2023-05-10Drop uplifted clippy::drop_refUrgau-29/+3
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-0/+1
Introduce `AliasKind::Inherent` for inherent associated types Allows us to check (possibly generic) inherent associated types for well-formedness. Type inference now also works properly. Follow-up to #105961. Supersedes #108430. Fixes #106722. Fixes #108957. Fixes #109768. Fixes #109789. Fixes #109790. ~Not to be merged before #108860 (`AliasKind::Weak`).~ CC `@jackh726` r? `@compiler-errors` `@rustbot` label T-types F-inherent_associated_types
2023-05-06changes from review: add FIXME to clippy and change subst_identity to ↵Kyle Matsuda-0/+3
skip_binder in mir subst methods
2023-05-06make (try_)subst_and_normalize_erasing_regions take EarlyBinderKyle Matsuda-1/+1
2023-05-05Auto merge of #111255 - flip1995:clippyup, r=Manishearthbors-119/+477
Update Clippy r? `@Manishearth`
2023-05-05Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyupPhilipp Krones-119/+477
2023-05-05Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errorsDylan DPC-3/+9
Implement RFC 3348, `c"foo"` literals RFC: https://github.com/rust-lang/rfcs/pull/3348 Tracking issue: #105723
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-0/+1
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-7/+4
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-7/+7
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02rm diag item, use lang itemDeadbeef-3/+3
2023-05-02initial step towards implementing C string literalsDeadbeef-0/+6
2023-05-02Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errorsDylan DPC-63/+3
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` Split from #109842. r? ``@compiler-errors``
2023-04-28uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`Deadbeef-63/+3
2023-04-27Make clippy happyMichael Goulet-1/+1
2023-04-26Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadataAlbert Larsan-3/+1
2023-04-26Fix uses of `TraitRef::identity` in clippy and rustdocMaybe Waffle-6/+3
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-3/+2
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Use `ty::TraitRef::new` in clippyMaybe Waffle-1/+1
2023-04-24Auto merge of #110718 - flip1995:clippyup, r=Manishearthbors-128/+298
Update Clippy r? `@Manishearth` A few days late, I was on a business trip, sorry.
2023-04-23Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillotbors-2/+2
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23Merge commit 'a3ed905928a03b6e433d0b429190bf3a847128b3' into clippyupPhilipp Krones-128/+298
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-1/+7
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
2023-04-21Allow `LocalDefId` as the argument to `def_path_str`Oli Scherer-2/+2
2023-04-21offset_ofDrMeepster-1/+7
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-1/+1
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20change usages of explicit_item_bounds to bound_explicit_item_boundsKyle Matsuda-4/+3
2023-04-20Remove WithOptconstParam.Camille GILLOT-5/+3
2023-04-16Alloc `hir::Lit` in an arena to remove the destructor from `Expr`Nilstrieb-5/+5
This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on.
2023-04-11Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyupPhilipp Krones-513/+1468
2023-04-06Make elaborator genericMichael Goulet-1/+1
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-2/+2
2023-04-04box a bunch of large typesOli Scherer-2/+2
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-2/+2
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-1/+1
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-2/+2