about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2023-07-26Unite bless environment variables under `RUSTC_BLESS`Trevor Gross-1/+3
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to indicate that output should be blessed, but they use different variable names. In order to improve consistency, this patch applies the following changes: - Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always available - Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS` - Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS` - Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS` - Adjust the blessable test in `rustc_errors` to use this same convention - Update documentation where applicable Any tools that uses `RUSTC_BLESS` should check that it is set to any value other than `"0"`.
2023-07-26Rollup merge of #114070 - blyxyas:iter_mut_symbol, r=oli-obkMatthias Krüger-1/+1
Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy We currently have `sym::iter` and `sym::iter_repeat`, this PR adds `sym::iter_mut` as it's useful for https://github.com/rust-lang/rust-clippy/pull/11038 and another Clippy lint, it also adds `sym::as_mut_ptr` as it's useful for https://github.com/rust-lang/rust-clippy/pull/10962.
2023-07-26Auto merge of #114054 - oli-obk:cleanups, r=estebankbors-1/+1
Split some functions with many arguments into builder pattern functions r? `@estebank` This doesn't resolve all of the ones in rustc, mostly because I need to do other cleanups in order to be able to use some builder derives from crates.io Works around https://github.com/rust-lang/rust/issues/90672 by making `x test rustfmt --bless` format itself instead of testing that it is formatted
2023-07-25Add `sym::iter_mut` + `sym::as_mut_ptr`blyxyas-1/+1
2023-07-25Auto merge of #114063 - matthiaskrgr:rollup-c90czu6, r=matthiaskrgrbors-1/+1
Rollup of 7 pull requests Successful merges: - #114008 (coverage: Obtain the `__llvm_covfun` section name outside a per-function loop) - #114014 (builtin_macros: expect raw strings too) - #114043 (docs(LazyLock): add example pass local LazyLock variable to struct) - #114051 (Add regression test for invalid "unused const" in method) - #114052 (Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some cases) - #114058 (Add help for crate arg when crate name is invalid) - #114060 (abi: unsized field in union - assert to delay bug ) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-25Rollup merge of #114014 - davidtwco:issue-114010-env-rawstr, r=cjgillotMatthias Krüger-1/+1
builtin_macros: expect raw strings too Fixes #114010. `expr_to_string` allows raw strings through so this code should be expected to handle those.
2023-07-25Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnrbors-2/+2
Normalize the RHS of an `Unsize` goal in the new solver `Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work: ```rust trait A {} trait B: A {} impl A for usize {} impl B for usize {} trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } fn main() { // usize: Unsize<dyn B> let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>; // dyn A: Unsize<dyn B> let y = x as Box<<dyn A as Mirror>::Assoc>; } ``` --- In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias. Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-25Make everything builtin!Michael Goulet-2/+2
2023-07-25Use a builder instead of boolean/option argumentsOli Scherer-1/+1
2023-07-25bless moreRalf Jung-4/+4
2023-07-25clippy: `env!` invocations can't be b"" literalsDavid Wood-1/+1
Signed-off-by: David Wood <david@davidtw.co>
2023-07-24Perform OpaqueCast field projection on HIR, too.Oli Scherer-0/+2
This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).
2023-07-23fixDeadbeef-12/+14
2023-07-20XSimplifiedType to SimplifiedType::Xlcnr-29/+26
2023-07-19On nightly, dump ICE backtraces to diskEsteban Küber-1/+1
Implement rust-lang/compiler-team#578. When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected.
2023-07-17Rename arg_iter to iter_instantiatedMichael Goulet-3/+3
2023-07-17Another fix for incorrect_implsPhilipp Krones-4/+3
2023-07-17Merge commit 'd9c24d1b1ee61f276e550b967409c9f155eac4e3' into clippyupPhilipp Krones-2537/+5241
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-307/+307
2023-07-13Rename cast_ref_to_mut to invalid_reference_casting (clippy side)Urgau-6/+6
2023-07-12Ignore flaky clippy tests.Eric Huss-0/+9
2023-07-11Auto merge of #111717 - Urgau:uplift_fn_null_check, r=oli-obkbors-223/+64
Uplift `clippy::fn_null_check` lint This PR aims at uplifting the `clippy::fn_null_check` lint into rustc. ## `incorrect_fn_null_checks` (warn-by-default) The `incorrect_fn_null_checks` lint checks for expression that checks if a function pointer is null. ### Example ```rust let fn_ptr: fn() = /* somehow obtained nullable function pointer */ if (fn_ptr as *const ()).is_null() { /* ... */ } ``` ### Explanation Function pointers are assumed to be non-null, checking for their nullity is incorrect. ----- Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 `@rustbot` label: +I-lang-nominated r? compiler
2023-07-10Drop uplifted `clippy::fn_null_check`Urgau-223/+64
2023-07-08Auto merge of #113450 - Nilstrieb:src/bootstrap/test.rs, r=flip1995bors-19/+0
Fail the build if clippy tests don't pass This was removed in https://github.com/rust-lang/rust/pull/113260/commits/de69d556eb5006a21f868b8c12d48f0ef1308a5a#diff-8479eab02701e686aedb15b567dc8fc31220c6e4efb9565ccc9d662b7fee2214 which caused CI to ignore clippy failures. This adds back the exit, which should cause CI to fail again if a test is broken (like right now, as clippy tests are broken on master). Also see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/CI.20doesn't.20care.20about.20clippy.20test.20failures.20but.20only.20sometime r? flip1995
2023-07-08Delete `to_string_in_format_args_incremental.rs`Nilstrieb-19/+0
It fails CI and passes locally. It passes random directores in `-Cincremental` so maybe something's up. It shouldn't block us here.
2023-07-08Auto merge of #113376 - ↵bors-9/+9
Nilstrieb:pointer-coercions-are-not-casts-because-that-sounds-way-to-general-aaaa, r=oli-obk Rename `adjustment::PointerCast` and variants using it to `PointerCoercion` It makes it sounds like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a little enum variants. Make it clear there these are only coercions and that people who see this and think "why are so many pointer related casts not in these variants" aren't insane. This enum was added in #59987. I'm not sure whether the variant sharing is actually worth it, but this at least makes it less confusing. r? oli-obk
2023-07-07Fix failing clippy testsAlex Macleod-41/+21
Comments out the C string literals due to https://github.com/rust-lang/rust/pull/113334 Fixes https://github.com/rust-lang/rust-clippy/issues/11121
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-9/+9
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-06Auto merge of #113377 - BoxyUwU:move_ty_ctors_to_ty, r=compiler-errorsbors-17/+18
Move `TyCtxt::mk_x` to `Ty::new_x` where applicable Part of rust-lang/compiler-team#616 turns out there's a lot of places we construct `Ty` this is a ridiculously huge PR :S r? `@oli-obk`
2023-07-06Auto merge of #113291 - oli-obk:pretty_print_mir_const, r=RalfJungbors-3/+4
Specialize `try_destructure_mir_constant` for its sole user (pretty printing) We can't remove the query, as we need to invoke it from rustc_middle, but can only implement it in mir interpretation/const eval. r? `@RalfJung` for a first round. While we could move all the logic into pretty printing, that would end up duplicating a bit of code with const eval, which doesn't seem great either.
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-17/+18
2023-07-05Patch clippyOli Scherer-3/+4
2023-07-05Deal with falloutBoxy-2/+2
2023-07-02Fix compile-test tests to work with the new ui_test cratePhilipp Krones-9/+3
2023-07-02Fix valtree changesPhilipp Krones-2/+2
2023-07-02Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyupPhilipp Krones-5828/+21798
2023-07-02Auto merge of #112718 - oli-obk:SIMD-destructure_mir_const, r=cjgillotbors-14/+62
Make simd_shuffle_indices use valtrees This removes the second-to-last user of the `destructure_mir_constant` query. So in a follow-up we can remove the query and just move the query provider function directly into pretty printing (which is the last user). cc `@rust-lang/clippy` there's a small functional change, but I think it is correct?
2023-06-27Provide more context for `rustc +nightly -Zunstable-options` on stable许杰友 Jieyou Xu (Joe)-1/+5
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-59/+30
2023-06-26Auto merge of #112887 - WaffleLapkin:become_unuwuable_in_hir, ↵bors-0/+18
r=compiler-errors,Nilstrieb `hir`: Add `Become` expression kind (explicit tail calls experiment) This adds `hir::ExprKind::Become` alongside ast lowering. During hir-thir lowering we currently lower `become` as `return`, so that we can partially test `become` without ICEing. cc `@scottmcm` r? `@Nilstrieb`
2023-06-26Make simd_shuffle_indices use valtreesOli Scherer-14/+62
2023-06-26Support `hir::ExprKind::Become` in clippyMaybe Waffle-0/+18
2023-06-25Do not offer any of the suggestions in emit_coerce_suggestions for expr from ↵yukang-5/+0
destructuring assignment desugaring
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-8/+8
2023-06-21Auto merge of #112877 - Nilstrieb:rollup-5g5hegl, r=Nilstriebbors-37/+38
Rollup of 6 pull requests Successful merges: - #112632 (Implement PartialOrd for `Vec`s over different allocators) - #112759 (Make closure_saved_names_of_captured_variables a query. ) - #112772 (Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`) - #112790 (Syntactically accept `become` expressions (explicit tail calls experiment)) - #112830 (More codegen cleanups) - #112844 (Add retag in MIR transform: `Adt` for `Unique` may contain a reference) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-21Rollup merge of #112790 - WaffleLapkin:syntactically, r=NilstriebNilstrieb-0/+1
Syntactically accept `become` expressions (explicit tail calls experiment) This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature. cc `@scottmcm`
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-37/+37
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that... r? ``@lcnr`` or ``@oli-obk`` [^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21Auto merge of #106450 - albertlarsan68:fix-arc-ptr-eq, r=Amanieubors-28/+8
Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata FCP completed in https://github.com/rust-lang/rust/issues/103763#issuecomment-1362267967 Closes #103763
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-1/+1
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19s/Clause/ClauseKindMichael Goulet-37/+37