about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2022-11-19Refactor `must_use` lint into two partsNilstrieb-113/+203
Before, the lint did the checking for `must_use` and pretty printing the types in a special format in one pass, causing quite complex and untranslatable code. Now the collection and printing is split in two. That should also make it easier to translate or extract the type pretty printing in the future. Also fixes an integer overflow in the array length pluralization calculation.
2022-11-19Rollup merge of #104566 - matthiaskrgr:clippy_perf_nov18, r=oli-obkDylan DPC-2/+2
couple of clippy::perf fixes
2022-11-19drive-by: PolyExistentialPredicateMichael Goulet-1/+1
2022-11-18Auto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkovbors-2/+5
Shrink `ast::Expr` harder r? `@ghost`
2022-11-18couple of clippy::perf fixesMatthias Krüger-2/+2
2022-11-18Rm diagnostic item, use lang itemDeadbeef-1/+1
2022-11-17Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errorsMatthias Krüger-0/+1
Convert predicates into Predicate in the Obligation constructor instead of having almost all callers do that. This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17Rollup merge of #104433 - TaKO8Ki:fix-104392, r=estebankMatthias Krüger-9/+7
Fix `emit_unused_delims_expr` ICE Fixes #104392
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-11/+8
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-2/+5
patterns.
2022-11-16Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkovbors-11/+11
Use `token::Lit` in `ast::ExprKind::Lit`. Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. r? `@petrochenkov`
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-0/+1
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-11/+11
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-15Merge branch 'master' into patch-2Kagami Sascha Rosylight-105/+138
2022-11-15Rollup merge of #104296 - compiler-errors:opaque-ty-ffi-normalization-cycle, ↵Matthias Krüger-22/+17
r=lcnr Walk types more carefully in `ProhibitOpaqueTypes` visitor The visitor didn't account for the case where you could have `<TAIT as Trait>::Assoc` normalize to itself, in the case of a `type TAIT = impl Trait` with an unconstrained associated type. That causes the visitor to loop on the same type over and over. Fixes #104291
2022-11-15return when expr has errorsTakayuki Maeda-0/+5
add ui tests
2022-11-15simplify `emit_unused_delims_expr`Takayuki Maeda-10/+3
2022-11-15Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgrbors-1/+2
Rollup of 13 pull requests Successful merges: - #103842 (Adding Fuchsia compiler testing script, docs) - #104354 (Remove leading newlines from `NonZero*` doc examples) - #104372 (Update compiler-builtins) - #104380 (rustdoc: remove unused CSS `code { opacity: 1 }`) - #104381 (Remove dead NoneError diagnostic handling) - #104383 (Remove unused symbols and diagnostic items) - #104391 (Deriving cleanups) - #104403 (Specify language of code comment to generate document) - #104404 (Fix missing minification for static files) - #104413 ([llvm-wrapper] adapt for LLVM API change) - #104415 (rustdoc: fix corner case in search keyboard commands) - #104422 (Fix suggest associated call syntax) - #104426 (Add test for #102154) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-15Normalize types before looking for opaquesMichael Goulet-22/+17
2022-11-14Specify language of code comment to generate documentkoka-1/+2
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-11/+8
2022-11-13fix some typos in commentscui fliter-2/+2
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-12Auto merge of #103530 - cjgillot:hir-lifetimes-direct, r=estebankbors-1/+1
Resolve lifetimes independently for each item-like. Now that the heavy-lifting is done on the AST and during lowering, we do not need to perform HIR lifetime resolution on a full item at once. Instead, we can treat each item-like independently, and look at `generics_of` the parent exceptionally for associated items.
2022-11-11Auto merge of #104293 - Manishearth:rollup-xj92d0k, r=Manishearthbors-13/+29
Rollup of 8 pull requests Successful merges: - #95292 (Allow specialized const trait impls.) - #100386 (Make `Sized` coinductive, again) - #102215 (Implement the `+whole-archive` modifier for `wasm-ld`) - #103468 (Fix unused lint and parser caring about spaces to won't produce invalid code) - #103531 (Suggest calling the instance method of the same name when method not found) - #103960 (piece of diagnostic migrate) - #104051 (update Miri) - #104129 (rustdoc: use javascript to layout notable traits popups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-11Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, ↵Manish Goregaokar-13/+29
r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes #103435
2022-11-11Tweak signatures in rustc_middle::hir::map.Camille GILLOT-1/+1
2022-11-10review commentsEsteban Küber-3/+10
2022-11-10Consider `#[must_use]` annotation on `async fn` as also affecting the ↵Esteban Küber-1/+13
`Future::Output` No longer lint against `#[must_use] async fn foo()`. When encountering a statement that awaits on a `Future`, check if the `Future`'s parent item is annotated with `#[must_use]` and emit a lint if so. This effectively makes `must_use` an annotation on the `Future::Output` instead of only the `Future` itself. Fix #78149.
2022-11-10Tweak span for `#[must_use]`Esteban Küber-6/+3
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-11-07fix: lint against lint functionsRejyr-0/+6
fix: lint against the functions `LintContext::{lookup_with_diagnostics,lookup,struct_span_lint,lint}`, `TyCtxt::struct_lint_node`, `LintLevelsBuilder::struct_lint`.
2022-11-05Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726Matthias Krüger-9/+2
Use `TraitEngine` (by itself) less Replace `TraitEngine` in favor of `ObligationCtxt` or `fully_solve_*`, improving code readability.
2022-11-02Use TraitEngine lessMichael Goulet-9/+2
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-2/+3
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-10-31Rollup merge of #103338 - l4l:enum-unreachable-pub, r=nagisaDylan DPC-2/+6
Fix unreachable_pub suggestion for enum with fields Resolves #103317
2022-10-29Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errorsGuillaume Gomez-4/+4
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions` This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3 r? `@compiler-errors`
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-34/+34
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-4/+4
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-26Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]Xiretza-2/+3
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-11/+12
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-25Fix failing examplesKagami Sascha Rosylight-6/+10
2022-10-24Update let_underscore.rsKagami Sascha Rosylight-2/+2
2022-10-24Update compiler/rustc_lint/src/let_underscore.rsKagami Sascha Rosylight-1/+1
2022-10-24Add `compile_fail` to `let_underscore_drop` exampleKagami Sascha Rosylight-1/+1
2022-10-24fix parentheses surrounding spacing issue in parseryukang-4/+2
2022-10-24fix #103435, unused lint won't produce invalid codeyukang-13/+31
2022-10-23Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obkMichael Howell-1/+4
Fix wrapped valid-range handling in ty_find_init_error Rust's niche handling allows for wrapping valid ranges with end < start; for instance, a valid range with start=43 and end=41 means a niche of 42. Most places in the compiler handle this correctly, but `ty_find_init_error` assumed that `lo > 0` means the type cannot contain a zero. Fix it to handle wrapping ranges.
2022-10-23Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errorsbors-291/+272
Flatten diagnostic slug modules This makes it easier to grep for the slugs in the code. See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it. This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know. r? `@davidtwco`
2022-10-23Migrate all diagnosticsNilstrieb-291/+272
2022-10-23Auto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgrbors-8/+6
Rollup of 9 pull requests Successful merges: - #103123 (Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` ) - #103328 (Do not suggest trivially false const predicates) - #103354 (Escape string literals when fixing overlong char literal) - #103355 (Handle return-position `impl Trait` in traits properly in `register_hidden_type`) - #103368 (Delay ambiguity span bug in normalize query iff not rustdoc) - #103388 (rustdoc: remove unused CSS class `.result-description`) - #103399 (Change `unknown_lint` applicability to `MaybeIncorrect`) - #103401 (Use functions for headings rustdoc GUI test) - #103412 (Fix typo in docs of `String::leak`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-23Rollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-deadMatthias Krüger-1/+1
Change `unknown_lint` applicability to `MaybeIncorrect` This small PR changes the applicability of `unknown_lint` to `MaybeIncorrect`, because the suggested lint might not be the correct one. Here is one example where the current applicability causes a problem. Clippy has a set of internal lints guarded by a feature called `internal`. If the feature is not enabled, then the internal lints are "unknown." In that case, running `cargo clippy --fix ...` on `clippy_utils` causes lines such as the followig https://github.com/rust-lang/rust/blob/26c96e341639102afacbbcad0dc18ad0ac71ab18/src/tools/clippy/clippy_utils/src/paths.rs#L51-L52 to be changed to ```rust #[expect(clippy::invalid_regex)] // internal lints do not know about all external crates pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"]; ``` which is not correct.