Commit Graph

5117 Commits

Author SHA1 Message Date
Oli Scherer
a3be235fcc Add gen blocks to ast and do some broken ast lowering 2023-10-27 13:05:48 +00:00
bors
d5bf53b454 Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkov
report `unused_import` for empty reexports even it is pub

Fixes #116032

An easy fix. r? `@petrochenkov`

(Discovered this issue while reviewing #115993.)
2023-10-23 20:24:09 +00:00
Caleb Cartwright
04bd7201a9 Merge commit '81fe905ca83cffe84322f27ca43950b617861ff7' into rustfmt-sync 2023-10-22 20:21:44 -05:00
bohan
4335c28677 use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
Oli Scherer
7a20da333b Rename lots of files that had generator in their name 2023-10-20 21:14:02 +00:00
Oli Scherer
1b9dd4b4ad s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Michael Goulet
f867858755 Fix spans for comments in rustfmt 2023-10-04 21:09:54 +00:00
Matthew Jasper
e0d90ccd45 Update tools and fulldeps tests 2023-09-11 15:51:19 +00:00
Camille GILLOT
45e19aa80c Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
John Kåre Alsaker
eb349e35aa Use conditional synchronization for Lock 2023-08-30 06:10:02 +02:00
Frank King
af6a6a3c2c Parse unnamed fields and anonymous structs or unions
Anonymous structs or unions are only allowed in struct field
definitions.

Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-24 11:17:54 +08:00
bors
327903e669 Auto merge of #114481 - matthiaskrgr:rollup-58pczpl, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #113945 (Fix wrong span for trait selection failure error reporting)
 - #114351 ([rustc_span][perf] Remove unnecessary string joins and allocs.)
 - #114418 (bump parking_lot to 0.12)
 - #114434 (Improve spans for indexing expressions)
 - #114450 (Fix ICE failed to get layout for ReferencesError)
 - #114461 (Fix unwrap on None)
 - #114462 (interpret: add mplace_to_ref helper method)
 - #114472 (Reword `confusable_idents` lint)
 - #114477 (Account for `Rc` and `Arc` when suggesting to clone)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-04 20:31:40 +00:00
Matthias Krüger
6e87f866ec Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31
Improve spans for indexing expressions

fixes #114388

Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.

r? compiler-errors
2023-08-04 21:31:57 +02:00
bors
e3d6bf8daa Auto merge of #114104 - oli-obk:syn2, r=compiler-errors
Lots of tiny incremental simplifications of `EmitterWriter` internals

ignore the first commit, it's https://github.com/rust-lang/rust/pull/114088 squashed and rebased, but it's needed to use to use `derive_setters`, as they need a newer `syn` version.

Then this PR starts out with removing many arguments that are almost always defaulted to `None` or `false` and replace them with builder methods that can set these fields in the few cases that want to set them.

After that it's one commit after the other that removes or merges things until everything becomes some very simple trait objects
2023-08-04 18:46:19 +00:00
Nilstrieb
aca22c73fd Improve spans for indexing expressions
Indexing is similar to method calls in having an arbitrary
left-hand-side and then something on the right, which is the main part
of the expression. Method calls already have a span for that right part,
but indexing does not. This means that long method chains that use
indexing have really bad spans, especially when the indexing panics and
that span in coverted into a panic location.

This does the same thing as method calls for the AST and HIR, storing an
extra span which is then put into the `fn_span` field in THIR.
2023-08-04 13:17:39 +02:00
Matthias Krüger
4cc22af56c Rollup merge of #114300 - MU001999:fix/turbofish-pat, r=estebank
Suggests turbofish in patterns

Fixes #114112

r? ```@estebank```
2023-08-03 17:29:07 +02:00
Nicholas Nethercote
14101ed5a5 Remove MacDelimiter.
It's the same as `Delimiter`, minus the `Invisible` variant. I'm
generally in favour of using types to make impossible states
unrepresentable, but this one feels very low-value, and the conversions
between the two types are annoying and confusing.

Look at the change in `src/tools/rustfmt/src/expr.rs` for an example:
the old code converted from `MacDelimiter` to `Delimiter` and back
again, for no good reason. This suggests the author was confused about
the types.
2023-08-03 09:03:30 +10:00
Mu001999
35d875a3a0 Fix rustfmt dep 2023-08-03 00:13:41 +08:00
Oli Scherer
aac383e3ea Use builder pattern instead of lots of arguments for EmitterWriter::new 2023-07-31 09:34:30 +00:00
bors
1f369f8b6a Auto merge of #114115 - nnethercote:less-token-tree-cloning, r=petrochenkov
Less `TokenTree` cloning

`TokenTreeCursor` has this comment on it:
```
// FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones.
```
This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that.

r? `@petrochenkov`
2023-07-28 01:21:27 +00:00
Nicholas Nethercote
e60a9e2c97 Avoid into_trees usage in rustfmt.
Token tree cloning is only needed in one place.
2023-07-27 11:58:42 +10:00
Trevor Gross
08fd1644d2 Unite bless environment variables under RUSTC_BLESS
Currently, Clippy, Miri, Rustfmt, and rustc all use an environment variable to
indicate that output should be blessed, but they use different variable names.
In order to improve consistency, this patch applies the following changes:

- Emit `RUSTC_BLESS` within `prepare_cargo_test` so it is always
  available
- Change usage of `MIRI_BLESS` in the Miri subtree to use `RUSTC_BLESS`
- Change usage of `BLESS` in the Clippy subtree to `RUSTC_BLESS`
- Change usage of `BLESS` in the Rustfmt subtree to `RUSTC_BLESS`
- Adjust the blessable test in `rustc_errors` to use this same
  convention
- Update documentation where applicable

Any tools that uses `RUSTC_BLESS` should check that it is set to any value
other than `"0"`.
2023-07-26 16:54:02 -04:00
Oli Scherer
c0ee8f5fea Make x test src/tools/rustfmt --bless format rustfmt with the freshly built in-tree version 2023-07-26 08:22:52 +00:00
Oli Scherer
a3dfd82559 Use a builder instead of boolean/option arguments 2023-07-25 13:51:15 +00:00
Esteban Küber
6013a8014b On nightly, dump ICE backtraces to disk
Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic
handler will also write the contents of the backtrace to disk. If any
`delay_span_bug`s are encountered, their backtrace is also added to the
file. The platform and rustc version will also be collected.
2023-07-19 14:10:07 +00:00
Caleb Cartwright
78331eefaf Merge commit 'dca1cf90ad6b8e45afbed2061803befbb2d159e9' into sync-rustfmt 2023-07-01 02:49:12 -05:00
Nilstrieb
80bf3ea542 Rollup merge of #112790 - WaffleLapkin:syntactically, r=Nilstrieb
Syntactically accept `become` expressions (explicit tail calls experiment)

This adds `ast::ExprKind::Become`, implements parsing and properly gates the feature.

cc `@scottmcm`
2023-06-21 07:37:02 +02:00
Caleb Cartwright
ed3e96e3d1 Merge commit '3f7c366fc0464e01ddcaefbd70647cb3da4202be' into rustfmt-sync 2023-06-19 23:13:56 -05:00
Maybe Waffle
dc7dc3e74c Implement become expression formatting in rustfmt 2023-06-19 12:54:34 +00:00
Matthias Krüger
48e380fa40 Rollup merge of #110989 - jyn514:bug-report-url, r=WaffleLapkin
Make the BUG_REPORT_URL configurable by tools

This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

I haven't changed clippy in case they want to make the change upstream instead of the subtree, but
I'm happy to do so here if the maintainers want - cc ````@rust-lang/clippy````

Fixes https://github.com/rust-lang/rust/issues/109486.
2023-05-06 13:30:04 +02:00
Michael Goulet
8ed5d5de3d Rustfmt support for negative bounds, test 2023-05-02 22:36:25 +00:00
Michael Goulet
8e330f9d5b Make tools happy 2023-05-02 22:36:24 +00:00
bors
ae213e228d Auto merge of #109128 - chenyukang:yukang/remove-type-ascription, r=estebank
Remove type ascription from parser and diagnostics

Mostly based on https://github.com/rust-lang/rust/pull/106826

Part of #101728

r? `@estebank`
2023-05-02 09:41:35 +00:00
jyn
34a71f67d1 Make the BUG_REPORT_URL configurable by tools
This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

- Switch clippy to the new hook

  This also adds a `extra_info` callback so clippy can include its own version number, which differs
  from rustc's.

- Call `install_ice_hook` in rustfmt
2023-05-01 21:44:04 -05:00
bors
4351e50a9e Auto merge of #111036 - RalfJung:miri, r=RalfJung
update Miri

r? `@ghost`
2023-05-01 11:13:49 +00:00
yukang
9d20134a78 remove rustfmt testcase for type ascription 2023-05-01 16:15:17 +08:00
yukang
a74d2d7440 fix tests 2023-05-01 16:15:17 +08:00
Ralf Jung
4eb1b520d5 Merge from rustc 2023-04-30 22:35:29 +02:00
Michael Goulet
6b9c151686 Tweak await span 2023-04-27 17:18:11 +00:00
Ralf Jung
afe34c8443 Merge from rustc 2023-04-22 10:35:35 +02:00
DrMeepster
f4c9b4c26f rustfmt fmt 2023-04-21 08:59:30 -07:00
DrMeepster
ecfdec44df minor tweaks 2023-04-21 02:14:04 -07:00
DrMeepster
84385bff42 offset_of 2023-04-21 02:14:02 -07:00
Ben Kimock
f533800225 Merge from rustc 2023-04-10 07:55:57 -04:00
Oli Scherer
f1781396bf box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer
3ecb9ed53c Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
ced3cd8d40 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer
c2890ec2d7 rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
Oli Scherer
5effe61a54 Merge from rustc 2023-04-04 08:01:31 +00:00
Guillaume Gomez
5cbb08db00 Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00