Commit Graph

57 Commits

Author SHA1 Message Date
Michael Goulet
ec79720c1e Add async_fn_in_trait lint 2023-10-03 00:37:18 +00:00
bors
635c4a5e61 Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726
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-09-16 03:40:20 +00:00
Weihang Lo
a11805ae46
feat(rustc_lint): make CheckLintName respect lint level 2023-08-30 19:24:44 +01:00
Weihang Lo
81a24922e7
lint: translate RenamedOrRemovedLint 2023-08-24 01:09:46 +01:00
Urgau
aa7730003e Improve note for the invalid_reference_casting lint
Add link to the book interior mutability chapter,
https://doc.rust-lang.org/book/ch15-05-interior-mutability.html.
2023-08-23 11:27:33 +02:00
est31
4b1bc27010 Improve diagnostics and add tests for function calls 2023-08-06 19:08:14 +02:00
Matthias Krüger
cd5317a000
Rollup merge of #114472 - estebank:issue-76140, r=compiler-errors
Reword `confusable_idents` lint

Fix #76140.
2023-08-04 21:31:59 +02:00
Esteban Küber
553508c22e Reword confusable idents lint
Fix #76140.
2023-08-04 16:46:08 +00:00
bors
ec5b882c2f Auto merge of #114414 - cjgillot:early-unnameable-test, r=petrochenkov
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-04 14:13:11 +00:00
bors
1fe384649a Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk
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-03 22:58:02 +00:00
Matthias Krüger
7518ae566e
Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillot
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-03 17:29:06 +02:00
Camille GILLOT
2a0a1f918d Make test harness lint about unnnameable tests. 2023-08-03 13:07:30 +00:00
Nilstrieb
5830ca216d Add internal_features lint
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-03 14:50:50 +02:00
Urgau
ee519532f6 Also add label with original type for function pointers 2023-08-03 10:57:11 +02:00
Urgau
d2b7c8028f Rename incorrect_fn_null_checks to useless_ptr_null_checks 2023-08-01 19:35:31 +02:00
Urgau
743ae5a2eb Expand incorrect_fn_null_check lint with reference null checking 2023-08-01 19:35:31 +02:00
Urgau
20a6b57106 Improve diagnostics of the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
Urgau
f3dafe91ff Add support for deferred casting for the invalid_reference_casting lint 2023-07-29 12:20:59 +02:00
bors
04411507be Auto merge of #113422 - Urgau:cast_ref_to_mut-pre-beta, r=Nilstrieb
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-29 07:48:44 +00:00
bors
4734ac0943 Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors
make `noop_method_call` warn by default

r? `@compiler-errors`
2023-07-29 01:40:50 +00:00
Deadbeef
2a76c570d6 add suggestion 2023-07-23 09:58:31 +00:00
Deadbeef
626efab67f fix 2023-07-23 09:58:31 +00:00
David Wood
99b1897cf6
lint: refactor check_variant_for_ffi
Simplify this function a bit, it was quite hard to reason about.

Signed-off-by: David Wood <david@davidtw.co>
2023-07-19 09:55:10 +01:00
Urgau
3dbbf23e29 Rename cast_ref_to_mut lint to invalid_reference_casting 2023-07-13 23:01:24 +02:00
Urgau
f6d2bf63d3 Uplift clippy::fn_null_check to rustc 2023-07-10 18:12:41 +02:00
Guillaume Gomez
db7d8374c1
Rollup merge of #112517 - fee1-dead-contrib:sus-op-no-borrow, r=compiler-errors
`suspicious_double_ref_op`: don't lint on `.borrow()`

closes #112489
2023-06-15 22:04:55 +02:00
Deadbeef
1caed51673 do not use stringly typed diagnostics 2023-06-13 13:53:56 +00:00
Nicky Lim
6033895ec2 Add subdiagnostic and suggestion for overflowing bin hex with sign bits 2023-06-11 18:27:26 +08:00
Urgau
3e91349c42 Uplift improved version of clippy::cmp_nan to rustc 2023-06-10 11:12:55 +02:00
Urgau
52300bf8d8 Uplift clippy::undropped_manually_drops to rustc 2023-06-08 11:41:34 +02:00
Urgau
5da606779c Uplift clippy::cast_ref_to_mut to rustc 2023-05-31 12:28:38 +02:00
Urgau
7f99c7d3e6 Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked 2023-05-27 00:18:28 +02:00
Urgau
7f8846a9ef Uplift clippy::invalid_utf8_in_unchecked as invalid_from_utf8_unchecked 2023-05-27 00:16:47 +02:00
clubby789
f97fddab91 Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
Urgau
6b08a745a4 Rename forget_ref lint to forgetting_references 2023-05-21 14:28:09 +02:00
Urgau
c93d9c1794 Rename drop_ref lint to dropping_references 2023-05-21 14:16:41 +02:00
Urgau
85a1828943 Rename forget_copy lint to forgetting_copy_types 2023-05-21 14:09:03 +02:00
Urgau
1c7ab18c08 Rename drop_copy lint to dropping_copy_types 2023-05-21 13:37:32 +02:00
Urgau
e280df556d Add note to suggest using let _ = x to ignore the value 2023-05-10 19:36:02 +02:00
Urgau
d23f8957ae Improve warning message by saying that it "does nothing" 2023-05-10 19:36:02 +02:00
Urgau
457fa953a2 Use label instead of note to be more consistent with other lints 2023-05-10 19:36:02 +02:00
Urgau
971b9b23b5 Uplift clippy::forget_copy to rustc 2023-05-10 19:36:01 +02:00
Urgau
1ef9c163aa Uplift clippy::forget_ref to rustc 2023-05-10 19:36:01 +02:00
Urgau
156f5563c7 Uplift clippy::drop_copy to rustc 2023-05-10 19:36:01 +02:00
Urgau
28cdbc2a64 Uplift clippy::drop_ref to rustc 2023-05-10 19:36:01 +02:00
Deadbeef
475378f0c6 add match to diagnostic messages 2023-04-29 15:47:23 +00:00
Deadbeef
5c99175a9e uplift clippy::clone_double_ref as suspicious_double_ref_op 2023-04-28 17:24:48 +00:00
clubby789
eeb527602a Add deny lint to prevent untranslatable diagnostics using static strings 2023-04-25 18:44:49 +01:00
kadiwa
85653831f7
typos 2023-04-17 09:16:07 +02:00
DaniPopes
677357d32b
Fix typos in compiler 2023-04-10 22:02:52 +02:00