about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2022-03-31Auto merge of #95501 - Dylan-DPC:rollup-arx6sdc, r=Dylan-DPCbors-1/+1
Rollup of 6 pull requests Successful merges: - #93901 (Stabilize native library modifier syntax and the `whole-archive` modifier specifically) - #94806 (Fix `cargo run tidy`) - #94869 (Add the generic_associated_types_extended feature) - #95011 (async: Give predictable name to binding generated from .await expressions.) - #95251 (Reduce max hash in raw strings from u16 to u8) - #95298 (Fix double drop of allocator in IntoIter impl of Vec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-31Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnayDylan DPC-1/+1
Reduce max hash in raw strings from u16 to u8 [Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-7/+13
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30clippy: nameres for primitive type implslcnr-38/+75
2022-03-30get clippy to compile againlcnr-59/+26
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-7/+13
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
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-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-2/+2
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-25Update clippy helper function typesGrisha Vartanyan-1/+1
2022-03-24Auto merge of #95273 - flip1995:clippyup, r=manishearthbors-546/+1957
Update Clippy r? `@Manishearth`
2022-03-24Merge commit 'd0cf3481a84e3aa68c2f185c460e282af36ebc42' into clippyupflip1995-546/+1957
2022-03-24update clippy stderr fileOli Scherer-0/+10
2022-03-20Take &mut Diagnostic in emit_diagnostic.Camille GILLOT-2/+2
Taking a Diagnostic by move would break the usual pattern `diag.label(..).emit()`.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-24/+24
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15fix typosDylan DPC-2/+2
2022-03-14Merge commit 'dc5423ad448877e33cca28db2f1445c9c4473c75' into clippyupflip1995-331/+3350
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-92/+93
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-5/+6
2022-03-07Auto merge of #94706 - matthiaskrgr:rollup-l5erynr, r=matthiaskrgrbors-26/+25
Rollup of 4 pull requests Successful merges: - #93350 (libunwind: readd link attrs to _Unwind_Backtrace) - #93827 (Stabilize const_fn_fn_ptr_basics, const_fn_trait_bound, and const_impl_trait) - #94696 (Remove whitespaces and use CSS to align line numbers to the right instead) - #94700 (rustdoc: Update minifier version) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-07Update and fix clippy testsEric Holk-5/+24
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-21/+1
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-1/+1
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-07Introduce `ConstAllocation`.Nicholas Nethercote-3/+3
Currently some `Allocation`s are interned, some are not, and it's very hard to tell at a use point which is which. This commit introduces `ConstAllocation` for the known-interned ones, which makes the division much clearer. `ConstAllocation::inner()` is used to get the underlying `Allocation`. In some places it's natural to use an `Allocation`, in some it's natural to use a `ConstAllocation`, and in some places there's no clear choice. I've tried to make things look as nice as possible, while generally favouring `ConstAllocation`, which is the type that embodies more information. This does require quite a few calls to `inner()`. The commit also tweaks how `PartialOrd` works for `Interned`. The previous code was too clever by half, building on `T: Ord` to make the code shorter. That caused problems with deriving `PartialOrd` and `Ord` for `ConstAllocation`, so I changed it to build on `T: PartialOrd`, which is slightly more verbose but much more standard and avoided the problems.
2022-03-06Rollup merge of #94617 - pierwill:update-itertools, r=Mark-SimulacrumMatthias Krüger-3/+3
Update `itertools` Update to 0.10.1
2022-03-05Change syntax for TyAlias where clausesJack Huey-42/+6
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-04Update `itertools`pierwill-3/+3
Update to 0.10.1
2022-03-03Auto merge of #94512 - RalfJung:sdiv-ub, r=oli-obkbors-4/+4
Miri/CTFE: properly treat overflow in (signed) division/rem as UB To my surprise, it looks like LLVM treats overflow of signed div/rem as UB. From what I can tell, MIR `Div`/`Rem` directly lowers to the corresponding LLVM operation, so to make that correct we also have to consider these overflows UB in the CTFE/Miri interpreter engine. r? `@oli-obk`
2022-03-02bless clippyRalf Jung-4/+4
2022-03-02Move transmute_undefined_repr back to nurseryflip1995-3/+2
There's still open discussion if this lint is ready to be enabled by default. We want to give us more time to figure this out and prevent this lint from getting to stable as an enabled-by-default lint.
2022-02-26Merge commit 'e329249b6a3a98830d860c74c8234a8dd9407436' into clippyupflip1995-1441/+3461
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-23/+21
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24Rollup merge of #93714 - compiler-errors:can-type-impl-copy-error-span, ↵Dylan DPC-1/+1
r=jackh726 better ObligationCause for normalization errors in `can_type_implement_copy` Some logic is needed so we can point to the field when given totally nonsense types like `struct Foo(<u32 as Iterator>::Item);` Fixes #93687
2022-02-24Update clippy testsVadim Petrochenkov-2/+2
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-1/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-24better ObligationCause for normalization errors in can_type_implement_copyMichael Goulet-1/+1
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-6/+4
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-17/+17
2022-02-21update clippylcnr-19/+18
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-26/+8
2022-02-17Rollup merge of #94030 - ChayimFriedman2:issue-94010, r=petrochenkovMatthias Krüger-1/+1
Correctly mark the span of captured arguments in `format_args!()` It should not include the braces, or misspelling suggestions will be wrong. Fixes #94010.
2022-02-16Correctly mark the span of captured arguments in `format_args!()`Chayim Refael Friedman-1/+1
It should only include the identifier, or misspelling suggestions will be wrong.
2022-02-15Rollup merge of #94014 - flip1995:clippy_transmute_lint_regroup, r=dtolnayMatthias Krüger-3/+2
Move transmute_undefined_repr back to nursery There's still open discussion if this lint is ready to be enabled by default. We want to give us more time to figure this out and prevent this lint from getting to stable as an enabled-by-default lint. cc https://github.com/rust-lang/rust-clippy/pull/8432 r? `@Manishearth` `@dtolnay` I think this is the way to go here. We can re-enable this lint with the next sync, if we should decide to do so. But I would hold of for this release. We have until Friday (beta branching) to decide if we want to merge this.
2022-02-15Move transmute_undefined_repr back to nurseryflip1995-3/+2
There's still open discussion if this lint is ready to be enabled by default. We want to give us more time to figure this out and prevent this lint from getting to stable as an enabled-by-default lint.
2022-02-15Overhaul `Const`.Nicholas Nethercote-12/+12
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.