about summary refs log tree commit diff
path: root/src/tools/clippy/tests
AgeCommit message (Collapse)AuthorLines
2022-05-11Bless clippy.Camille GILLOT-1/+9
2022-05-09Auto merge of #95542 - xFrednet:rfc-2383-expect-query, r=wesleywiserbors-0/+182
Support tool lints with the `#[expect]` attribute (RFC 2383) This PR fixes the ICE https://github.com/rust-lang/rust/issues/94953 by making the assert for converted expectation IDs conditional. Additionally, it moves the lint expectation check into a separate query to support rustdoc and other tools. On the way, I've also added some tests to ensure that the attribute works for Clippy and rustdoc lints. The number of changes comes from the long test file. This may look like a monster PR, this may smell like a monster PR and this may be a monster PR, but it's a harmless monster. :sauropod: --- Closes: https://github.com/rust-lang/rust/issues/94953 cc: https://github.com/rust-lang/rust/issues/85549 r? `@wesleywiser` cc: `@rust-lang/rustdoc`
2022-05-08Auto merge of #96770 - flip1995:fix-trait-type-in-bounds, r=cjgillotbors-18/+2
Track if a where bound comes from a impl Trait desugar With https://github.com/rust-lang/rust/pull/93803 `impl Trait` function arguments get desugared to hidden where bounds. However, Clippy needs to know if a bound was originally a `impl Trait` or an actual bound. This adds a field to the `WhereBoundPredicate` struct to keep track of this information during AST->HIR lowering. r? `@cjgillot` cc `@estebank` (as the reviewer of #93803)
2022-05-08Test `expect` attribute for tool lints, clippy edition (RFC 2383)xFrednet-0/+182
2022-05-06Lint for significant drops who may have surprising lifetimes #1Preston From-0/+787
author Preston From <prestonfrom@gmail.com> 1645164142 -0600 committer Preston From <prestonfrom@gmail.com> 1650005351 -0600
2022-05-06Rollup merge of #96557 - nbdd0121:const, r=oli-obkGuillaume Gomez-1/+1
Allow inline consts to reference generic params Tracking issue: #76001 The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well. However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have: ```rust fn foo<T>() { let x = [4i32; std::mem::size_of::<T>()]; // NOT ALLOWED (for now) let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR! let x = [4i32; const { std::mem::size_of::<T>() }]; // NOT ALLOWED (for now) } ``` This would make inline consts super useful for compile-time checks and assertions: ```rust fn assert_zst<T>() { const { assert!(std::mem::size_of::<T>() == 0) }; } ``` This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do: ```rust fn assert_zst<T>() { struct F<T>(T); impl<T> F<T> { const V: () = assert!(std::mem::size_of::<T>() == 0); } let _ = F::<T>::V; } ``` It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either: ```rust fn foo<T>() -> usize { let (_, size): (PhantomData<T>, usize) = const { const fn my_size_of<T>() -> (PhantomData<T>, usize) { (PhantomData, std::mem::size_of::<T>()) } my_size_of() }; size } ``` ```@rustbot``` label: F-inline_const
2022-05-05(Partially) Revert "HACK: Move buggy lints to nursery"flip1995-18/+2
This reverts commit bb01aca86f66954b80798213711e8eadc4b26902. Partial: Keep regression tests
2022-05-05Merge commit '7c21f91b15b7604f818565646b686d90f99d1baf' into clippyupflip1995-1064/+3258
2022-05-05Bless clippy error msgGary Guo-1/+1
2022-04-30Bless tests.Camille GILLOT-14/+2
2022-04-17Auto merge of #95779 - cjgillot:ast-lifetimes-undeclared, r=petrochenkovbors-8/+8
Report undeclared lifetimes during late resolution. First step in https://github.com/rust-lang/rust/pull/91557 We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes. r? `@petrochenkov`
2022-04-17Bless clippy.Camille GILLOT-8/+8
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-13/+13
Refactor HIR item-like traversal (part 1) Issue #95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-08Refactor HIR item-like traversal (part 1)Miguel Guarniz-13/+13
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyupflip1995-465/+1443
2022-03-26Auto merge of #95274 - jendrikw:slice-must-use, r=Dylan-DPCbors-30/+30
add #[must_use] to functions of slice and its iterators. Continuation of #92853. Tracking issue: #89692.
2022-03-26add #[must_use] to functions of slice and its iterators.Jendrik-18/+18
2022-03-26add #[must_use] to functions of slice and its iterators.Jendrik-12/+12
2022-03-24Auto merge of #95273 - flip1995:clippyup, r=manishearthbors-334/+1084
Update Clippy r? `@Manishearth`
2022-03-24Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyupflip1995-334/+1084
2022-03-24update clippy stderr fileOli Scherer-0/+10
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-3/+3
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-14Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyupflip1995-56/+1394
2022-03-07Update and fix clippy testsEric Holk-5/+11
2022-03-05Do not point at whole file missing `fn main`Esteban Kuber-14/+6
Only point at the end of the crate. We could try making it point at the beginning of the crate, but that is confused with `DUMMY_SP`, causing the output to be *worse*. This change will make it so that VSCode will *not* underline the whole file when `main` is missing, so other errors will be visible.
2022-03-02bless clippyRalf Jung-4/+4
2022-02-26Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyupflip1995-327/+1776
2022-02-24Update clippy testsVadim Petrochenkov-2/+2
2022-02-18Auto merge of #94088 - oli-obk:revert, r=jackh726bors-10/+2
Revert #91403 fixes #94004 r? `@pnkfelix` `@cjgillot`
2022-02-17Revert "Auto merge of #91403 - cjgillot:inherit-async, r=oli-obk"Oli Scherer-10/+2
This reverts commit 3cfa4def7c87d571bd46d92fed608edf8fad236e, reversing changes made to 5d8767cb229b097fedb1dd4bd9420d463c37774f.
2022-02-17Don't lint `needless_borrow` in method receiver positionsJason Newcomb-25/+7
2022-02-12Bless clippy test.Camille GILLOT-2/+10
2022-02-10Merge commit '57b3c4b90f4346b3990c1be387c3b3ca7b78412c' into clippyupflip1995-345/+905
2022-02-01silence lint in clippylcnr-26/+27
2022-01-27Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyupflip1995-561/+884
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-1/+1
2022-01-21Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrumbors-1/+10
Emit simpler code from format_args I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code. <br> `println!("rust")` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &match () { _args => [], })); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); }; ``` `println!("{}", x)` **Before:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &match (&x,) { _args => [::core::fmt::ArgumentV1::new( _args.0, ::core::fmt::Display::fmt, )], }, )); }; ``` **After:** ```rust { ::std::io::_print(::core::fmt::Arguments::new_v1( &["", "\n"], &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)], )); }; ```
2022-01-17Bless clippy ui tests after format_args changeDavid Tolnay-1/+10
2022-01-17Merge commit '8d14c94b5c0a66241b4244f1c60ac5859cec1d97' into clippyupflip1995-30/+502
2022-01-13Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyupflip1995-419/+1374
2022-01-09rustc_metadata: Rename `item_children(_untracked)` to ↵Vadim Petrochenkov-2/+2
`module_children(_untracked)` And `each_child_of_item` to `for_each_module_child`
2022-01-04Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwUMatthias Krüger-1/+2
Allow `_` as the length of array types and repeat expressions r? `@BoxyUwU` cc `@varkor`
2021-12-31Make tidy check for magic numbers that spell thingsJosh Triplett-7/+7
Remove existing problematic cases.
2021-12-30Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyupflip1995-129/+676
2021-12-23fix clippylcnr-1/+2
2021-12-22Bless clippy test.Mara Bos-1/+1
2021-12-17Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisabors-3/+3
Implement let-else type annotations natively Tracking issue: #87335 Fixes #89688, fixes #89807, edit: fixes #89960 as well As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved. This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically: * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~ * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that. * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~ * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~ * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~ Some other misc notes: * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~ * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-17Merge commit '23d11428de3e973b34a5090a78d62887f821c90e' into clippyupflip1995-159/+1644
2021-12-15Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, ↵Matthias Krüger-13/+2
r=jackh726,pnkfelix Stabilize `destructuring_assignment` Closes #71126 - [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058) - [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819) `@rustbot` label +F-destructuring-assignment +T-lang Also needs +relnotes but I don't have permission to add that tag.
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-13/+2