bors
4bc39f028d
Auto merge of #120924 - xFrednet:rfc-2383-stabilization-party, r=Urgau,blyxyas
...
Let's `#[expect]` some lints: Stabilize `lint_reasons` (RFC 2383)
Let's give this another try! The [previous stabilization attempt](https://github.com/rust-lang/rust/pull/99063 ) was stalled by some unresolved questions. These have been discussed in a [lang team](https://github.com/rust-lang/lang-team/issues/191 ) meeting. The last open question, regarding the semantics of the `#[expect]` attribute was decided on in https://github.com/rust-lang/rust/issues/115980
I've just updated the [stabilization report](https://github.com/rust-lang/rust/issues/54503#issuecomment-1179563964 ) with the discussed questions and decisions. Luckily, the decision is inline with the current implementation.
This hopefully covers everything. Let's hope that the CI will be green like the spring.
fixes #115980
fixes #54503
---
r? `@wesleywiser`
Tacking Issue: https://github.com/rust-lang/rust/issues/54503
Stabilization Report: https://github.com/rust-lang/rust/issues/54503#issuecomment-1179563964
Documentation Update: https://github.com/rust-lang/reference/pull/1237
<!--
For Clippy:
changelog: [`allow_attributes`]: Is now available on stable, since the `lint_reasons` feature was stabilized
changelog: [`allow_attributes_without_reason`]: Is now available on stable, since the `lint_reasons` feature was stabilized
-->
---
Roses are red,
Violets are blue,
Let's expect lints,
With reason clues
2024-06-26 16:38:30 +00:00
bors
31f8b70d2e
Auto merge of #126951 - matthiaskrgr:rollup-xg0o4mc, r=matthiaskrgr
...
Rollup of 7 pull requests
Successful merges:
- #126618 (Mark assoc tys live only if the corresponding trait is live)
- #126746 (Deny `use<>` for RPITITs)
- #126868 (not use offset when there is not ends with brace)
- #126884 (Do not ICE when suggesting dereferencing closure arg)
- #126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level)
- #126915 (Don't suggest awaiting in closure patterns)
- #126943 (De-duplicate all consecutive native libs regardless of their options)
r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-25 23:29:58 +00:00
Matthias Krüger
58bbade921
Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoerister
...
Detect unused structs which derived Default
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using
r? <reviewer name>
-->
Fixes #98871
2024-06-25 21:33:41 +02:00
Matthias Krüger
2724aeaaeb
Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
...
Mark assoc tys live only if the corresponding trait is live
r? ````@pnkfelix````
2024-06-25 18:02:58 +02:00
mu001999
6997b6876d
Detect unused structs which derived Default
2024-06-25 23:29:44 +08:00
xFrednet
8b14e23dce
RFC 2383: Stabilize lint_reasons 🎉
2024-06-25 17:22:22 +02:00
Michael Goulet
00e5f5886a
Rollup merge of #124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix
...
Show notice about "never used" of Debug for enum
Close #123068
If an ADT implements `Debug` trait and it is not used, the compiler says a note that indicates intentionally ignored during dead code analysis as [this note](https://github.com/rust-lang/rust/blob/2207179a591f5f252885a94ab014dafeb6e8e9e8/tests/ui/lint/dead-code/unused-variant.stderr#L9 ).
However this node is not shown for variants that have fields in enum. This PR fixes to show the note.
2024-06-24 15:51:00 -04:00
León Orell Valerian Liehr
96144c94af
Rollup merge of #124580 - gurry:124556-suggest-remove-tuple-field, r=jackh726
...
Suggest removing unused tuple fields if they are the last fields
Fixes #124556
We now check if dead/unused fields are the last fields of the tuple and suggest their removal instead of suggesting them to be changed to `()`.
2024-06-19 09:51:59 +02:00
mu001999
a264bff9d5
Mark assoc tys live only if the trait is live
2024-06-18 16:00:57 +08:00
long-long-float
d630f5da7a
Show notice about "never used" for enum
2024-06-16 18:33:51 +09:00
Matthias Krüger
977c5fd419
Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
...
Add pub struct with allow(dead_code) into worklist
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.
This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using
r? <reviewer name>
-->
Fixes #126289
2024-06-13 22:55:45 +02:00
r0cky
af106617f1
Detect pub structs never constructed even though they impl pub trait with assoc constants
2024-06-12 23:31:27 +08:00
r0cky
64450732be
Add pub struct with allow(dead_code) into worklist
2024-06-12 17:58:20 +08:00
r0cky
35130d7233
Detect pub structs never constructed and unused associated constants in traits
2024-06-05 23:20:09 +08:00
r0cky
96968350e1
Detect unused structs which implement private traits
2024-05-23 09:07:59 +08:00
Gurinder Singh
012a458dca
Suggest removing unused tuple fields if they are the last fields
2024-05-13 17:42:44 +05:30
Arthur Carcano
a0fe4138ed
Replace visibility test with reachability test in dead code detection
...
Fixes https://github.com/rust-lang/rust/issues/119545
2024-03-12 10:59:40 +01:00
r0cky
1299aa7c18
Detect unused struct impls pub trait
2024-03-10 23:30:53 +08:00
许杰友 Jieyou Xu (Joe)
ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives
2024-02-16 20:02:50 +00:00
r0cky
c7519d42c2
Update tests
2024-02-07 10:42:01 +08:00
r0cky
40878ca6ea
Make traits / trait methods detected by the dead code lint!
2024-02-07 10:22:16 +08:00
Matthew Jasper
4feec41e05
#![feature(inline_const_pat)] is no longer incomplete
2024-02-01 10:27:54 +00:00
George Bateman
615946db4f
Stabilize simple offset_of
2024-01-19 20:38:51 +00:00
Jake Goulding
d95d6ceecb
dead_code treats #[repr(transparent)] the same as #[repr(C)]
...
Fixes #119659
2024-01-18 13:04:31 -05:00
Jake Goulding
53eca9fa87
Adjust compiler tests for unused_tuple_struct_fields -> dead_code
2024-01-02 15:34:37 -05:00
Camille GILLOT
8bb74c0187
Pass DeadItem and lint as consistent group in dead-code.
2023-12-25 13:15:28 +00:00
Nilstrieb
41e8d152dc
Show number in error message even for one error
...
Co-authored-by: Adrian <adrian.iosdev@gmail.com >
2023-11-24 19:15:52 +01:00
Urgau
d801a2ff15
Respect #[expect] the same way #[allow] is with the dead_code lint
2023-08-10 22:57:48 +02:00
DrMeepster
a642563d49
major test improvements
2023-04-21 02:45:48 -07:00
DrMeepster
f92294f76b
bless
2023-04-21 02:14:03 -07:00
DrMeepster
2bcb018253
fmt
2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c
fix incorrect param env in dead code lint
2023-04-21 02:14:03 -07:00
Eric Huss
d7ed5a52ff
Unignore closure-bang.
...
This test was ignored long ago in
https://github.com/rust-lang/rust/pull/20578/ when the syntax for
closures was changed.
The current status is that a closure with an explicit `!` return type
will trigger the `unreachable_code` lint which appears to be the
original intent of the test
(https://github.com/rust-lang/rust/pull/16836 ). A closure without a
return type won't trigger the lint since the `!` type isn't inferred
(AFAIK). This restores the test to its original form.
2023-04-15 14:43:20 -07:00
Ezra Shaw
39e23ef532
impl reviewer feedback
...
- remove unused (pun intentional) `continue`
- improve wording with assoc items in general
2023-04-13 23:39:14 +12:00
Ezra Shaw
c41dcac8e8
dead-code-lint: de-dup multiple unused assoc fns
2023-04-13 22:42:47 +12:00
Ezra Shaw
03cf0e949f
refactor: emit "unused assoc fn" in lexical order
...
with repect to other dead code lints
2023-04-13 20:53:32 +12:00
Yuki Okushi
06ec5faccb
Add regression test for #59003
...
Signed-off-by: Yuki Okushi <jtitor@2k36.org >
2023-04-12 06:24:49 +09:00
bors
0978711950
Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
...
diagnostics: if AssocFn has self argument, describe as method
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515
This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods >
> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html ), for example, `x.foo()`, as well as the usual function call notation.
In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
Michael Howell
3f374128ee
diagnostics: update test cases to refer to assoc fn with self as method
2023-02-22 08:40:47 -07:00
clubby789
c7a4f387fd
Lint dead code in closures
2023-02-22 15:27:19 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests
2023-01-11 09:32:08 +00:00