about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2023-09-03Emit unused doc comment warnings for pat and expr fieldsGurinder Singh-0/+14
2023-09-01Rollup merge of #115424 - notriddle:notriddle/issue-106413, r=oli-obkMatthias Krüger-1/+30
diagnostics: avoid wrong `unused_parens` on `x as (T) < y` Fixes #106413 Fixes #80636
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-0/+5
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-08-31Use terminology more sensiblyMichael Howell-1/+1
2023-08-31diagnostics: avoid wrong `unused_parens` on `x as (T) < y`Michael Howell-1/+30
2023-08-30feat(rustc_lint): make `CheckLintName` respect lint levelWeihang Lo-109/+97
2023-08-30refactor(rustc_lint): inline `check_lint_name_cmdline`Weihang Lo-70/+62
2023-08-29some more is_zst that should be is_1zstRalf Jung-3/+3
2023-08-24Rollup merge of #115152 - weihanglo:lint-refactor, r=compiler-errorsWeihang Lo-51/+77
refactor(lint): translate `RenamedOrRemovedLint` I was trying to address <https://github.com/rust-lang/cargo/issues/12495> and found that maybe I should refactor relevant lints a bit. This PR translates `RenamedOrRemovedLint` into fluent file. To make diagnostic types clearer and easier to organize, this PR splits it into two structs. The second commit adds lifetime annotations for removing unnecessary clones. If people feel too noisy, we can revert such change. ### Possibly relevant UI tests: * `tests/ui/lint-removed*` * `tests/ui/lint-renamed*` * `tests/ui/rustdoc-renamed.rs` * `tests/rustdoc-ui/lints/unknown-renamed-lints.rs`
2023-08-24Lint on invalid UnsafeCell::raw_get with invalid_reference_casting lintUrgau-5/+39
2023-08-24Auto merge of #115094 - Mark-Simulacrum:bootstrap-update, r=ozkanonurbors-1/+1
Update bootstrap compiler to 1.73.0 beta
2023-08-24refactor: use references to reduce unnecessary clonesWeihang Lo-28/+27
2023-08-24lint: translate `RenamedOrRemovedLint`Weihang Lo-34/+61
2023-08-23Bump cfg(bootstrap)Mark Rousskov-1/+1
2023-08-23Improve note for the invalid_reference_casting lintUrgau-0/+2
Add link to the book interior mutability chapter, https://doc.rust-lang.org/book/ch15-05-interior-mutability.html.
2023-08-23Rollup merge of #115100 - Urgau:invalid_ref_casting-ptr-writes, r=est31Dylan DPC-17/+47
Add support for `ptr::write`s for the `invalid_reference_casting` lint This PR adds support for `ptr::write` and others for the `invalid_reference_casting` lint. Detecting instances where instead of using the deref (`*`) operator to assign someone uses `ptr::write`, `ptr::write_unaligned` or `ptr::write_volatile`. ```rust let data_len = 5u64; std::ptr::write( std::mem::transmute::<*const u64, *mut u64>(&data_len), new_data_len, ); ``` r? ``@est31``
2023-08-22Rollup merge of #115011 - compiler-errors:warn-on-elided-assoc-ct-lt, r=cjgillotMichael Goulet-0/+8
Warn on elided lifetimes in associated constants (`ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT`) Elided lifetimes in associated constants (in impls) erroneously resolve to fresh lifetime parameters on the impl since #97313. This is not correct behavior (see #38831). I originally opened #114716 to fix this, but given the time that has passed, the crater results seem pretty bad: https://github.com/rust-lang/rust/pull/114716#issuecomment-1682091952 This PR alternatively implements a lint against this behavior, and I'm hoping to bump this to deny in a few versions.
2023-08-22Add support for ptr::write for the invalid_reference_casting lintUrgau-17/+47
2023-08-22unknown unstable lint command linemojave2-10/+18
fix ##113702 fix #113702 unknown unstable lint command lint improve impelementation
2023-08-20Warn on elided lifetimes in associated constantsMichael Goulet-0/+8
2023-08-16Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, ↵Matthias Krüger-18/+31
r=est31 Improve `invalid_reference_casting` lint This PR improves the `invalid_reference_casting` lint: - by considering an unlimited number of casts instead only const to mut ptr - by also considering ptr-to-integer and integer-to-ptr casts - by also taking into account [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast), [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast-1) and [`ptr::cast_const`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast_const) Most of this improvements comes from skimming Github Code Search result for [`&mut \*.*as \*const`](https://github.com/search?q=lang%3Arust+%2F%26mut+%5C*.*as+%5C*const%2F&type=code) r? ``@est31`` (maybe)
2023-08-15Rollup merge of #114772 - fee1-dead-contrib:typed-did, r=b-naberGuillaume Gomez-5/+5
Add `{Local}ModDefId` to more strongly type DefIds` Based on #110862 by `@Nilstrieb`
2023-08-15Improve `invalid_reference_casting` lintUrgau-18/+31
2023-08-14match scrutinee need necessary parentheses for structsyukang-0/+18
2023-08-14Use `{Local}ModDefId` in many queriesNilstrieb-5/+5
2023-08-13Auto merge of #114757 - Urgau:transmute-with-invalid_reference_casting, r=est31bors-24/+48
Also consider `mem::transmute` with the `invalid_reference_casting` lint This PR extend the `invalid_reference_casting` lint with regard to the `std::mem::transmute` function. ``` error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:27:16 | LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(&num); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` *I encourage anyone reviewing this PR to do so [without whitespaces](https://github.blog/2011-10-21-github-secrets/#whitespace).*
2023-08-13Auto merge of #114723 - petrochenkov:noplugin2, r=davidtwcobors-3/+19
rustc: Move `features` from `Session` to `GlobalCtxt` Removes one more piece of mutable state. Follow up to #114622. The rule I used for passing feature in function signatures: - if a crate already depends on `rustc_middle`, then `Session` is replaced with `TyCtxt` - otherwise session and features are passed as a pair `sess: &Session, features: &Features` The code in `rustc_lint` is ultimately used for implementing a trait from `rustc_expand`, so it also doesn't use tcx despite the dependency on `rustc_middle`.
2023-08-12Also consider `transmute` with the `invalid_reference_casting` lintUrgau-24/+48
2023-08-11rustc: Move `features` from `Session` to `GlobalCtxt`Vadim Petrochenkov-3/+19
Removes two pieces of mutable state. Follow up to #114622.
2023-08-10downgrade internal_features to warnlcnr-2/+2
2023-08-06Improve diagnostics and add tests for function callsest31-23/+31
2023-08-06Rollup merge of #114486 - Urgau:const-context-nan-suggestion-114471, ↵Matthias Krüger-6/+10
r=compiler-errors Avoid invalid NaN lint machine-applicable suggestion in const context This PR removes the machine-applicable suggestion in const context for the `invalid_nan_comparision` lint ~~and replace it with a simple help~~. Fixes https://github.com/rust-lang/rust/issues/114471
2023-08-05Add FIXME as reminder to restore suggestion laterMichael Goulet-0/+1
2023-08-05Avoid invalid NaN lint machine-applicable suggestion in const contextUrgau-6/+9
2023-08-05Rollup merge of #114248 - fmease:neg-copy-rules-out-missing-copy-impl, r=b-naberMatthias Krüger-0/+23
Make lint missing-copy-implementations honor negative `Copy` impls Fixes #101980. ``@rustbot`` label A-lint F-negative_impls
2023-08-05Auto merge of #113734 - cjgillot:no-crate-lint, r=petrochenkovbors-512/+494
Convert builtin "global" late lints to run per module The compiler currently has 4 non-incremental lints: 1. `clashing_extern_declarations`; 2. `missing_debug_implementations`; 3. ~`unnameable_test_items`;~ changed by https://github.com/rust-lang/rust/pull/114414 4. `missing_docs`. Non-incremental lints get reexecuted for each compilation, which is slow. Moreover, those lints are allow-by-default, so run for nothing most of the time. This PR attempts to make them more incremental-friendly. `clashing_extern_declarations` is moved to a standalone query. `missing_debug_implementation` can use `non_blanket_impls_for_ty` instead of recomputing it. `missing_docs` is harder as it needs to track if there is a `doc(hidden)` module surrounding. I hack around this using the lint level engine. That's easy to implement and allows to re-enable the lint for a re-exported module, while a more proper solution would reuse the same device as `unnameable_test_items`.
2023-08-05Add #[rustc_never_returns_null_ptr]est31-1/+1
And look for it in the useless_ptr_null_checks lint
2023-08-04Auto merge of #112117 - bryangarza:track-caller-feature-gate, r=compiler-errorsbors-7/+7
Add separate feature gate for async fn track caller This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-08-04Rollup merge of #114472 - estebank:issue-76140, r=compiler-errorsMatthias Krüger-1/+4
Reword `confusable_idents` lint Fix #76140.
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-2/+2
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Reword confusable idents lintEsteban Küber-1/+4
Fix #76140.
2023-08-04Fetch diagnostic item later.Camille GILLOT-2/+2
2023-08-04Make rustc internal lints per module.Camille GILLOT-7/+7
2023-08-04Make MissingDoc a module lint.Camille GILLOT-71/+38
2023-08-04Make MissingDebugImplementation a module lint.Camille GILLOT-22/+14
2023-08-04Simplify clashing_extern_declarations.Camille GILLOT-270/+263
2023-08-04Querify clashing_extern_declarations lint.Camille GILLOT-410/+440
2023-08-04Auto merge of #114414 - cjgillot:early-unnameable-test, r=petrochenkovbors-83/+1
Make test harness lint about unnnameable tests. Implementation of https://github.com/rust-lang/rust/pull/113734#discussion_r1283073418 About the options suggested in https://github.com/rust-lang/rust/issues/36629#issuecomment-404753945: adding this case to unused_attribute was just more complicated. I'll try to understand a bit more what you had in mind in https://github.com/rust-lang/rfcs/pull/2471#issuecomment-397241123 This was just simpler to do in a standalone PR. I'll remove the corresponding changes from https://github.com/rust-lang/rust/pull/113734 later. r? `@petrochenkov`
2023-08-04Improve spans for indexing expressionsNilstrieb-2/+2
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-03Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obkbors-16/+59
Add `internal_features` lint Implements https://github.com/rust-lang/compiler-team/issues/596 Also requires some more test blessing for codegen tests etc `@jyn514` had the idea of just `allow`ing the lint by default in the test suite. I'm not sure whether this is a good idea, but it's definitely one worth considering. Additional input encouraged.