]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoRollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
Matthias Krüger [Wed, 17 Aug 2022 10:32:49 +0000 (12:32 +0200)]
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov

Clean up `LitKind`

r? ``@petrochenkov``

22 months agoRename some things related to literals.
Nicholas Nethercote [Mon, 1 Aug 2022 06:46:08 +0000 (16:46 +1000)]
Rename some things related to literals.

- Rename `ast::Lit::token` as `ast::Lit::token_lit`, because its type is
  `token::Lit`, which is not a token. (This has been confusing me for a
  long time.)
  reasonable because we have an `ast::token::Lit` inside an `ast::Lit`.
- Rename `LitKind::{from,to}_lit_token` as
  `LitKind::{from,to}_token_lit`, to match the above change and
  `token::Lit`.

22 months agoShrink `ast::Attribute`.
Nicholas Nethercote [Thu, 11 Aug 2022 11:06:11 +0000 (21:06 +1000)]
Shrink `ast::Attribute`.

22 months agoDo not consider method call receiver as an argument in AST.
Camille GILLOT [Sun, 7 Aug 2022 13:21:11 +0000 (15:21 +0200)]
Do not consider method call receiver as an argument in AST.

23 months agoRemove `TreeAndSpacing`.
Nicholas Nethercote [Thu, 28 Jul 2022 00:31:04 +0000 (10:31 +1000)]
Remove `TreeAndSpacing`.

A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.

23 months agoAdd rustfmt test for formatting `for<>` before closures
Maybe Waffle [Sun, 3 Jul 2022 12:11:46 +0000 (16:11 +0400)]
Add rustfmt test for formatting `for<>` before closures

23 months agoimplement rustfmt formatting for `for<>` closure binders
Maybe Waffle [Thu, 30 Jun 2022 13:40:38 +0000 (17:40 +0400)]
implement rustfmt formatting for `for<>` closure binders

23 months agoast: Add span to `Extern`
Nixon Enraght-Moony [Sat, 2 Jul 2022 17:25:55 +0000 (18:25 +0100)]
ast: Add span to `Extern`

2 years agoMerge commit 'c4416f20dcaec5d93077f72470e83e150fb923b1' into sync-rustfmt
Caleb Cartwright [Thu, 23 Jun 2022 03:14:32 +0000 (22:14 -0500)]
Merge commit 'c4416f20dcaec5d93077f72470e83e150fb923b1' into sync-rustfmt

2 years agoRollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser...
Matthias Krüger [Thu, 16 Jun 2022 07:10:20 +0000 (09:10 +0200)]
Rollup merge of #97757 - xFrednet:rfc-2383-expect-with-force-warn, r=wesleywiser,flip1995

Support lint expectations for `--force-warn` lints (RFC 2383)

Rustc has a `--force-warn` flag, which overrides lint level attributes and forces the diagnostics to always be warn. This means, that for lint expectations, the diagnostic can't be suppressed as usual. This also means that the expectation would not be fulfilled, even if a lint had been triggered in the expected scope.

This PR now also tracks the expectation ID in the `ForceWarn` level. I've also made some minor adjustments, to possibly catch more bugs and make the whole implementation more robust.

This will probably conflict with https://github.com/rust-lang/rust/pull/97718. That PR should ideally be reviewed and merged first. The conflict itself will be trivial to fix.

---

r? `@wesleywiser`

cc: `@flip1995` since you've helped with the initial review and also discussed this topic with me. :upside_down_face:

Follow-up of: https://github.com/rust-lang/rust/pull/87835

Issue: https://github.com/rust-lang/rust/issues/85549

Yeah, and that's it.

2 years agoSupport lint expectations for `--force-warn` lints (RFC 2383)
xFrednet [Sun, 5 Jun 2022 10:33:45 +0000 (12:33 +0200)]
Support lint expectations for `--force-warn` lints (RFC 2383)

2 years agoMerge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt
Caleb Cartwright [Mon, 13 Jun 2022 03:03:05 +0000 (22:03 -0500)]
Merge commit '7b73b60faca71d01d900e49831fcb84553e93019' into sync-rustfmt

2 years agoMerge crate and restricted visibilities
Jacob Pratt [Sat, 21 May 2022 18:45:14 +0000 (14:45 -0400)]
Merge crate and restricted visibilities

2 years agoRemove feature: `crate` visibility modifier
Jacob Pratt [Sat, 21 May 2022 17:53:26 +0000 (13:53 -0400)]
Remove feature: `crate` visibility modifier

2 years agoRemove `crate` visibility modifier in libs, tests
Jacob Pratt [Sat, 21 May 2022 01:06:44 +0000 (21:06 -0400)]
Remove `crate` visibility modifier in libs, tests

2 years agoFix typo
ydah [Fri, 20 May 2022 01:39:10 +0000 (10:39 +0900)]
Fix typo

This PR is fixes typo "avaiable" to "available".

2 years agofix rustfmt
klensy [Wed, 18 May 2022 16:02:06 +0000 (19:02 +0300)]
fix rustfmt

2 years agoast: Introduce some traits to get AST node properties generically
Vadim Petrochenkov [Sun, 1 May 2022 17:58:24 +0000 (20:58 +0300)]
ast: Introduce some traits to get AST node properties generically

And use them to avoid constructing some artificial `Nonterminal` tokens during expansion

2 years agoRollup merge of #96543 - nnethercote:rm-make_token_stream-hacks, r=Aaron1011
Yuki Okushi [Wed, 11 May 2022 04:16:30 +0000 (13:16 +0900)]
Rollup merge of #96543 - nnethercote:rm-make_token_stream-hacks, r=Aaron1011

Remove hacks in `make_token_stream`.

`make_tokenstream` has three commented hacks, and a comment at the top
referring to #67062. These hacks have no observable effect, at least as judged
by running the test suite. The hacks were added in #82608, with an explanation
[here](https://github.com/rust-lang/rust/pull/82608#issuecomment-812877329). It
appears that one of the following is true: (a) they never did anything useful,
(b) they do something useful but we have no test coverage for them, or (c)
something has changed in the meantime that means they are no longer necessary.

This commit removes the hacks and the comments, in the hope that (b) is not
true.

r? `@Aaron1011`

2 years agoRemove some unnecessary invisible delimiter checks.
Nicholas Nethercote [Wed, 11 May 2022 00:14:49 +0000 (10:14 +1000)]
Remove some unnecessary invisible delimiter checks.

These seem to have no useful effect... they don't seem useful from a
code inspection point of view, and they affect anything in the test
suite.

2 years agoFix the rustfmt build
Scott McMurray [Mon, 25 Apr 2022 02:25:30 +0000 (19:25 -0700)]
Fix the rustfmt build

2 years agorustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`
Vadim Petrochenkov [Tue, 26 Apr 2022 12:40:14 +0000 (15:40 +0300)]
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

2 years agoMake explicit an unreachable `NoDelim` case in `rustfmt`.
Nicholas Nethercote [Tue, 26 Apr 2022 05:09:11 +0000 (15:09 +1000)]
Make explicit an unreachable `NoDelim` case in `rustfmt`.

2 years agoAvoid producing `NoDelim` values in `MacArgs::delim()`.
Nicholas Nethercote [Tue, 26 Apr 2022 05:21:15 +0000 (15:21 +1000)]
Avoid producing `NoDelim` values in `MacArgs::delim()`.

2 years agoVisit generics inside visit_fn.
Camille GILLOT [Fri, 19 Nov 2021 21:03:43 +0000 (22:03 +0100)]
Visit generics inside visit_fn.

2 years agoRollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix
Dylan DPC [Fri, 15 Apr 2022 18:50:43 +0000 (20:50 +0200)]
Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelix

Create (unstable) 2024 edition

[On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition.

This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024.

For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical.

````@rustbot```` label +T-lang +S-waiting-on-review

Not sure on the relevant team, to be honest.

2 years agoerrors: lazily load fallback fluent bundle
David Wood [Tue, 12 Apr 2022 08:34:40 +0000 (09:34 +0100)]
errors: lazily load fallback fluent bundle

Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agosession: opt for enabling directionality markers
David Wood [Sun, 3 Apr 2022 03:53:01 +0000 (04:53 +0100)]
session: opt for enabling directionality markers

Add an option for enabling and disabling Fluent's directionality
isolation markers in output. Disabled by default as these can render in
some terminals and applications.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement sysroot/testing bundle loading
David Wood [Mon, 28 Mar 2022 08:36:20 +0000 (09:36 +0100)]
errors: implement sysroot/testing bundle loading

Extend loading of Fluent bundles so that bundles can be loaded from the
sysroot based on the language requested by the user, or using a nightly
flag.

Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoerrors: implement fallback diagnostic translation
David Wood [Sat, 26 Mar 2022 07:27:43 +0000 (07:27 +0000)]
errors: implement fallback diagnostic translation

This commit updates the signatures of all diagnostic functions to accept
types that can be converted into a `DiagnosticMessage`. This enables
existing diagnostic calls to continue to work as before and Fluent
identifiers to be provided. The `SessionDiagnostic` derive just
generates normal diagnostic calls, so these APIs had to be modified to
accept Fluent identifiers.

In addition, loading of the "fallback" Fluent bundle, which contains the
built-in English messages, has been implemented.

Each diagnostic now has "arguments" which correspond to variables in the
Fluent messages (necessary to render a Fluent message) but no API for
adding arguments has been added yet. Therefore, diagnostics (that do not
require interpolation) can be converted to use Fluent identifiers and
will be output as before.

2 years agospan: move `MultiSpan`
David Wood [Thu, 24 Mar 2022 02:03:04 +0000 (02:03 +0000)]
span: move `MultiSpan`

`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2 years agoCreate 2024 edition
Jacob Pratt [Mon, 28 Feb 2022 23:13:24 +0000 (18:13 -0500)]
Create 2024 edition

2 years agoMerge commit '5ff7b632a95bac6955611d85040859128902c580' into sync-rustfmt-subtree
Caleb Cartwright [Wed, 30 Mar 2022 04:17:30 +0000 (23:17 -0500)]
Merge commit '5ff7b632a95bac6955611d85040859128902c580' into sync-rustfmt-subtree

2 years agoTake &mut Diagnostic in emit_diagnostic.
Camille GILLOT [Sun, 20 Mar 2022 17:26:09 +0000 (18:26 +0100)]
Take &mut Diagnostic in emit_diagnostic.

Taking a Diagnostic by move would break the usual pattern
`diag.label(..).emit()`.

2 years agoRollup merge of #94960 - codehorseman:master, r=oli-obk
Dylan DPC [Thu, 17 Mar 2022 21:55:05 +0000 (22:55 +0100)]
Rollup merge of #94960 - codehorseman:master, r=oli-obk

Fix many spelling mistakes

Signed-off-by: codehorseman <cricis@yeah.net>
2 years agorustc_error: make ErrorReported impossible to construct
mark [Sun, 23 Jan 2022 00:49:12 +0000 (18:49 -0600)]
rustc_error: make ErrorReported impossible to construct

There are a few places were we have to construct it, though, and a few
places that are more invasive to change. To do this, we create a
constructor with a long obvious name.

2 years agoresolve the conflict in compiler/rustc_session/src/parse.rs
codehorseman [Wed, 16 Mar 2022 12:12:30 +0000 (20:12 +0800)]
resolve the conflict in compiler/rustc_session/src/parse.rs

Signed-off-by: codehorseman <cricis@yeah.net>
2 years agoAuto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber
bors [Tue, 15 Mar 2022 03:56:33 +0000 (03:56 +0000)]
Auto merge of #94584 - pnkfelix:inject-use-suggestion-sites, r=ekuber

More robust fallback for `use` suggestion

Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.

But this was fragile, as illustrated in issue #87613

This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.

Fix #87613

2 years agoplacate rustfmt in rustfmt.
Felix S. Klock II [Mon, 7 Mar 2022 21:37:35 +0000 (16:37 -0500)]
placate rustfmt in rustfmt.

2 years agoRollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum
Matthias Krüger [Sun, 6 Mar 2022 14:41:26 +0000 (15:41 +0100)]
Rollup merge of #94617 - pierwill:update-itertools, r=Mark-Simulacrum

Update `itertools`

Update to 0.10.1

2 years agoChange syntax for TyAlias where clauses
Jack Huey [Tue, 19 Oct 2021 22:45:48 +0000 (18:45 -0400)]
Change syntax for TyAlias where clauses

2 years agoPlacate tidy in submodule.
Felix S. Klock II [Fri, 4 Mar 2022 22:05:30 +0000 (17:05 -0500)]
Placate tidy in submodule.

2 years agoUpdate `itertools`
pierwill [Fri, 4 Mar 2022 17:54:28 +0000 (11:54 -0600)]
Update `itertools`

Update to 0.10.1

2 years agoAdjusted diagnostic output so that if there is no `use` in a item sequence,
Felix S. Klock II [Thu, 20 Jan 2022 19:07:54 +0000 (14:07 -0500)]
Adjusted diagnostic output so that if there is no `use` in a item sequence,
then we just suggest the first legal position where you could inject a use.

To do this, I added `inject_use_span` field to `ModSpans`, and populate it in
parser (it is the span of the first token found after inner attributes, if any).
Then I rewrote the use-suggestion code to utilize it, and threw out some stuff
that is now unnecessary with this in place. (I think the result is easier to
understand.)

Then I added a test of issue 87613.

2 years agoAssociate multiple with a crate too.
Felix S. Klock II [Thu, 3 Mar 2022 23:45:25 +0000 (18:45 -0500)]
Associate multiple with a crate too.

2 years agorefactor: prepare to associate multiple spans with a module.
Felix S. Klock II [Thu, 20 Jan 2022 16:06:45 +0000 (11:06 -0500)]
refactor: prepare to associate multiple spans with a module.

2 years agoEnable rustc_pass_by_value for Span
Mark Rousskov [Wed, 23 Feb 2022 13:11:17 +0000 (08:11 -0500)]
Enable rustc_pass_by_value for Span

2 years agorustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.
Eduard-Mihai Burtescu [Wed, 26 Jan 2022 03:39:14 +0000 (03:39 +0000)]
rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.

2 years agorustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.
Eduard-Mihai Burtescu [Sun, 23 Jan 2022 23:11:37 +0000 (23:11 +0000)]
rustc_errors: add `downgrade_to_delayed_bug` to `Diagnostic` itself.

2 years agorustc_errors: only box the `diagnostic` field in `DiagnosticBuilder`.
Eduard-Mihai Burtescu [Mon, 24 Jan 2022 11:23:14 +0000 (11:23 +0000)]
rustc_errors: only box the `diagnostic` field in `DiagnosticBuilder`.

2 years agoAdd term to ExistentialProjection
kadmin [Thu, 13 Jan 2022 07:39:58 +0000 (07:39 +0000)]
Add term to ExistentialProjection

Also prevent ICE when adding a const in associated const equality.

2 years agoAdd term
kadmin [Fri, 7 Jan 2022 03:58:32 +0000 (03:58 +0000)]
Add term

Instead of having a separate enum variant for types and consts have one but have either a const
or type.

2 years agoadd eq constraints on associated constants
kadmin [Fri, 30 Jul 2021 08:56:45 +0000 (08:56 +0000)]
add eq constraints on associated constants

2 years agoAuto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
bors [Mon, 17 Jan 2022 09:40:29 +0000 (09:40 +0000)]
Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu

Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`

2 years agofix(rustfmt): resolve generated file formatting issue
Caleb Cartwright [Sat, 15 Jan 2022 00:18:37 +0000 (18:18 -0600)]
fix(rustfmt): resolve generated file formatting issue

2 years agoRemove LLVM-style inline assembly from rustfmt
Tomasz Miąsko [Wed, 12 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Remove LLVM-style inline assembly from rustfmt

2 years agoCompute most of Public/Exported access level in rustc_resolve
Lamb [Mon, 26 Jul 2021 03:38:16 +0000 (05:38 +0200)]
Compute most of Public/Exported access level in rustc_resolve

Mak DefId to AccessLevel map in resolve for export

hir_id to accesslevel in resolve and applied in privacy
using local def id
removing tracing probes
making function not recursive and adding comments

Move most of Exported/Public res to rustc_resolve

moving public/export res to resolve

fix missing stability attributes in core, std and alloc

move code to access_levels.rs

return for some kinds instead of going through them

Export correctness, macro changes, comments

add comment for import binding

add comment for import binding

renmae to access level visitor, remove comments, move fn as closure, remove new_key

fmt

fix rebase

fix rebase

fmt

fmt

fix: move macro def to rustc_resolve

fix: reachable AccessLevel for enum variants

fmt

fix: missing stability attributes for other architectures

allow unreachable pub in rustfmt

fix: missing impl access level + renaming export to reexport

Missing impl access level was found thanks to a test in clippy

2 years agoMerge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree
Caleb Cartwright [Thu, 30 Dec 2021 02:49:39 +0000 (20:49 -0600)]
Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree

2 years agoRemove unnecessary sigils around `Ident::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 05:13:11 +0000 (16:13 +1100)]
Remove unnecessary sigils around `Ident::as_str()` calls.

2 years agoRemove unnecessary sigils around `Symbol::as_str()` calls.
Nicholas Nethercote [Wed, 15 Dec 2021 03:39:23 +0000 (14:39 +1100)]
Remove unnecessary sigils around `Symbol::as_str()` calls.

2 years agoRemove `SymbolStr`.
Nicholas Nethercote [Tue, 14 Dec 2021 21:32:21 +0000 (08:32 +1100)]
Remove `SymbolStr`.

By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!

2 years agoMerge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree
Caleb Cartwright [Fri, 3 Dec 2021 03:35:30 +0000 (21:35 -0600)]
Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree

2 years agoChange how the fn params span is calculated
Esteban Kuber [Wed, 24 Nov 2021 17:11:15 +0000 (17:11 +0000)]
Change how the fn params span is calculated

Use the available Generics span field to avoid issues with `T: Fn()` bounds.

This is necessary to land #85346.

2 years agoMerge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync
Caleb Cartwright [Mon, 8 Nov 2021 02:37:34 +0000 (20:37 -0600)]
Merge commit 'ea199bacef07213dbe008841b89c450e3bf0c638' into rustfmt-sync

2 years agoast: Fix naming conventions in AST structures
Vadim Petrochenkov [Sun, 7 Nov 2021 08:43:49 +0000 (16:43 +0800)]
ast: Fix naming conventions in AST structures

TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn

All `*Kind`s in AST are supposed to be enums.

Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.

Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.

2 years agofix doc issue in rustfmt
Caleb Cartwright [Thu, 21 Oct 2021 22:22:54 +0000 (17:22 -0500)]
fix doc issue in rustfmt

2 years agoensure cargo-fmt tests are excluded from root workspace
Caleb Cartwright [Wed, 20 Oct 2021 15:12:22 +0000 (10:12 -0500)]
ensure cargo-fmt tests are excluded from root workspace

2 years agoMerge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
Caleb Cartwright [Wed, 20 Oct 2021 05:11:59 +0000 (00:11 -0500)]
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree

2 years agoMigrate to 2021
Mark Rousskov [Sun, 19 Sep 2021 16:49:55 +0000 (12:49 -0400)]
Migrate to 2021

2 years agoRollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
Manish Goregaokar [Wed, 15 Sep 2021 21:56:58 +0000 (14:56 -0700)]
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco

Revert anon union parsing

Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.

Fix #88583.

2 years agoAuto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
bors [Sat, 11 Sep 2021 23:35:28 +0000 (23:35 +0000)]
Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov

Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.

2 years agoKeep a parent LocalDefId in SpanData.
Camille GILLOT [Sun, 18 Apr 2021 12:27:04 +0000 (14:27 +0200)]
Keep a parent LocalDefId in SpanData.

2 years agoIgnore automatically derived impls of `Clone` and `Debug` in dead code analysis
Fabian Wolff [Fri, 21 May 2021 17:35:49 +0000 (19:35 +0200)]
Ignore automatically derived impls of `Clone` and `Debug` in dead code analysis

2 years agoRevert "Allow formatting `Anonymous{Struct, Union}` declarations"
Felix S. Klock II [Wed, 8 Sep 2021 17:40:32 +0000 (13:40 -0400)]
Revert "Allow formatting `Anonymous{Struct, Union}` declarations"

This reverts commit 64acb7d92135ae722dfce89f0ca9d7cf6576de66.

2 years agoAuto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
bors [Mon, 6 Sep 2021 00:14:41 +0000 (00:14 +0000)]
Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank

Fix #88256 remove duplicated diagnostics

Fix #88256

2 years agoFix #88256, remove duplicated diagnostic
yukang [Sat, 4 Sep 2021 11:26:25 +0000 (19:26 +0800)]
Fix #88256, remove duplicated diagnostic

2 years agoDetect bare blocks with type ascription that were meant to be a `struct` literal
Esteban Kuber [Thu, 2 Sep 2021 18:34:03 +0000 (18:34 +0000)]
Detect bare blocks with type ascription that were meant to be a `struct` literal

Address part of #34255.

Potential improvement: silence the other knock down errors in
`issue-34255-1.rs`.

2 years agoTemporary fix rustfmt for let-else
Cameron Steffen [Sun, 25 Jul 2021 23:28:08 +0000 (18:28 -0500)]
Temporary fix rustfmt for let-else

2 years agoFix rustfmt test
Deadbeef [Fri, 27 Aug 2021 11:53:03 +0000 (11:53 +0000)]
Fix rustfmt test

2 years agoIntroduce `~const`
Deadbeef [Wed, 25 Aug 2021 11:53:16 +0000 (11:53 +0000)]
Introduce `~const`

 - [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps (*for this PR, obviously*)
      - [ ] Fix #88155
      - [ ] Do something with constness bounds in chalk

2 years agoFix typos “an”→“a” and a few different ones that appeared in the same search
Frank Steffahn [Sun, 22 Aug 2021 16:15:49 +0000 (18:15 +0200)]
Fix typos “an”→“a” and a few different ones that appeared in the same search

2 years agoFix more “a”/“an” typos
Frank Steffahn [Sun, 22 Aug 2021 14:20:58 +0000 (16:20 +0200)]
Fix more “a”/“an” typos

2 years agoAuto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum
bors [Tue, 17 Aug 2021 04:18:55 +0000 (04:18 +0000)]
Auto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum

Document private items for rustfmt

This is possible now that https://github.com/rust-lang/rust/pull/73936 has been merged.

2 years agoDocument private items for rustfmt
Joshua Nelson [Wed, 14 Jul 2021 01:09:03 +0000 (21:09 -0400)]
Document private items for rustfmt

This is possible now that rustdoc allows passing
`--document-private-items` more than once.

2 years agoIntroduce hir::ExprKind::Let - Take 2
Caio [Sun, 8 Aug 2021 14:49:13 +0000 (11:49 -0300)]
Introduce hir::ExprKind::Let - Take 2

2 years agoAuto merge of #87535 - lf-:authors, r=Mark-Simulacrum
bors [Mon, 2 Aug 2021 05:49:17 +0000 (05:49 +0000)]
Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum

rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.

2 years agorfc3052: Remove authors field from Cargo manifests
Jade [Tue, 27 Jul 2021 23:38:13 +0000 (16:38 -0700)]
rfc3052: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.

2 years agoMerge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt
Caleb Cartwright [Mon, 26 Jul 2021 03:57:19 +0000 (22:57 -0500)]
Merge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt

2 years agoUse LocalExpnId where possible.
Camille GILLOT [Fri, 25 Jun 2021 18:43:04 +0000 (20:43 +0200)]
Use LocalExpnId where possible.

2 years agoRework SESSION_GLOBALS API to prevent overwriting it
Guillaume Gomez [Wed, 5 May 2021 19:31:25 +0000 (21:31 +0200)]
Rework SESSION_GLOBALS API to prevent overwriting it

2 years agoDocument rustfmt on nightly-rustc
Joshua Nelson [Wed, 30 Jun 2021 04:13:34 +0000 (00:13 -0400)]
Document rustfmt on nightly-rustc

The recursion_limit attribute avoids the following error:

```
error[E0275]: overflow evaluating the requirement `std::ptr::Unique<rustc_ast::Pat>: std::marker::Send`
  |
  = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`rustfmt_nightly`)
```

3 years agoRollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
Yuki Okushi [Mon, 21 Jun 2021 15:00:41 +0000 (00:00 +0900)]
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum

rustfmt: load nested out-of-line mods correctly

This should address https://github.com/rust-lang/rustfmt/issues/4874

r? `@Mark-Simulacrum`

Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt

3 years agoRollup merge of #86274 - alexander-melentyev:spaces, r=bjorn3
Yuki Okushi [Mon, 21 Jun 2021 15:00:38 +0000 (00:00 +0900)]
Rollup merge of #86274 - alexander-melentyev:spaces, r=bjorn3

Spaces

3 years agoDelete spaces
Alexander Melentyev [Mon, 21 Jun 2021 09:11:37 +0000 (12:11 +0300)]
Delete spaces

3 years agofix(rustfmt): load nested out-of-line mods correctly
Caleb Cartwright [Fri, 18 Jun 2021 03:35:19 +0000 (22:35 -0500)]
fix(rustfmt): load nested out-of-line mods correctly

3 years agoUse `AttrVec` for `Arm`, `FieldDef`, and `Variant`
Yuki Okushi [Wed, 16 Jun 2021 22:11:13 +0000 (07:11 +0900)]
Use `AttrVec` for `Arm`, `FieldDef`, and `Variant`

3 years agoAdd support for using qualified paths with structs in expression and pattern
Ryan Levick [Thu, 10 Dec 2020 12:20:07 +0000 (13:20 +0100)]
Add support for using qualified paths with structs in expression and pattern
position.

3 years agoAllow formatting `Anonymous{Struct, Union}` declarations
jedel1043 [Mon, 17 May 2021 03:13:38 +0000 (22:13 -0500)]
Allow formatting `Anonymous{Struct, Union}` declarations

3 years agoUpdate log to 0.4.14
Joshua Nelson [Sun, 2 May 2021 20:56:25 +0000 (16:56 -0400)]
Update log to 0.4.14

This avoids the following warning:

```
warning: trailing semicolon in macro used in expression position
   --> /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/src/macros.rs:152:45
    |
147 | / macro_rules! debug {
148 | |     (target: $target:expr, $($arg:tt)+) => (
149 | |         log!(target: $target, $crate::Level::Debug, $($arg)+);
150 | |     );
151 | |     ($($arg:tt)+) => (
152 | |         log!($crate::Level::Debug, $($arg)+);
    | |                                             ^
153 | |     )
154 | | }
    | |_- in this expansion of `debug!`
    |
   ::: src/tools/rustfmt/src/modules/visitor.rs:36:23
    |
36  |               Err(e) => debug!("{}", e),
    |                         --------------- in this macro invocation
    |
    = note: requested on the command line with `-W semicolon-in-expressions-from-macros`
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
```

3 years agochore: update gitattributes for files with windows style line endings
Caleb Cartwright [Fri, 14 May 2021 23:18:12 +0000 (18:18 -0500)]
chore: update gitattributes for files with windows style line endings