about summary refs log tree commit diff
path: root/src/tools/clippy
AgeCommit message (Collapse)AuthorLines
2022-04-30Inline WhereClause into Generics.Camille GILLOT-9/+8
2022-04-30Box HIR Generics and Impl.Camille GILLOT-3/+3
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-3/+3
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-23Make clippy inspector more precise.Camille GILLOT-2/+14
2022-04-23Drop vis in Item.Camille GILLOT-13/+13
2022-04-23Drop vis in ImplItem.Camille GILLOT-8/+5
2022-04-23Drop vis in FieldDef.Camille GILLOT-1/+4
2022-04-23Stop visiting visibility.Camille GILLOT-10/+9
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-3/+3
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
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-17Stop using CRATE_DEF_INDEX.Camille GILLOT-3/+3
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Bless clippy.Camille GILLOT-8/+8
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-14/+19
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-16Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisabors-7/+26
Implement sym operands for global_asm! Tracking issue: #93333 This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are: - At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`. - At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails). - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`. - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to. - The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression. - At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details. - On Mach-O, all symbols have a leading underscore. - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall. - No mangling is needed on other platforms. r? `@nagisa` cc `@eddyb`
2022-04-15Rollup merge of #94849 - ouz-a:master4, r=oli-obkDylan DPC-4/+4
Check var scope if it exist Fixes #92893. Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist. Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error
2022-04-15clippy: Update full path to `CString`Vadim Petrochenkov-1/+1
2022-04-14Update issue-92893.stderrouz-a-4/+4
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-7/+26
global_asm!
2022-04-13Auto merge of #95968 - davidtwco:translation-lazy-fallback, r=oli-obkbors-3/+6
errors: lazily load fallback fluent bundle Addresses (hopefully) https://github.com/rust-lang/rust/pull/95667#issuecomment-1094794087. Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. r? `@ghost` (just for perf initially)
2022-04-13Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obkbors-5/+3
Use mir constant in thir instead of ty::Const This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary). This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`. Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented. r? `@oli-obk`
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-3/+6
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-11Add new `Deinit` statement kindJakob Degen-1/+2
2022-04-09Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercotebors-3/+2
Cached stable hash cleanups r? `@nnethercote` Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time. Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
2022-04-08remove CheckVisitor, CollectExternCrateVisitor and ItemLikeVisitor implsMiguel Guarniz-0/+4
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08Refactor HIR item-like traversal (part 1)Miguel Guarniz-14/+15
- 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-08Avoid looking at the internals of Interned directlyOli Scherer-3/+2
2022-04-08Update Cargo.lockflip1995-1/+1
2022-04-08Merge commit '984330a6ee3c4d15626685d6dc8b7b759ff630bd' into clippyupflip1995-1486/+3113
2022-04-06get rid of visit_constant in thir visitorb-naber-8/+9
2022-04-05session: opt for enabling directionality markersDavid Wood-2/+2
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-2/+6
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-10/+24
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-12/+24
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-02rebase and use ty::Const in patterns againb-naber-13/+10
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>