Commit Graph

847 Commits

Author SHA1 Message Date
bors
cb93c24bf3 Auto merge of #124157 - wutchzone:partial_eq, r=estebank
Do not add leading asterisk in the `PartialEq`

I think we should address this issue, however I am not exactly sure, if this is the right way to do it. It is related to the #123056.

Imagine the simplified code:

```rust
trait MyTrait {}

impl PartialEq for dyn MyTrait {
    fn eq(&self, _other: &Self) -> bool {
        true
    }
}

#[derive(PartialEq)]
enum Bar {
    Foo(Box<dyn MyTrait>),
}
```

On the nightly compiler, the `derive` produces invalid code with the weird error message:
```
error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
  --> src/main.rs:11:9
   |
9  | #[derive(PartialEq)]
   |          --------- in this derive macro expansion
10 | enum Things {
11 |     Foo(Box<dyn MyTrait>),
   |         ^^^^^^^^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn MyTrait>`, which does not implement the `Copy` trait
   |
   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
```

It may be related to the perfect derive problem, although requiring the _type_ to be `Copy` seems unfortunate because it is not necessary. Besides, we are adding the extra dereference only for the diagnostics?
2024-05-09 08:34:14 +00:00
Matthias Krüger
d30af5e168
Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=Nilstrieb
Remove braces when fixing a nested use tree into a single item

[Back in 2019](https://github.com/rust-lang/rust/pull/56645) I added rustfix support for the `unused_imports` lint, to automatically remove them when running `cargo fix`. For the most part this worked great, but when removing all but one childs of a nested use tree it turned `use foo::{Unused, Used}` into `use foo::{Used}`. This is slightly annoying, because it then requires you to run `rustfmt` to get `use foo::Used`.

This PR automatically removes braces and the surrouding whitespace when all but one child of a nested use tree are unused. To get it done I had to add the span of the nested use tree to the AST, and refactor a bit the code I wrote back then.

A thing I noticed is, there doesn't seem to be any `//@ run-rustfix` test for fixing the `unused_imports` lint. I created a test in `tests/suggestions` (is that the right directory?) that for now tests just what I added in the PR. I can followup in a separate PR to add more tests for fixing `unused_lints`.

This PR is best reviewed commit-by-commit.
2024-05-08 23:33:24 +02:00
Nilstrieb
1572c0dcd7 Various improvements to entrypoint code
This moves some code around and adds some documentation comments to make
it easier to understand what's going on with the entrypoint logic, which
is a bit complicated.

The only change in behavior is consolidating the error messages for
unix_sigpipe to make the code slightly simpler.
2024-05-04 14:48:42 +02:00
Nicholas Nethercote
a74a272a5b Use parse renaming of rustc_parse_format.
This is a case where `rustc_parse_format` is renamed as `parse` but a
couple of places don't take advantage.
2024-05-03 16:03:15 +10:00
Nicholas Nethercote
6341935a13 Remove extern crate tracing from numerous crates. 2024-04-30 16:47:49 +10:00
Matthias Krüger
cf07246ae9
Rollup merge of #124382 - petrochenkov:itemvisit, r=lcnr
ast: Generalize item kind visiting

And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).

The diff is better viewed with whitespace ignored.
2024-04-27 07:55:37 +02:00
Jacob Pratt
608f71ec66
Rollup merge of #124391 - nnethercote:builtin_macros-cleanups, r=fee1-dead
`rustc_builtin_macros` cleanups

Some improvements I found while looking over this code.

r? ``@fee1-dead``
2024-04-26 19:25:55 -04:00
Nicholas Nethercote
30d6f63b4e Adjust some pubs. 2024-04-26 13:29:20 +10:00
Nicholas Nethercote
8dc84fa7d1 Move some functions from rustc_expand to rustc_builtin_macros.
These functions are only used in `rustc_builtin_macros`, so it makes
sense for them to live there. This allows them to be changed from `pub`
to `pub(crate)`.
2024-04-26 09:24:33 +10:00
Nicholas Nethercote
e2d2b1c698 Introduce DeriveResolution.
Making this a proper struct, and giving its fields names, makes things
easier to understand.
2024-04-26 07:55:21 +10:00
Vadim Petrochenkov
5be9fdd636 ast: Generalize item kind visiting
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-25 22:49:58 +03:00
Nicholas Nethercote
11e95d43ae Name the field in Expander.
For code clarity.
2024-04-25 15:18:07 +10:00
Daniel Sedlak
c2a0ef65da Do not add leading asterisk in the PartialEq
Adding leading asterisk can cause compilation failure for
the _types_ that don't implement the `Copy`.
2024-04-23 20:56:52 +02:00
Daniel Sedlak
5a6e995980 Fix typos 2024-04-23 20:06:04 +02:00
Xiretza
5646b65cf5 Pass translation closure to add_to_diag_with() as reference 2024-04-21 07:45:03 +00:00
Jules Bertholet
2a4624ddd1
Rename BindingAnnotation to BindingMode 2024-04-17 09:34:39 -04:00
Nicholas Nethercote
27374a0214 Avoid unnecessary rustc_span::DUMMY_SP usage.
In some cases `DUMMY_SP` is already imported. In other cases this commit
adds the necessary import, in files where `DUMMY_SP` is used more than
once.
2024-04-16 15:55:24 +10:00
Pietro Albini
13f76235b3
store the span of the nested part of the use tree in the ast 2024-04-14 18:45:28 +02:00
Ralf Jung
ec3ac1dcd6 builtin-derive: tag → discriminant 2024-04-14 11:34:15 +02:00
Matthias Krüger
ffea7e2a9b
Rollup merge of #123204 - notriddle:notriddle/include-str-span, r=pnkfelix
rustdoc: point at span in `include_str!`-ed md file

Fixes #118549
2024-04-12 17:41:32 +02:00
Matthias Krüger
f9ca213510 remove some things that do not need to be 2024-04-11 21:09:52 +02:00
Oli Scherer
c340e67dec Add pattern types to parser 2024-04-08 11:57:17 +00:00
beetrees
0bbaa2505b
Fix error message for env! when env var is not valid Unicode 2024-04-01 05:44:45 +01:00
Michael Howell
98642da6a9 rustdoc: point at span in include_str!-ed md file 2024-03-29 13:31:35 -07:00
klensy
afd0a8eb8f change BuiltinDeriveFn type to get ExtCtxt by immutable ref and fix signatures 2024-03-28 12:49:18 +03:00
klensy
615bb53a8d compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\clone.rs:160:9
    |
160 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\partial_ord.rs:72:9
   |
72 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\partial_eq.rs:19:18
   |
19 |     fn cs_eq(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                  ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\ord.rs:42:19
   |
42 | pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                   ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:917:13
    |
917 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1406:13
     |
1406 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1157:13
     |
1157 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1103:13
     |
1103 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1080:13
     |
1080 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:859:13
    |
859 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:805:13
    |
805 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:467:13
    |
467 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:457:13
    |
457 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:36:45 +03:00
klensy
ecb39926d8 compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\mod.rs:120:9
    |
120 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1573:13
     |
1573 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1556:13
     |
1556 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1463:13
     |
1463 |         cx: &mut ExtCtxt<'_>,
     |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
    --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:1433:36
     |
1433 |     fn summarise_struct(&self, cx: &mut ExtCtxt<'_>, struct_def: &VariantData) -> StaticFields {
     |                                    ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:953:13
    |
953 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:932:13
    |
932 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:580:13
    |
580 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\generic\mod.rs:989:13
    |
989 |         cx: &mut ExtCtxt<'_>,
    |             ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\clone.rs:97:9
   |
97 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\cmp\eq.rs:52:9
   |
52 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\hash.rs:50:9
   |
50 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\encodable.rs:150:9
    |
150 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\default.rs:176:9
    |
176 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\default.rs:106:9
    |
106 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\default.rs:57:9
   |
57 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\default.rs:84:9
   |
84 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\deriving\debug.rs:212:9
    |
212 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\deriving\debug.rs:48:26
   |
48 | fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> BlockOrExpr {
   |                          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:16:08 +03:00
klensy
316bc1c67c compiler: fix few needless_pass_by_ref_mut clippy lints
warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\asm.rs:306:28
    |
306 | fn err_duplicate_option(p: &mut Parser<'_>, symbol: Symbol, span: Span) {
    |                            ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\asm.rs:318:8
    |
318 |     p: &mut Parser<'a>,
    |        ^^^^^^^^^^^^^^^ help: consider changing to: `&Parser<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\assert.rs:114:25
    |
114 | fn parse_assert<'a>(cx: &mut ExtCtxt<'a>, sp: Span, stream: TokenStream) -> PResult<'a, Assert> {
    |                         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\asm.rs:32:10
   |
32 |     ecx: &mut ExtCtxt<'a>,
   |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\test.rs:99:9
   |
99 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\source_util.rs:237:9
    |
237 |     cx: &mut ExtCtxt<'_>,
    |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:809:10
    |
809 |     ecx: &mut ExtCtxt<'_>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:737:10
    |
737 |     ecx: &mut ExtCtxt<'a>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\format.rs:68:24
   |
68 | fn parse_args<'a>(ecx: &mut ExtCtxt<'a>, sp: Span, tts: TokenStream) -> PResult<'a, MacroInput> {
   |                        ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
   --> compiler\rustc_builtin_macros\src\format.rs:607:10
    |
607 |     ecx: &mut ExtCtxt<'_>,
    |          ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\edition_panic.rs:43:9
   |
43 |     cx: &'cx mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\concat_bytes.rs:11:9
   |
11 |     cx: &mut ExtCtxt<'_>,
   |         ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\cfg.rs:38:22
   |
38 | fn parse_cfg<'a>(cx: &mut ExtCtxt<'a>, span: Span, tts: TokenStream) -> PResult<'a, ast::MetaItem> {
   |                      ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'a>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut

warning: this argument is a mutable reference, but not used mutably
  --> compiler\rustc_builtin_macros\src\cfg_accessible.rs:13:28
   |
13 | fn validate_input<'a>(ecx: &mut ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> {
   |                            ^^^^^^^^^^^^^^^^ help: consider changing to: `&ExtCtxt<'_>`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut
2024-03-28 12:04:00 +03:00
Kornel
826ddb3018 Suggest correct path in include_bytes! 2024-03-27 15:16:25 +00:00
bors
c308726599 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection

Fixes https://github.com/rust-lang/rust/issues/119545

Also included is a fix for an error now flagged by the lint
2024-03-23 00:37:05 +00:00
Matthias Krüger
783778c631
Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkov
Experimental feature postfix match

This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md).

This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement.

It is entirely implemented in the parser, so it should be relatively easy to remove if needed.

This PR is split in to 5 commits to ease review.

1. The implementation of the feature & gating.
2. Add a MatchKind field, fix uses, fix pretty.
3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix.
4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-22 11:36:58 +01:00
Michael Goulet
a015b90953 Make type_ascribe! not a built-in 2024-03-20 22:28:56 -04:00
Maybe Waffle
defcc44238 Make unexpected always "return" PResult<()> & add unexpected_any
This prevents breakage when `?` no longer skews inference.
2024-03-15 11:36:21 +00:00
bohan
8fcdf54a6b delay expand macro bang when there has indeterminate path 2024-03-13 16:11:16 +08:00
Arthur Carcano
ccd99b384e Remove unused fields in some structures
The dead_code lint was previously eroneously missing those.
Since this lint bug has been fixed, the unused fields need
to be removed.
2024-03-12 10:59:40 +01:00
Nicholas Nethercote
541d7cc65c Rename AddToDiagnostic as Subdiagnostic.
To match `derive(Subdiagnostic)`.

Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11 10:04:49 +11:00
Nicholas Nethercote
7a294e998b Rename IntoDiagnostic as Diagnostic.
To match `derive(Diagnostic)`.

Also rename `into_diagnostic` as `into_diag`.
2024-03-11 09:15:09 +11:00
Matthias Krüger
3e634f8c5c
Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkov
Use `ControlFlow` in visitors.

Follow up to #121256

This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
2024-03-08 13:22:26 +01:00
Matthias Krüger
d774fbea7c
Rollup merge of #119365 - nbdd0121:asm-goto, r=Amanieu
Add asm goto support to `asm!`

Tracking issue: #119364

This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto).

Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary.

r? ``@Amanieu``
cc ``@ojeda``
2024-03-08 08:19:17 +01:00
Ross Smyth
78b3bf98c3 Add MatchKind member to the Match expr for pretty printing & fmt 2024-03-06 00:35:19 -05:00
Jason Newcomb
e760c44063 Use ControlFlow in AST visitors. 2024-03-05 19:03:20 -05:00
Jason Newcomb
5abfb3775d Move visitor utils to rustc_ast_ir 2024-03-05 12:38:03 -05:00
Nicholas Nethercote
7aa0eea19c Rename BuiltinLintDiagnostics as BuiltinLintDiag.
Not the dropping of the trailing `s` -- this type describes a single
diagnostic and its name should be singular.
2024-03-05 12:15:10 +11:00
Nicholas Nethercote
573267cf3c Rename SubdiagnosticMessageOp as SubdiagMessageOp. 2024-03-05 12:14:49 +11:00
Nicholas Nethercote
80d2bdb619 Rename all ParseSess variables/fields/lifetimes as psess.
Existing names for values of this type are `sess`, `parse_sess`,
`parse_session`, and `ps`. `sess` is particularly annoying because
that's also used for `Session` values, which are often co-located, and
it can be difficult to know which type a value named `sess` refers to.
(That annoyance is the main motivation for this change.) `psess` is nice
and short, which is good for a name used this much.

The commit also renames some `parse_sess_created` values as
`psess_created`.
2024-03-05 08:11:45 +11:00
Nicholas Nethercote
aa38c26bbf Tweak parse_asm_args.
It doesn't need a `Parser` and a `ParseSess`, because the former
contains the latter.
2024-03-04 16:12:33 +11:00
r0cky
2064c19886 Remove unused fluent messages 2024-03-01 09:59:44 +08:00
León Orell Valerian Liehr
2b8060578a
AST: Refactor type alias where clauses 2024-02-29 17:18:40 +01:00
r0cky
1850ba7f54 Remove unused diagnostic struct 2024-02-29 14:14:21 +08:00
Nicholas Nethercote
899cb40809 Rename DiagnosticBuilder as Diag.
Much better!

Note that this involves renaming (and updating the value of)
`DIAGNOSTIC_BUILDER` in clippy.
2024-02-28 08:55:35 +11:00