about summary refs log tree commit diff
path: root/compiler/rustc_lint/messages.ftl
AgeCommit message (Collapse)AuthorLines
2023-12-06Add warn-by-default lint against ambiguous wide pointer comparisonsUrgau-0/+4
2023-11-22Rework supertrait lint once againMichael Goulet-1/+2
2023-11-22Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkinbors-2/+3
Stabilize RFC3324 dyn upcasting coercion This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324. The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398. ~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~ Heavily inspired by https://github.com/rust-lang/rust/pull/101718 Fixes https://github.com/rust-lang/rust/issues/65991
2023-11-22Auto merge of #112380 - jieyouxu:useless-bindings-lint, r=WaffleLapkinbors-0/+3
Add allow-by-default lint for unit bindings ### Example ```rust #![warn(unit_bindings)] macro_rules! owo { () => { let whats_this = (); } } fn main() { // No warning if user explicitly wrote `()` on either side. let expr = (); let () = expr; let _ = (); let _ = expr; //~ WARN binding has unit type let pat = expr; //~ WARN binding has unit type let _pat = expr; //~ WARN binding has unit type // No warning for let bindings with unit type in macro expansions. owo!(); // No warning if user explicitly annotates the unit type on the binding. let pat: () = expr; } ``` outputs ``` warning: binding has unit type `()` --> $DIR/unit-bindings.rs:17:5 | LL | let _ = expr; | ^^^^-^^^^^^^^ | | | this pattern is inferred to be the unit type `()` | note: the lint level is defined here --> $DIR/unit-bindings.rs:3:9 | LL | #![warn(unit_bindings)] | ^^^^^^^^^^^^^ warning: binding has unit type `()` --> $DIR/unit-bindings.rs:18:5 | LL | let pat = expr; | ^^^^---^^^^^^^^ | | | this pattern is inferred to be the unit type `()` warning: binding has unit type `()` --> $DIR/unit-bindings.rs:19:5 | LL | let _pat = expr; | ^^^^----^^^^^^^^ | | | this pattern is inferred to be the unit type `()` warning: 3 warnings emitted ``` This lint is not triggered if any of the following conditions are met: - The user explicitly annotates the binding with the `()` type. - The binding is from a macro expansion. - The user explicitly wrote `let () = init;` - The user explicitly wrote `let pat = ();`. This is allowed for local lifetimes. ### Known Issue It is known that this lint can trigger on some proc-macro generated code whose span returns false for `Span::from_expansion` because e.g. the proc-macro simply forwards user code spans, and otherwise don't have distinguishing syntax context compared to non-macro-generated code. For those kind of proc-macros, I believe the correct way to fix them is to instead emit identifers with span like `Span::mixed_site().located_at(user_span)`. Closes #71432.
2023-11-22Stabilize RFC3324 dyn upcasting coercionUrgau-2/+3
Aka trait_upcasting feature. And also adjust the `deref_into_dyn_supertrait` lint.
2023-11-20Add allow-by-default lint for unit bindings许杰友 Jieyou Xu (Joe)-0/+3
This lint is not triggered if any of the following conditions are met: - The user explicitly annotates the binding with the `()` type. - The binding is from a macro expansion. - The user explicitly wrote `let () = init;` - The user explicitly wrote `let pat = ();`. This is allowed for local lifetimes.
2023-11-18Remove --check-cfg checking of --cfg argsUrgau-6/+0
2023-10-20s/generator/coroutine/Oli Scherer-7/+7
2023-10-16debug Span::ctxt() call detectionArthur Lafrance-1/+1
2023-10-16basic lint v2 implementedArthur Lafrance-0/+2
2023-10-13Fix AFIT lint message to mention pitfallMichael Goulet-1/+1
2023-10-06Rollup merge of #116421 - Urgau:inter-mut-invalid_ref_casting, r=oli-obkMatthias Krüger-0/+2
Clarify `invalid_reference_casting` lint around interior mutable types This is PR intends to clarify the `invalid_reference_casting` lint around interior mutable types by adding a note for them saying that they should go through `UnsafeCell::get`. So for this code: ```rust let cell = &std::cell::UnsafeCell::new(0); let _num = &mut *(cell as *const _ as *mut i32); ``` the following note will be added to the lint output: ```diff error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:68:16 | LL | let _num = &mut *(cell as *const _ as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + = note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get` ``` Suggestion are welcome around the note contents. Fixes https://github.com/rust-lang/rust/issues/116410 cc `@RalfJung`
2023-10-04Clarify `invalid_reference_casting` lint around interior mutable typesUrgau-0/+2
2023-10-03Address review nitsMichael Goulet-1/+1
2023-10-03Fill in prose to describe the `async_fn_in_trait` lintTravis Cross-3/+3
We're stabilizing `async fn` in trait (AFIT), but we have some reservations about how people might use this in the definitions of publicly-visible traits, so we're going to lint about that. This is a bit of an odd lint for `rustc`. We normally don't lint just to have people confirm that they understand how Rust works. But in this one exceptional case, this seems like the right thing to do as compared to the other plausible alternatives. In this commit, we describe the nature of this odd lint.
2023-10-03Add async_fn_in_trait lintMichael Goulet-0/+4
2023-09-16Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726bors-0/+2
Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR #113657 Fixes #114442
2023-08-30feat(rustc_lint): make `CheckLintName` respect lint levelWeihang Lo-9/+2
2023-08-24lint: translate `RenamedOrRemovedLint`Weihang Lo-3/+8
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-06Improve diagnostics and add tests for function callsest31-0/+2
2023-08-04Rollup merge of #114472 - estebank:issue-76140, r=compiler-errorsMatthias Krüger-2/+3
Reword `confusable_idents` lint Fix #76140.
2023-08-04Reword confusable idents lintEsteban Küber-2/+3
Fix #76140.
2023-08-04Auto merge of #114414 - cjgillot:early-unnameable-test, r=petrochenkovbors-2/+0
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-03Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obkbors-0/+3
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.
2023-08-03Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillotMatthias Krüger-3/+7
Expand, rename and improve `incorrect_fn_null_checks` lint This PR, - firstly, expand the lint by now linting on references - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks` - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut` Fixes https://github.com/rust-lang/rust/issues/113601 cc ```@est31```
2023-08-03Make test harness lint about unnnameable tests.Camille GILLOT-2/+0
2023-08-03Add `internal_features` lintNilstrieb-0/+3
It lints against features that are inteded to be internal to the compiler and standard library. Implements MCP #596. We allow `internal_features` in the standard library and compiler as those use many features and this _is_ the standard library from the "internal to the compiler and standard library" after all. Marking some features as internal wasn't exactly the most scientific approach, I just marked some mostly obvious features. While there is a categorization in the macro, it's not very well upheld (should probably be fixed in another PR). We always pass `-Ainternal_features` in the testsuite About 400 UI tests and several other tests use internal features. Instead of throwing the attribute on each one, just always allow them. There's nothing wrong with testing internal features^^
2023-08-03Also add label with original type for function pointersUrgau-0/+1
2023-08-01Rename incorrect_fn_null_checks to useless_ptr_null_checksUrgau-6/+6
2023-08-01Expand incorrect_fn_null_check lint with reference null checkingUrgau-1/+4
2023-07-29Improve diagnostics of the invalid_reference_casting lintUrgau-1/+4
2023-07-29Add support for deferred casting for the invalid_reference_casting lintUrgau-0/+1
2023-07-29Auto merge of #113422 - Urgau:cast_ref_to_mut-pre-beta, r=Nilstriebbors-2/+2
Rename and allow `cast_ref_to_mut` lint This PR is a small subset of https://github.com/rust-lang/rust/pull/112431, that is the renaming of the lint (`cast_ref_to_mut` -> `invalid_reference_casting`). BUT also temporarily change the default level of the lint from deny-by-default to allow-by-default until https://github.com/rust-lang/rust/pull/112431 is merged. r? `@Nilstrieb`
2023-07-29Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, ↵bors-2/+2
r=compiler-errors make `noop_method_call` warn by default r? `@compiler-errors`
2023-07-23add suggestionDeadbeef-1/+1
2023-07-23fixDeadbeef-1/+1
2023-07-19lint: refactor `check_variant_for_ffi`David Wood-2/+0
Simplify this function a bit, it was quite hard to reason about. Signed-off-by: David Wood <david@davidtw.co>
2023-07-13Rename cast_ref_to_mut lint to invalid_reference_castingUrgau-2/+2
2023-07-10Uplift `clippy::fn_null_check` to rustcUrgau-0/+3
2023-06-15Rollup merge of #112517 - fee1-dead-contrib:sus-op-no-borrow, r=compiler-errorsGuillaume Gomez-7/+5
`suspicious_double_ref_op`: don't lint on `.borrow()` closes #112489
2023-06-13do not use stringly typed diagnosticsDeadbeef-7/+5
2023-06-11Add subdiagnostic and suggestion for overflowing bin hex with sign bitsNicky Lim-0/+1
2023-06-10Uplift improved version of `clippy::cmp_nan` to rustcUrgau-0/+5
2023-06-08Uplift clippy::undropped_manually_drops to rustcUrgau-0/+4
2023-05-31Uplift clippy::cast_ref_to_mut to rustcUrgau-0/+2
2023-05-27Add invalid_from_utf8 analogous to invalid_from_utf8_uncheckedUrgau-0/+4
2023-05-27Uplift clippy::invalid_utf8_in_unchecked as invalid_from_utf8_uncheckedUrgau-0/+4
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-371/+370
2023-05-21Rename `forget_ref` lint to `forgetting_references`Urgau-1/+1