Commit Graph

5790 Commits

Author SHA1 Message Date
Michael Goulet
d6d9e76240 Add tests showing how comments are handled 2024-09-12 10:27:02 -05:00
Michael Goulet
df06d7eb09 Format trailing where clauses in rustfmt 2024-09-12 10:27:02 -05:00
rufevean
14d5165960 refactor - show file path in error message when parsing config from toml
fixes 6302

Display the path to the toml config file that rustfmt failed to parse
configurations from.
2024-09-12 10:57:14 -04:00
klensy
16f0ecc84c config_proc_macro: bump edition to 2021 2024-09-12 01:31:07 -04:00
klensy
7e507a8396 config_proc_macro: reduce syn's features 2024-09-12 01:31:07 -04:00
klensy
2e66891370 remove unused tracing-attributes 2024-09-12 00:26:05 -04:00
Yacin Tmimi
a1017ae046
Merge pull request #6320 from ytmimi/subtree-push-nightly-2024-09-10
subtree-push nightly-2024-09-10
2024-09-11 23:45:41 -04:00
Yacin Tmimi
d66e974c70 remove stray comments 2024-09-11 23:21:24 -04:00
Yacin Tmimi
bd5873ae12 bump toolchain to nightly-2024-09-10 2024-09-10 01:16:16 -04:00
Yacin Tmimi
348a499e8b Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-09-10 2024-09-10 01:15:02 -04:00
Trivikram Kamat
182a20378b ci: bump actions/checkout to v4 2024-09-09 12:21:05 -04:00
cui fliter
91b2c17ffb
Add missing backtick in comment (#6317)
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-09 11:23:15 -04:00
Michael Goulet
e1712ea92f Fix tools 2024-09-06 10:32:48 -04:00
ding-young
d720a7ef77 impl rewrite_result for ast::Expr 2024-09-05 02:25:45 -04:00
ding-young
b40c3cc388 impl rewrite_result for ForeignItem 2024-09-05 02:02:40 -04:00
ding-young
2639370905 impl rewrite_result for TraitAliasBounds, WherePredicate 2024-09-05 02:02:40 -04:00
Mattias Wallin
1a70f40d7f Avoid allocation in ChainItemKind::is_tup_field_access 2024-09-03 18:48:41 -04:00
Yacin Tmimi
06e16449d2 Add test cases for issue 4381
This was one of the original issues filed against rustfmt that discussed
using a natural sort order instead of a lexicographical order. At the
time it was closed, but now that we're supporting version-sorting in
`style_edition=2024` I thought it would be good to add a test case.
2024-09-03 15:21:36 -04:00
Yacin Tmimi
ae59ee755a sort rustfmt imports
The version-sort algorithm makes changes to the sort order of imports,
and we're updating them here for the self tests.
2024-09-03 15:21:36 -04:00
Yacin Tmimi
296417260c use version-sort when reordering imports using style_edition=2024 2024-09-03 15:21:36 -04:00
Yacin Tmimi
1681c91a35 implement version-sorting algorithm for rust identifiers
The algorithm is described in the [style guide] and was introduced in
`r-l/rust 115046`.

[style guide]: https://doc.rust-lang.org/nightly/style-guide/#sorting
2024-09-03 15:21:36 -04:00
Mattias Wallin
5d30ce6844 Avoid allocating intermediate strings in determine_operation 2024-09-02 22:42:53 -04:00
Mattias Wallin
9d407bfd1b Avoid allocating intermediate strings in ItemizedBlock::trimmed_block_as_string 2024-09-02 22:42:53 -04:00
Mattias Wallin
40909b4331 Fix test_editions_2015_2018_2021_identical
Was comparing unit type.
2024-09-01 11:00:56 -04:00
ding-young
35b3889c77 impl rewrite_result for ControlFlow, Stmt, update rewrite_index 2024-09-01 10:15:00 -04:00
ding-young
193051438d update rewrite_assignment to return RewriteResult 2024-09-01 09:07:21 -04:00
Nicholas Nethercote
c3beb05687 Remove #[macro_use] extern crate tracing from rustfmt. 2024-08-30 13:35:05 +10:00
Nicholas Nethercote
1fcfd57e2f Remove #[macro_use] extern crate tracing from rustfmt helpers. 2024-08-30 13:31:05 +10:00
Caleb Cartwright
46cb7d3220 refactor: improve mapping of legacy 'version' to 'style_edition' 2024-08-27 20:49:15 -05:00
Caleb Cartwright
065258659d feat: implement 2024 Style Edition for expr overflows 2024-08-27 20:49:15 -05:00
Caleb Cartwright
0c6515cacc feat: support style edition differing defaults in config loading 2024-08-27 20:49:15 -05:00
Caleb Cartwright
c0c3dc7a25 refactor: include edition & style edition in CliOptions 2024-08-27 20:49:15 -05:00
Caleb Cartwright
53d5ccd5e9 refactor: use style edition when loading from partial config 2024-08-27 20:49:15 -05:00
beetrees
5ee4d3b532 Remove outdated comment from mac.yml 2024-08-26 15:31:28 -04:00
ding-young
6f5e99b7b5 update macro rewrite functions to return RewriteResult 2024-08-25 09:23:04 -04:00
Yacin Tmimi
448906160d
Merge pull request #6285 from ytmimi/subtree-push-nightly-2024-08-17
subtree-push nightly-2024-08-17
2024-08-19 19:04:27 -04:00
bors
9cfbd23ac4 Auto merge of #128771 - carbotaniuman:stabilize_unsafe_attr, r=nnethercote
Stabilize `unsafe_attributes`

# Stabilization report

## Summary

This is a tracking issue for the RFC 3325: unsafe attributes

We are stabilizing `#![feature(unsafe_attributes)]`,  which makes certain attributes considered 'unsafe', meaning that they must be surrounded by an `unsafe(...)`, as in `#[unsafe(no_mangle)]`.

RFC: rust-lang/rfcs#3325
Tracking issue: #123757

## What is stabilized

### Summary of stabilization

Certain attributes will now be designated as unsafe attributes, namely, `no_mangle`, `export_name`, and `link_section` (stable only), and these attributes will need to be called by surrounding them in `unsafe(...)` syntax. On editions prior to 2024, this is simply an edition lint, but it will become a hard error in 2024. This also works in `cfg_attr`, but `unsafe` is not allowed for any other attributes, including proc-macros ones.

```rust
#[unsafe(no_mangle)]
fn a() {}

#[cfg_attr(any(), unsafe(export_name = "c"))]
fn b() {}
```

For a table showing the attributes that were considered to be included in the list to require unsafe, and subsequent reasoning about why each such attribute was or was not included, see [this comment here](https://github.com/rust-lang/rust/pull/124214#issuecomment-2124753464)

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-attributes` and `tests/ui/attributes/unsafe`.
2024-08-17 22:48:42 +00:00
Yacin Tmimi
d34fca4f01 bump toolchain to nightly-2024-08-17 2024-08-17 14:38:27 -04:00
Yacin Tmimi
6bcadd6aa4 Merge remote-tracking branch 'upstream/master' into subtree-push-nightly-2024-08-17 2024-08-17 14:36:42 -04:00
ding-young
fbe04244f8 update rewrite_chain to return RewriteResult 2024-08-15 12:32:26 -04:00
Lukasz Anforowicz
caaa612a0b Ensure that fn config_path returns canonicalized paths.
This commit ensures that `fn config_path` in `rustfmt/src/config/mod.rs`
always returns canonicalized paths.  This is achieved by canonicalizing
both: 1) paths received via `CliOptions` (after checking if the path
exists) as well as 2) paths returned via `get_toml_path` (canonicalizing
within `fn get_toml_path`).

Fixes https://github.com/rust-lang/rustfmt/issues/6178
2024-08-14 15:02:38 -04:00
ding-young
68dc912b99 update rewrite functions in imports.rs 2024-08-14 12:36:26 -04:00
Nicholas Nethercote
7b2299a2d2 Use impl PartialEq<TokenKind> for Token more.
This lets us compare a `Token` with a `TokenKind`. It's used a lot, but
can be used even more, avoiding the need for some `.kind` uses.
2024-08-14 16:37:09 +10:00
John Kåre Alsaker
57af02c9c4 Link std statically in rustc_driver 2024-08-11 04:16:53 +02:00
carbotaniuman
87949d7dde Stabilize unsafe_attributes 2024-08-07 03:12:13 -05:00
ding-young
40f5075269 impl rewrite_result for Pat, TuplePatField
- also update rewrite_unary_*** to return RewriteResult
2024-08-05 07:53:46 -06:00
David Tolnay
88944668fe Print empty commit info without trailing hyphen 2024-08-04 12:44:32 -06:00
David Tolnay
15c75fec4f Check exit status of git commands spawned by build script 2024-08-04 12:44:32 -06:00
David Tolnay
17c5869dff Print a deterministic length of commit hash in --version 2024-08-04 08:00:40 -06:00
benluiwj
a1361bd0d5 Run check-diff tests in ci 2024-08-03 05:17:27 -06:00