Commit Graph

5710 Commits

Author SHA1 Message Date
Giordanno Castro
c8290a5fb7
ensure parse errors aren't emitted when formatting doc comments (#6232)
This adds a test case to validate behavior when using
`format_code_in_doc_comments=true`
2024-07-07 20:52:33 -04:00
ding-young
eed7e237bc rewrite_result for GenericBounds, GenericParam, SegmentParam 2024-07-06 09:17:32 -06:00
ding-young
f62d730e54 impl rewrite_result for AssocItemConstraintKind, GenericArg, GenericBound, Ty 2024-07-06 09:17:32 -06:00
ding-young
21afdb81f8 add Ext trait for converting Option->RewriteResult 2024-07-03 19:10:20 -06:00
ding-young
905ca5483b add rewrite_result method to Rewrite trait
impl rewrite_result for ast::Local, ast::FieldDef, ast::Param, ast::FnRetTy
2024-07-03 19:10:20 -06:00
hattizai
533b760f8d remove duplicate word 2024-07-02 07:52:22 -06:00
hattizai
f65d04a109 fix link syntax 2024-07-01 21:28:10 -06:00
Caleb Cartwright
6093d48d15
Merge pull request #6217 from compiler-errors/sync-from-rust-2024-06-24
subtree-push 2024-06-24
2024-06-30 23:11:13 -05:00
Michael Goulet
c5284965bd Remove stray println from rustfmt 2024-06-25 18:05:52 -04:00
Michael Goulet
a3a84e5dc2 Bump toolchain to nightly-2024-06-24 2024-06-24 23:09:24 -04:00
Michael Goulet
b5fa338f23 Merge remote-tracking branch 'origin/master' into sync-from-rust-2024-06-24 2024-06-24 23:02:45 -04:00
Matthias Krüger
514fe39e25 Rollup merge of #126888 - compiler-errors:oops-debug-printing, r=dtolnay
Remove stray println from rustfmt's `rewrite_static`

r? `@calebcartwright` `@ytmimi` -- though anyone should probably r+ this so it gets into nightly sooner than later, since it's obviously wrong.

This can just be fixed in-tree, since I don't think we want to wait until the next sync to fix this.

Fix https://github.com/rust-lang/rustfmt/issues/6210
Fix https://github.com/rust-lang/rust/issues/126887
2024-06-24 06:27:17 +02:00
Matthias Krüger
bd0a886b7e Rollup merge of #126754 - compiler-errors:use-rustfmt, r=calebcartwright
Implement `use<>` formatting in rustfmt

This PR implements formatting for precise-capturing `use<>` syntax as proposed in https://github.com/rust-lang/rust/pull/126753.

The syntax is implemented as-if the `use<>` bound were a trait bound but with the `use` keyword as its path segment identifier.

I opted to develop this in the rust-lang/rust tree since I'm not certain when the next rustfmt subtree sync is going to be, and I'd rather not block landing nightly support for `use<>` on something I have no control over. If ``@rust-lang/rustfmt`` would rather I move this PR over to that repository, then I would at least like to know when the next rustfmt->rust subtree sync is going to be, since stabilizing `precise_capturing` without formatting will be disruptive.

This implementation is otherwise rather straightforward.

Tracking:

- https://github.com/rust-lang/rust/issues/123432
2024-06-24 06:27:14 +02:00
Michael Goulet
22aac496cc Remove stray println from rustfmt 2024-06-23 22:27:41 -04:00
Matthias Krüger
8f8a463cbd Rollup merge of #126851 - nnethercote:NtExprKind-NtPatKind, r=compiler-errors
Rework pattern and expression nonterminal kinds.

Some tweaks to `NonterminalKind` that will assist with #124141. Details in the individual commits.

r? compiler-errors
cc ```@eholk```
2024-06-23 22:39:01 +02:00
Michael Goulet
10277c97c2 Implement use<> formatting in rustfmt 2024-06-23 10:57:10 -04:00
Nicholas Nethercote
5faf95c1c1 Rework pattern and expression nonterminal kinds.
Merge `PatParam`/`PatWithOr`, and `Expr`/`Expr2021`, for a few reasons.

- It's conceptually nice, because the two pattern kinds and the two
  expression kinds are very similar.

- With expressions in particular, there are several places where both
  expression kinds get the same treatment.

- It removes one unreachable match arm.

- Most importantly, for #124141 I will need to introduce a new type
  `MetaVarKind` that is very similar to `NonterminalKind`, but records a
  couple of extra fields for expression metavars. It's nicer to have a
  single `MetaVarKind::Expr` expression variant to hold those extra
  fields instead of duplicating them across two variants
  `MetaVarKind::{Expr,Expr2021}`. And then it makes sense for patterns
  to be treated the same way, and for `NonterminalKind` to also be
  treated the same way.

I also clarified the comments, because I have long found them a little
hard to understand.
2024-06-23 15:57:24 +10:00
Caleb Cartwright
081ae53225 fix bad merge conflict resolution 2024-06-22 16:21:14 -05:00
Michael Goulet
8b36bc00a8 Fix rustfmt 2024-06-22 15:41:51 -05:00
Caleb Cartwright
ebce054347 Merge commit 'e4944185ae09c99f59b460e358909f329010ea9c' into sync-from-rustfmt-24-06 2024-06-22 15:33:45 -05:00
Caleb Cartwright
e4944185ae chore: bump version 2024-06-21 18:20:47 -05:00
Yacin Tmimi
6c3c4308bb document rustfmt support for #![feature(unsafe_extern_blocks)] 2024-06-21 16:57:45 -05:00
Yacin Tmimi
6daf3c1778 Document removing rustfmt's lazy_static dependency 2024-06-21 16:57:45 -05:00
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
Oli Scherer
0c5a75a61b Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18 15:42:11 +00:00
Michael Goulet
1d1989fdab Fix rustfmt 2024-06-17 22:35:25 -04: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