about summary refs log tree commit diff
path: root/src/tools/clippy/clippy_lints
AgeCommit message (Collapse)AuthorLines
2023-09-26subst -> instantiatelcnr-2/+2
2023-09-26Don't store lazyness in DefKindMichael Goulet-1/+1
2023-09-25Merge commit '7671c283a50b5d1168841f3014b14000f01dd204' into clippyupPhilipp Krones-850/+1297
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-1/+0
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-18/+25
2023-09-21Record asyncness span in HIRMichael Goulet-3/+4
2023-09-21Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obkGuillaume Gomez-3/+3
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`. Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all. However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish... ``@oli-obk`` any ideas?
2023-09-21Prevent promotion of const fn calls in inline constsOli Scherer-2/+2
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-3/+3
2023-09-18Auto merge of #115748 - RalfJung:post-mono, r=oli-obkbors-3/+3
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2023-09-15Auto merge of #115851 - Alexendoo:clippy-doc-hidden-headers, r=flip1995bors-0/+4
Ignore `#[doc(hidden)]` functions in clippy doc lints Fixes https://github.com/rust-lang/rust-clippy/issues/11501 The implementation before #115689 had a check for unsugared doc comments that also happened to catch `#[doc(hidden)]`, this adds the check back in more explicitly https://github.com/rust-lang/rust/blob/852bf4e51bf260550cd1a280d2146f1c0641b1e8/src/tools/clippy/clippy_lints/src/doc.rs#L526-L529 r? `@flip1995`
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-3/+3
2023-09-14Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naberbors-2/+2
Improve invalid let expression handling - Move all of the checks for valid let expression positions to parsing. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress some later errors and MIR construction for invalid let expressions. - Fix a (drop) scope issue that was also responsible for #104172. Fixes #104172 Fixes #104868
2023-09-14Ignore `#[doc(hidden)]` functions in clippy doc lintsAlex Macleod-0/+4
2023-09-14Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obkbors-1/+1
treat host effect params as erased in codegen This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`. r? `@oli-obk`
2023-09-14treat host effect params as erased generics in codegenDeadbeef-1/+1
This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.
2023-09-14cleanup op_to_const a bit; rename ConstValue::ByRef → IndirectRalf Jung-1/+1
2023-09-13Auto merge of #115790 - flip1995:clippyup, r=Manishearthbors-420/+1333
Update Clippy r? `@Manishearth`
2023-09-13make the set of methods between our two Const types more consistentRalf Jung-10/+2
2023-09-12Merge commit '98363cbf6a7c3f8b571a7d92a3c645bb4376e4a6' into clippyupPhilipp Krones-420/+1333
2023-09-12Auto merge of #115689 - Alexendoo:clippy-doc-comments, ↵bors-127/+61
r=notriddle,Manishearth,flip1995 Reuse rustdoc's doc comment handling in Clippy Moves `source_span_for_markdown_range` and `span_of_attrs` (renamed to `span_of_fragments`) to `rustc_resolve::rustdoc` so it can be used in Clippy Fixes https://github.com/rust-lang/rust-clippy/issues/10277 Fixes https://github.com/rust-lang/rust-clippy/issues/5593 Fixes https://github.com/rust-lang/rust-clippy/issues/10263 Fixes https://github.com/rust-lang/rust-clippy/issues/2581
2023-09-11Update tools and fulldeps testsMatthew Jasper-2/+2
2023-09-08Reuse rustdoc's doc comment handling in ClippyAlex Macleod-127/+61
2023-09-08Partially outline code inside the panic! macroJohn Kåre Alsaker-4/+19
2023-09-07Use `Freeze` for `SourceFile.lines`John Kåre Alsaker-46/+38
2023-09-03Fix clippy.Camille GILLOT-15/+11
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-2/+2
2023-09-01[`clippy`] Use symbols intended for `arithmetic_side_effects`Caio-9/+40
2023-08-24Merge commit '080b587854a73f2a8cbaecff1884860a78e2ff37' into clippyupPhilipp Krones-54/+631
2023-08-17Auto merge of #11314 - GuillaumeGomez:needless_ref_mut_async_block, r=Centri3bors-22/+81
Correctly handle async blocks for NEEDLESS_PASS_BY_REF_MUT Fixes https://github.com/rust-lang/rust-clippy/issues/11299. The problem was that the `async block`s are popping a closure which we didn't go into, making it miss the mutable access to the variables. cc `@Centri3` changelog: none
2023-08-17Auto merge of #11070 - y21:issue11065, r=flip1995bors-3/+15
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro Fixes #11065 (which is actually two issues: an ICE and a false positive) It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616836099). It *also* makes sure that the expression is not part of a macro call (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616919639). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore) changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP) r? `@llogiq` (reviewed #10814, which introduced these issues)
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-11/+12
2023-08-11Merge commit '1e8fdf492808a25d78a97e1242b835ace9924e4d' into clippyupPhilipp Krones-238/+676
2023-08-11Auto merge of #114719 - compiler-errors:rollup-bf1vr51, r=compiler-errorsbors-80/+0
Rollup of 5 pull requests Successful merges: - #114194 (Inline trivial (noop) flush calls) - #114257 (Avoid using `ptr::Unique` in `LinkedList` code) - #114359 ([library/std] Replace condv while loop with `cvar.wait_while`.) - #114402 (Fix documentation of impl From<Vec<T>> for Rc<[T]>) - #114715 (Revert clippy lint [`filter_map_bool_then`]) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-10Revert "New lint [`filter_map_bool_then`]"Catherine Flores-80/+0
This reverts commits 978b1daf99d8326718684381704902fdaaf71b18 and 3235d9d612909bc64550eea3a0d387e1187e93dd.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+0
Removes a piece of mutable state. Follow up to #114578.
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-1/+1
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-1/+1
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-1/+1
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc https://github.com/rust-lang/rust/issues/114401 r? `@RalfJung`
2023-08-06cleanup misinformation regarding has_derefouz-a-1/+1
2023-08-04Auto merge of #114481 - matthiaskrgr:rollup-58pczpl, r=matthiaskrgrbors-31/+31
Rollup of 9 pull requests Successful merges: - #113945 (Fix wrong span for trait selection failure error reporting) - #114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.) - #114418 (bump parking_lot to 0.12) - #114434 (Improve spans for indexing expressions) - #114450 (Fix ICE failed to get layout for ReferencesError) - #114461 (Fix unwrap on None) - #114462 (interpret: add mplace_to_ref helper method) - #114472 (Reword `confusable_idents` lint) - #114477 (Account for `Rc` and `Arc` when suggesting to clone) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-31/+31
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Auto merge of #114104 - oli-obk:syn2, r=compiler-errorsbors-10/+1
Lots of tiny incremental simplifications of `EmitterWriter` internals ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version. Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them. After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-04Improve spans for indexing expressionsNilstrieb-31/+31
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-03Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillotMatthias Krüger-1/+1
Expand, rename and improve `incorrect_fn_null_checks` lint This PR, - firstly, expand the lint by now linting on references - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks` - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut` Fixes https://github.com/rust-lang/rust/issues/113601 cc ```@est31```
2023-08-02Auto merge of #107254 - chenyukang:yukang/fix-107113-wrong-sugg-in-macro, ↵bors-3/+13
r=estebank Avoid wrong code suggesting for attribute macro Fixes #107113 r? `@estebank`
2023-08-02Remove constness from `TraitPredicate`Deadbeef-5/+2
2023-08-02fix RedundantLocals clippy caused by async and awaityukang-3/+13
2023-08-01Rename incorrect_fn_null_checks to useless_ptr_null_checks (clippy side)Urgau-1/+1
2023-07-31Merge commit '5436dba826191964ac1d0dab534b7eb6d4c878f6' into clippyupPhilipp Krones-1353/+2923