about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2023-05-06delete whitelist and add checks to check_item() for missing_docsJames Dietz-24/+5
add test and bless
2023-05-06Emit while_true lint spanning the entire loop conditionFlying-Toast-2/+1
The lint that suggests `loop {}` instead of `while true {}` has functionality to 'pierce' parenthesis in cases like `while (true) {}`. In these cases, the emitted span only went to the hi of the `true` itself, not spanning the entire loop condition. Before: ``` warning: denote infinite loops with `loop { ... }` --> /tmp/foobar.rs:2:5 | 2 | while ((((((true)))))) {} | ^^^^^^^^^^^^^^^^ help: use `loop` | = note: `#[warn(while_true)]` on by default ``` After: ``` warning: denote infinite loops with `loop { ... }` --> /tmp/foobar.rs:2:5 | 2 | while ((((((true)))))) {} | ^^^^^^^^^^^^^^^^^^^^^^ help: use `loop` | = note: `#[warn(while_true)]` on by default ```
2023-05-06Check arguments length in trivial diagnostic lintclubby789-2/+4
2023-05-06introduce `DynSend` and `DynSync` auto traitSparrowLii-10/+10
2023-05-05Improve check-cfg diagnostics (part 2)Urgau-9/+45
2023-05-05Improve check-cfg diagnostics (part 1)Urgau-8/+8
2023-05-05Improve internal representation of check-cfgUrgau-16/+18
This is done to simplify to relationship between names() and values() but also make thing clearer (having an Any to represent that any values are allowed) but also to allow the (none) + values expected cases that wasn't possible before.
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-3/+8
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-11/+11
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-29add match to diagnostic messagesDeadbeef-3/+3
2023-04-28uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`Deadbeef-18/+71
2023-04-27rename `needs_subst` to `has_param`Boxy-1/+1
2023-04-26Rollup merge of #108760 - clubby789:autolintstuff, r=wesleywiserMatthias Krüger-1/+84
Add lint to deny diagnostics composed of static strings r? ghost I'm hoping to have a lint that semi-automatically converts simple diagnostics such as `struct_span_err(span, "msg").help("msg").span_note(span2, "msg").emit()` to typed session diagnostics. It's quite hacky and not entirely working because of problems with `x fix` but should hopefully help reduce some of the work. I'm going to start trying to apply what I can from this, but opening this as a draft in case anyone wants to develop on it. cc #100717
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-3/+3
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Add deny lint to prevent untranslatable diagnostics using static stringsclubby789-1/+84
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-20add subst_identity_iter and subst_identity_iter_copied methods on ↵Kyle Matsuda-26/+18
EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-3/+3
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20change usages of explicit_item_bounds to bound_explicit_item_boundsKyle Matsuda-18/+26
2023-04-20Rollup merge of #110545 - WaffleLapkin:generic_arg_as_x, r=cjgillotMatthias Krüger-4/+2
Add `GenericArgKind::as_{type,const,region}` This allows to make code nicer in some cases
2023-04-20Rollup merge of #110575 - Ezrashaw:fix-regression-110573, r=compiler-errorsYuki Okushi-9/+12
fix lint regression in `non_upper_case_globals` Fixes #110573 The issue also exists for inherent associated types (where I copied my impl from). `EarlyContext` is more involved to fix in this way, so I'll leave it be for now (note it's unstable so that's not urgent). r? `@compiler-errors`
2023-04-20reimpl `make non_upper_case_globals lint not report trait impls`Ezra Shaw-9/+12
2023-04-19Add `GenericArgKind::as_{type,const,region}`Maybe Waffle-4/+2
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-1/+1
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-19make `non_upper_case_globals` lint not report trait implsEzra Shaw-6/+9
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+1
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Rollup merge of #110441 - kadiwa4:typos, r=thomccGuillaume Gomez-1/+1
5 little typos
2023-04-17Spelling - compilerJosh Soref-7/+7
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Rollup merge of #110257 - ↵Matthias Krüger-18/+32
lukas-code:why-would-anyone-write-code-like-that-anyway, r=oli-obk fix false positives for `unused_parens` around unary and binary operations fix https://github.com/rust-lang/rust/issues/110251
2023-04-17typoskadiwa-1/+1
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-23/+16
2023-04-13emit `unused_parens` for `break` if it is not immediately followed by a blockLukas Markeffsky-4/+6
2023-04-13fix false positives for `unused_parens` around unary and binary operationsLukas Markeffsky-18/+30
2023-04-12Rollup merge of #110153 - DaniPopes:compiler-typos, r=NilstriebMatthias Krüger-16/+16
Fix typos in compiler I ran [`typos -w compiler`](https://github.com/crate-ci/typos) to fix typos in the `compiler` directory. Refs #110150
2023-04-11Allow the elaborator to only filter to real supertraitsMichael Goulet-0/+2
2023-04-10Fix typos in compilerDaniPopes-16/+16
2023-04-09Use HashMap entry APIs moreNilstrieb-6/+6
2023-04-06Make elaborator genericMichael Goulet-19/+16
2023-04-05Auto merge of #109117 - oli-obk:locks, r=michaelwoeristerbors-1/+1
Avoid a few locks We can use atomics or datastructures tuned for specific access patterns instead of locks. This may be an improvement for parallel rustc, but it's mostly a cleanup making various datastructures only usable in the way they are used right now (append data, never mutate), instead of having a general purpose lock.
2023-04-04Auto merge of #109944 - cjgillot:lint-cstring-macro, r=Nilstriebbors-41/+8
Do not suppress temporary_cstring_as_ptr in macros. There isn't really a reason to skip the lint when part of the expression comes from an expansion. Fixes https://github.com/rust-lang/rust/issues/94694
2023-04-04Do not suppress temporary_cstring_as_ptr in macros.Camille GILLOT-41/+8
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-1/+1
2023-04-04box a bunch of large typesOli Scherer-2/+2
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-1/+3
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-3/+2
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-2/+3
2023-04-04Replace another lock with an append-only vecOli Scherer-1/+1
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+1
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-29Rollup merge of #109554 - MU001999:master, r=WaffleLapkinMatthias Krüger-14/+56
Suggest ..= when someone tries to create an overflowing range Fixes #109529
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-2/+1
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.