Commit graph

5685 commits

Author SHA1 Message Date
Yacin Tmimi e2feea47bc Document fix for retaining inner attributes on const blocks 2024-06-21 16:57:45 -05:00
Yacin Tmimi 9748af80c6 reorder link reference definitions and one changelog entry
Moved the link reference definitions closer to where they were being
used and moved the `type ascription` formatting fix to the correct
section.
2024-06-21 16:57:45 -05:00
Yacin Tmimi 0737d553ed Add changelog entry for match expr inner attribute fix with version=Two 2024-06-21 16:57:45 -05:00
Yacin Tmimi 5cab54ff1e Add itertools v0.11 -> v0.12 bump to changelog 2024-06-21 16:57:45 -05:00
Yacin Tmimi 51ae60ca33 add link to dirs v5 changelog 2024-06-21 16:57:45 -05:00
Yacin Tmimi 591df0823c Add missing issue reference 2024-06-21 16:57:45 -05:00
Yacin Tmimi eca7a94033 move trace! macro fixes to Changed section. 2024-06-21 16:57:45 -05:00
Yacin Tmimi 4b3498b188 Add another batch of updates to the changelog 2024-06-21 16:57:45 -05:00
Yacin Tmimi 30cdc2b3e9 format safety keywords on static items
This includes both `ast::StaticItem` and `ast::StaticForeignItem`.
`safety` was added to both `ast::StaticItem` and `ast::SaticForeignItem`
in https://github.com/rust-lang/rust/pull/124482.
2024-06-21 09:11:07 -05:00
Caleb Cartwright 3ffd7d46a9
Merge pull request #6193 from ytmimi/subtree-push-nightly-2024-06-13
subtree-push nightly-2024-06-13
2024-06-17 15:47:07 -05:00
Caleb Cartwright 306ddabe0a
Merge branch 'master' into subtree-push-nightly-2024-06-13 2024-06-16 18:42:39 -05:00
Jacob Rothstein 55a70266e2 docs: pin a version of markedjs from cdnjs 2024-06-16 18:40:56 -05:00
Yacin Tmimi 30eb54b5ca Add config_proc_macro to system tests
Also formats unforamatted files in the crate.
2024-06-13 00:43:21 -04:00
Yacin Tmimi 8abbcad938 format #![feature(unsafe_attributes)]
Our diff-check job was failing in part due to removing `unsafe` from any
`#[unsafe(attributes)]`. To prevent that I added a quick implementation
for this.
2024-06-12 23:53:53 -04:00
Yacin Tmimi 8e80f8aa3a don't apply formatting to builtin type ascription syntax
The syntax changed from `expr: ty` -> `builtin # type_ascribe(expr, ty)`
For now, rustfmt will just emit the contents of the span.
2024-06-12 22:40:15 -04:00
Yacin Tmimi 8c4c336e37 remove archived error-chain crate from integration tests
Can't run `cargo test --all` for `error-chain` anymore. The tests don't
compile because of `#[deny(invalid_doc_attributes)]`. Here's  the error
message:

```
error: this attribute can only be applied at the crate level
   --> tests/tests.rs:508:7
    |
508 | #[doc(test)]
    |       ^^^^
    |
    = note: read <https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html#at-the-crate-level> for more information
    = note: `#[deny(invalid_doc_attributes)]` on by default
help: to apply to the crate, use an inner attribute
    |
508 | #![doc(test)]
    |  +
```
2024-06-12 22:40:05 -04:00
Yacin Tmimi acc687735a Bumped bytecount 0.6.4 -> 0.6.8
fixes compilation issues with the `generic-simd` feature
2024-06-12 22:39:26 -04:00
Yacin Tmimi 2db10950fe allow dead code for StyleEditionDefault
We need to allow `StyleEditionDefault` because it will be used to
implement `style_edition`, but that work is currently ongoing.
2024-06-12 22:39:13 -04:00
Yacin Tmimi afa731e42f bump toolchain to nightly-2024-06-13 2024-06-12 22:38:19 -04:00
Yacin Tmimi 76cd550c54 Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-06-13 2024-06-12 22:37:39 -04:00
Rémy Rakic 783a411f67 Revert "Rollup merge of #124099 - voidc:disallow-ambiguous-expr-attrs, r=davidtwco"
This reverts commit 57dad1d75e, reversing
changes made to 36316df9fe.
2024-06-06 20:39:54 +00:00
bors c1ea87876f Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obk
Unsafe extern blocks

This implements RFC 3484.

Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484

This is better reviewed commit by commit.
2024-06-06 08:14:58 +00:00
Nicholas Nethercote ecb2dd151c rustfmt: Remove an unnecessary catch_unwind use.
The `Input::File` and `Input::Text` cases should be very similar.
However, currently the `Input::File` case uses `catch_unwind` because,
until recently (#125815) there was a fallible version of
`new_parser_from_source_str` but only an infallible version of
`new_parser_from_file`. This difference wasn't fundamental, just an
overlooked gap in the API of `rustc_parse`.

Both of those operations are now fallible, so the `Input::File` and
`Input::Text` cases can made more similar, with no need for
`catch_unwind`. This also lets us simplify an `Option<Vec<Diag>>` to
`Vec<Diag>`.
2024-06-05 10:38:03 +10:00
Nicholas Nethercote 5962aa96f1 Make top-level rustc_parse functions fallible.
Currently we have an awkward mix of fallible and infallible functions:
```
       new_parser_from_source_str
 maybe_new_parser_from_source_str
       new_parser_from_file
(maybe_new_parser_from_file)        // missing
      (new_parser_from_source_file) // missing
 maybe_new_parser_from_source_file
       source_str_to_stream
 maybe_source_file_to_stream
```
We could add the two missing functions, but instead this commit removes
of all the infallible ones and renames the fallible ones leaving us with
these which are all fallible:
```
new_parser_from_source_str
new_parser_from_file
new_parser_from_source_file
source_str_to_stream
source_file_to_stream
```
This requires making `unwrap_or_emit_fatal` public so callers of
formerly infallible functions can still work.

This does make some of the call sites slightly more verbose, but I think
it's worth it for the simpler API. Also, there are two `catch_unwind`
calls and one `catch_fatal_errors` call in this diff that become
removable thanks this change. (I will do that in a follow-up PR.)
2024-06-05 10:38:03 +10:00
Nicholas Nethercote eeefcd66cb Remove stream_to_parser.
It's a zero-value wrapper of `Parser::new`.
2024-06-05 10:37:59 +10:00
Santiago Pastorino 6478d9e59c Handle safety keyword for extern block inner items 2024-06-04 14:19:42 -03:00
Amr Hesham c97996fab6 collapse nested if detected by clippy 2024-06-03 21:08:58 -06:00
benluiwj 76ef162af7 add check_diff crate skeleton code 2024-06-03 20:47:45 -06:00
WeiTheShinobi bf7bb56524 Prevent rustfmt from removing inner attributes in inline const blocks
Fixes 6158
2024-05-31 20:40:07 -06:00
George Bateman 871113eb42 Remove lazy_static dependency 2024-05-31 07:39:15 -06:00
León Orell Valerian Liehr a2c6f80a45 Rename HIR TypeBinding to AssocItemConstraint and related cleanup 2024-05-30 22:52:33 +02:00
Nilstrieb 28e43b6fb4 Use with_capacity in rewrite_path
It not only makes rustfmt faster, but also makes the code nicer imo.

performance:
```
Summary
  ./build/host/stage2/bin/rustfmt library/std/src/lib.rs --edition 2021 ran
    1.03 ± 0.02 times faster than ../rust3/build/host/stage2/bin/rustfmt library/std/src/lib.rs --edition 2021
```

Final string lengths when formatting `core`:
```
143144 counts
(  1)    23535 (16.4%, 16.4%): 4
(  2)    16138 (11.3%, 27.7%): 3
(  3)    15143 (10.6%, 38.3%): 5
(  4)    13477 ( 9.4%, 47.7%): 6
(  5)     9122 ( 6.4%, 54.1%): 7
(  6)     8715 ( 6.1%, 60.2%): 1
(  7)     6321 ( 4.4%, 64.6%): 8
(  8)     6178 ( 4.3%, 68.9%): 11
(  9)     5826 ( 4.1%, 73.0%): 2
( 10)     5168 ( 3.6%, 76.6%): 9
( 11)     4162 ( 2.9%, 79.5%): 10
( 12)     3555 ( 2.5%, 82.0%): 13
( 13)     3337 ( 2.3%, 84.3%): 14
( 14)     3017 ( 2.1%, 86.4%): 17
( 15)     2875 ( 2.0%, 88.4%): 12
( 16)     2345 ( 1.6%, 90.1%): 15
( 17)     1956 ( 1.4%, 91.4%): 16
( 18)     1946 ( 1.4%, 92.8%): 18
( 19)     1410 ( 1.0%, 93.8%): 19
( 20)     1187 ( 0.8%, 94.6%): 20
( 21)     1045 ( 0.7%, 95.3%): 22
( 22)     1042 ( 0.7%, 96.1%): 21
( 23)      792 ( 0.6%, 96.6%): 23
( 24)      649 ( 0.5%, 97.1%): 24
( 25)      619 ( 0.4%, 97.5%): 27
( 26)      569 ( 0.4%, 97.9%): 28
( 27)      540 ( 0.4%, 98.3%): 26
( 28)      460 ( 0.3%, 98.6%): 25
( 29)      328 ( 0.2%, 98.8%): 29
( 30)      243 ( 0.2%, 99.0%): 31
[...]
```
2024-05-28 09:31:47 -06:00
Santiago Pastorino 97bdbd96f1 Rename Unsafe to Safety 2024-05-17 18:33:37 -03:00
Vadim Petrochenkov 05a2db7624 delegation: Implement list delegation
```rust
reuse prefix::{a, b, c}
```
2024-05-15 02:32:59 +03:00
Matthias Krüger 2c7016776d 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
Guillaume Gomez d5f1200ed6 Add documentation for negated ignored files and add a test for it as well 2024-05-01 10:53:06 -06:00
Matthias Krüger 27d320d1b6 Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, r=oli-obk
Add StaticForeignItem and use it on ForeignItemKind

This is in preparation for unsafe extern blocks that adds a safe variant for functions inside extern blocks.

r? `@oli-obk`
cc `@compiler-errors`
2024-04-30 06:43:42 +02:00
Santiago Pastorino fafa690716 Add StaticForeignItem and use it on ForeignItemKind 2024-04-29 13:15:51 -03:00
George Bateman 997d5f2bec Move rustfmt changes out
Now in https://github.com/rust-lang/rustfmt/pull/6154
2024-04-28 21:38:55 +01:00
George Bateman e606bb626e Remove direct dependencies on lazy_static, once_cell and byteorder
The functionality of all three crates is now available in the standard library.
2024-04-28 14:35:00 +01:00
Febriananda Wida Pramudita f781b1b9d3 fix linter 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 003bab7523 fix linter 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 76ab3c19d8 refactor if into match 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 1f806d979a Update src/matches.rs
Co-authored-by: Yacin Tmimi <yacintmimi@gmail.com>
2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 23c11f3a08 rename file and remove unecessary file and add testcase 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 6540304790 add test and simplify code 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 3854ce9aca add test and simplify code 2024-04-26 07:21:32 -06:00
Febriananda Wida Pramudita 22a4306a7e fix the logic 2024-04-26 07:21:32 -06:00
klensy 4b1596f8a1 itertools bump to 0.12 2024-04-24 20:37:32 -06:00
Oli Scherer 20e40d5efe Error on using yield without also using #[coroutine] on the closure
And suggest adding the `#[coroutine]` to the closure
2024-04-24 08:05:29 +00:00