about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
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.
2022-10-23Rollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillotMatthias Krüger-7/+5
Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` Makes working with bounds lists a bit easier, which I seem to do a lot. Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.
2022-10-23Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obkbors-41/+5
Remove ParamEnv from uninhabited query
2022-10-23Fix wrapped valid-range handling in ty_find_init_errorJosh Triplett-1/+4
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. Add a test to cover this case.
2022-10-22Introduce InhabitedPredicateCameron Steffen-41/+5
2022-10-22Change `unknown_lint` applicability to `MaybeIncorrect`Samuel Moelius-1/+1
2022-10-22Rollup merge of #102602 - WaffleLapkin:linty_action, r=estebankDylan DPC-38/+40
Slightly tweak comments wrt `lint_overflowing_range_endpoint` From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r975610611 It _seemed_ that the lint was not emitted when the `if` check failed, but _actually_ this happens already in a special case and the lint is emitted outside of this function, if this function doesn't. I've cleared up the code/comments a bit, so it's more obvious :) r? ```@estebank```
2022-10-22Introduce subst_iter and subst_iter_copied on EarlyBinderMichael Goulet-7/+5
2022-10-21Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-deadDylan DPC-0/+1
Fixup a few tests needing asm support
2022-10-21Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errorsDylan DPC-23/+2
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use - Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing. - Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic. - Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc. cc #100717
2022-10-21Fix unreachable_pub suggestion for enum with fieldsKitsu-2/+6
2022-10-20Elaborate supertrait bounds when triggering unused_must_use on impl TraitMichael Goulet-2/+6
2022-10-19Fixup a few tests needing asm supportJosh Stone-0/+1
2022-10-17lint: use derive moreDavid Wood-23/+2
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-16Rollup merge of #102953 - WaffleLapkin:better_docs_for_decorate_param, ↵Matthias Krüger-0/+23
r=RalfJung Improve docs for `struct_lint_level` function. r? ``@RalfJung`` Does this answer your questions?
2022-10-14more dupe word typosRageking8-1/+1
2022-10-12link lint function with `decorate` function param to `struct_lint_level`Maybe Waffle-0/+23
2022-10-10errors: `AddToDiagnostic::add_to_diagnostic_with`David Wood-3/+12
`AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8KiDylan DPC-1/+1
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-1/+1
2022-10-09adopt to building infcxMaybe Waffle-24/+21
2022-10-09adopt to new rustc lint apiMaybe Waffle-15/+13
2022-10-09fixup lint nameMaybe Waffle-8/+8
2022-10-09fix `for_loop_over_fallibles` lint docsMaybe Waffle-22/+10
2022-10-09remove an infinite loopMaybe Waffle-2/+2
2022-10-09Edit documentation for `for_loop_over_fallibles` lintMaybe Waffle-23/+21