about summary refs log tree commit diff
path: root/clippy_lints/src
AgeCommit message (Collapse)AuthorLines
2024-01-15Ensure `callee_id`s are body ownersSamuel Moelius-3/+3
2024-01-12Delegation implementation: step 1Bryanskiy-0/+1
2024-01-11Auto merge of #119864 - matthiaskrgr:rollup-mc2qz13, r=matthiaskrgrbors-1/+1
Rollup of 8 pull requests Successful merges: - #119448 (annotate-snippets: update to 0.10) - #119813 (Silence some follow-up errors [2/x]) - #119836 (chore: remove unnecessary blank line) - #119841 (Remove `DiagnosticBuilder::buffer`) - #119842 (coverage: Add enums to accommodate other kinds of coverage mappings) - #119845 (rint: further doc tweaks) - #119852 (give const-err4 a more descriptive name) - #119853 (rustfmt.toml: don't ignore just any tests path, only root one) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-11Merge commit '26ac6aab023393c94edf42f38f6ad31196009643'Philipp Krones-351/+1664
2024-01-11Stop using `DiagnosticBuilder::buffer` in the parser.Nicholas Nethercote-1/+1
One consequence is that errors returned by `maybe_new_parser_from_source_str` now must be consumed, so a bunch of places that previously ignored those errors now cancel them. (Most of them explicitly dropped the errors before. I guess that was to indicate "we are explicitly ignoring these", though I'm not 100% sure.)
2024-01-08Rustdoc and Clippy stop misusing Key for Ty -> (adt) DefIdMichael Goulet-19/+9
2024-01-06Auto merge of #119531 - petrochenkov:cmpctxt, r=cjgillotbors-4/+4
rustc_span: Optimize syntax context comparisons Including comparisons with root context. - `eq_ctxt` doesn't require retrieving full `SpanData`, or taking the span interner lock twice. - Checking `SyntaxContext` for "rootness" is cheaper than extracting a full outer `ExpnData` for it and checking *it* for rootness. The internal lint for `eq_ctxt` is also tweaked to detect `a.ctxt() != b.ctxt()` in addition to `a.ctxt() == b.ctxt()`.
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-4/+4
Including comparisons with root context
2024-01-05Rollup merge of #119554 - matthewjasper:remove-guard-distinction, ↵Matthias Krüger-89/+51
r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes #118593
2024-01-05Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obkMichael Goulet-2/+2
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
2024-01-05Update clippy for hir::Guard removalMatthew Jasper-89/+51
2024-01-05Rename `EmitterWriter` as `HumanEmitter`.Nicholas Nethercote-2/+2
For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
2024-01-01Address unused tuple struct fields in clippyJake Goulding-19/+18
2023-12-29Auto merge of #119387 - flip1995:clippy-subtree-sync, r=matthiaskrgrbors-133/+821
Clippy subtree update r? `@Manishearth`
2023-12-28Merge commit 'ac4c2094a6030530661bee3876e0228ddfeb6b8b' into clippy-subtree-syncPhilipp Krones-133/+821
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-1/+1
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-69/+101
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Fix clippy's usage of Body's coroutine_kindMichael Goulet-69/+101
Also fixes a bug where we weren't peeling blocks from async bodies
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-23Rollup merge of #119231 - aDotInTheVoid:PatKind-struct-bool-docs, ↵Matthias Krüger-1/+1
r=compiler-errors Clairify `ast::PatKind::Struct` presese of `..` by using an enum instead of a bool The bool is mainly used for when a `..` is present, but it is also set on recovery to avoid errors. The doc comment not describes both of these cases. See https://github.com/rust-lang/rust/blob/cee794ee98d49b45a55ba225680d98e0c4672736/compiler/rustc_parse/src/parser/pat.rs#L890-L897 for the only place this is constructed. r? ``@compiler-errors``
2023-12-23bool->enum for ast::PatKind::Struct presence of `..`Alona Enraght-Moony-1/+1
See https://github.com/rust-lang/rust/blob/cee794ee98d49b45a55ba225680d98e0c4672736/compiler/rustc_parse/src/parser/pat.rs#L890-L897 for the only place this is constructed.
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-15/+19
2023-12-22Auto merge of #118847 - eholk:for-await, r=compiler-errorsbors-3/+7
Add support for `for await` loops This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library. Given a loop like: ```rust for await i in iter { ... } ``` this is desugared to something like: ```rust let mut iter = iter.into_async_iter(); while let Some(i) = loop { match core::pin::Pin::new(&mut iter).poll_next(cx) { Poll::Ready(i) => break i, Poll::Pending => yield, } } { ... } ``` This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this. I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue. r? `@compiler-errors`
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-2/+2
2023-12-19Plumb awaitness of for loopsEric Holk-3/+7
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-2/+2
2023-12-18Rename `ParseSess::with_span_handler` as `ParseSess::with_dcx`.Nicholas Nethercote-2/+2
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-2/+2
2023-12-16Merge commit 'a859e5cc1ce100df22346a1005da30532d04de59' into clippyupPhilipp Krones-328/+924
2023-12-15Appease the tools: clippy, rustdocMichael Goulet-4/+6
2023-12-15Rollup merge of #118888 - compiler-errors:uplift-more-things, r=jackh726Matthias Krüger-3/+3
Uplift `TypeAndMut` and `ClosureKind` to `rustc_type_ir` Uplifts `TypeAndMut` and `ClosureKind` I know I said I was just going to get rid of `TypeAndMut` (https://github.com/rust-lang/types-team/issues/124) but I think this is much simpler, lol r? `@jackh726` or `@lcnr`
2023-12-12Uplift TypeAndMutMichael Goulet-3/+3
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-50/+49
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-11Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwcobors-67/+3
Add lint against ambiguous wide pointer comparisons This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang. ## `ambiguous_wide_pointer_comparisons` *warn-by-default* The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands. ### Example ```rust let ab = (A, B); let a = &ab.0 as *const dyn T; let b = &ab.1 as *const dyn T; let _ = a == b; ``` ### Explanation The comparison includes metadata which may not be expected. ------- This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one. ~~One thing: is the current naming right? `invalid` seems a bit too much.~~ Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11Auto merge of #118661 - fee1-dead-contrib:restore-const-partialEq, ↵bors-3/+8
r=compiler-errors Restore `const PartialEq` And thus fixes a number of tests. There is a bug that still needs to be fixed, so WIP for now. r? `@compiler-errors`
2023-12-11Add spacing information to delimiters.Nicholas Nethercote-1/+1
This is an extension of the previous commit. It means the output of something like this: ``` stringify!(let a: Vec<u32> = vec![];) ``` goes from this: ``` let a: Vec<u32> = vec![] ; ``` With this PR, it now produces this string: ``` let a: Vec<u32> = vec![]; ```
2023-12-10fix clippyDeadbeef-3/+8
2023-12-10remove redundant importssurechen-8/+5
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-1/+1
Introduce support for `async gen` blocks I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`. **This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078). ### Technical note on the pre-generator-transform yield type: The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant). This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden. r? `@ghost`
2023-12-08coro_kind -> coroutine_kindMichael Goulet-1/+1
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-2/+6
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-06Drop clippy::vtable_address_comparisonsUrgau-67/+3
2023-12-04Fix buildEric Holk-1/+1
2023-12-04Update doctestEric Holk-2/+2
2023-12-04Remove bad mergeEric Holk-199/+0
2023-12-04Option<CoroutineKind>Eric Holk-1/+1
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-0/+199
2023-12-03Parse a pattern with no armNadrieril-2/+6
2023-12-01Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-syncPhilipp Krones-850/+1500
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-2/+6
Add `never_patterns` feature gate This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment. `@scottmcm` has agreed to be my lang-team liaison for this experiment.