Commit Graph

723 Commits

Author SHA1 Message Date
Nicholas Nethercote
7b6c5c76a5 Move condition out of maybe_recover_unexpected_comma. 2022-05-19 16:53:23 +10:00
Nicholas Nethercote
d4347ed678 Move condition out of maybe_recover_colon_colon_in_pat_typo. 2022-05-19 16:53:23 +10:00
Nicholas Nethercote
7a37e0c2ff Move condition out of maybe_report_ambiguous_plus and maybe_recover_from_bad_type_plus. 2022-05-19 16:53:06 +10:00
Nicholas Nethercote
a148a32fdc Move condition out of maybe_recover_from_question_mark. 2022-05-19 16:13:48 +10:00
Nicholas Nethercote
1b422451ae Move condition out of maybe_recover_from_bad_qpath. 2022-05-19 16:13:41 +10:00
Christian Poveda
462c1c846b
generate code for subdiagnostic fields in the second match 2022-05-17 13:10:15 -05:00
Christian Poveda
7cafefec4a
keep bounds where they were 2022-05-16 22:23:32 -05:00
Christian Poveda
7e8517df61
migrate maybe_recover_from_bad_type_plus diagnostic 2022-05-16 17:16:27 -05:00
Vadim Petrochenkov
f2b7fa4847 ast: Introduce some traits to get AST node properties generically
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
2022-05-11 12:43:27 +03:00
Yuki Okushi
81c0a2d96c
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`
2022-05-11 13:16:30 +09:00
Nicholas Nethercote
3cd8e9866d 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.
2022-05-11 10:14:49 +10:00
bors
574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
bors
4c60a0ea5b Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkov
Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`
2022-05-04 21:16:28 +00:00
Nicholas Nethercote
99f5945f85 Overhaul MacArgs::Eq.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
2022-05-05 07:06:12 +10:00
Elliot Roberts
7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Ken Matsui
6c7f4dee8f
Fix invalid keyword order for function declarations 2022-05-02 18:14:43 +09:00
Scott McMurray
e094ee5f10 Add do yeet expressions to allow experimentation in nightly
Using an obviously-placeholder syntax.  An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.

But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-30 17:40:27 -07:00
Camille GILLOT
74583852e8 Save colon span to suggest bounds. 2022-04-30 13:55:17 +02:00
Nicholas Nethercote
bb398ca594 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.
2022-04-29 15:23:25 +10:00
David Wood
73fa217bc1 errors: span_suggestion takes impl ToString
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:05:20 +01:00
Dylan DPC
0cbf3b2b30
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``
2022-04-28 20:13:02 +02:00
Dylan DPC
b3329f84f4
Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco
Migrate ambiguous plus diagnostic to the new derive macro

r? ````@davidtwco```` ````@jyn514````
2022-04-28 20:12:59 +02:00
Vadim Petrochenkov
2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
Dylan DPC
4c628bbb1c
Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnr
replace let else with `?`

r? `@oli-obk`
2022-04-28 02:40:36 +02:00
Dylan DPC
80045d65e1
Rollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkov
Less `NoDelim`

Currently there are several places where `NoDelim` (which really means "implicit delimiter" or "invisible delimiter") is used to mean "no delimiter". The name `NoDelim` is a bit misleading, and may be a cause.

This PR changes these places, e.g. by changing a `DelimToken` to `Option<DelimToken>` and then using `None` to mean "no delimiter". As a result, the *only* place where `NoDelim` values are now produced is within:
- `Delimiter::to_internal()`, when converting from `Delimiter::None`.
- `FlattenNonterminals::process_token()`, when converting `TokenKind::Interpolated`.

r? ````@petrochenkov````
2022-04-28 02:40:34 +02:00
Christian Poveda
e7ae9eb3f2
rename sum_with_parens 2022-04-27 12:03:16 +02:00
Ellen
f697955c1e tut tut tut 2022-04-27 08:51:33 +01:00
Nicholas Nethercote
9665da35cc Avoid producing NoDelim values in FrameData. 2022-04-27 10:35:29 +10:00
Nicholas Nethercote
6b367a0532 Avoid producing NoDelim values in MacArgs::delim(). 2022-04-27 08:15:12 +10:00
Nicholas Nethercote
f0bbc782ac Avoid producing NoDelim values in TokenCursorFrame. 2022-04-27 08:15:05 +10:00
Christian Poveda
6c3e793fb3
move AmbigousPlus outside 2022-04-26 11:12:48 +02:00
Christian Poveda
35b42cb9ec
avoid format! 2022-04-26 11:11:23 +02:00
Christian Poveda
530f4dce29
remove old code 2022-04-25 23:26:52 +02:00
Christian Poveda
519dd8e9de
migrate ambiguous plus diagnostic 2022-04-25 22:55:15 +02:00
Esteban Küber
3587406967 Better handle too many # recovery in raw str
Point at all the unnecessary trailing `#`.
Better handle interaction with outer attributes when `;` is missing.

Fix #95030.
2022-04-23 19:51:11 -07:00
Nicholas Nethercote
643e9f707e Introduced Cursor::next_with_spacing_ref.
This lets us clone just the parts within a `TokenTree` that need
cloning, rather than the entire thing. This is a surprisingly large
performance win, up to 4% on `async-std-1.10.0`.
2022-04-21 13:49:40 +10:00
Nicholas Nethercote
cc4e3443ec Produce CloseDelim and pop the stack at the same time.
This makes `CloseDelim` handling more like `OpenDelim` handling, which
produces `OpenDelim` and pushes the stack at the same time. It requires
some adjustment to `parse_token_tree` now that we don't remain within
the frame after getting the `CloseDelim`.
2022-04-21 12:34:38 +10:00
Nicholas Nethercote
7a89255b20 Avoid some tuple destructuring.
Surprisingly, this is a non-trivial performance win.
2022-04-21 09:21:45 +10:00
Nicholas Nethercote
880318c70a Remove Eof sanity check in Parser::inlined_bump_with.
A Google search of the error message fails to return any relevant
resuts, suggesting this has never occurred in practice. And removeing it
reduces instruction counts by up to 2% on some benchmarks.
2022-04-20 14:52:54 +10:00
Nicholas Nethercote
d2b9bbbf78 Inline Parser::nonterminal_may_begin_with. 2022-04-20 14:13:49 +10:00
Nicholas Nethercote
f9235db37e Inline Parser::parse_nonterminal. 2022-04-20 14:08:59 +10:00
Nicholas Nethercote
9e6879fdba Only record fallback_span when necessary. 2022-04-20 14:04:22 +10:00
Nicholas Nethercote
b09522a634 Remove the loop from Parser::bump().
The loop is there to handle a `NoDelim` open/close token. This commit
changes `TokenCursor::inlined_next` so it never returns such a token.
This is a performance win because the conditional test in `bump()` is
removed.

If the parser needs changing in the future to handle `NoDelim` tokens,
then `inlined_next()` can easily be changed to return them.
2022-04-20 12:28:26 +10:00
Nicholas Nethercote
3cd5e34617 Remove TokenCursorFrame::open_delim.
Because it's now always true.
2022-04-20 12:28:26 +10:00
Nicholas Nethercote
86723d3d46 Use true for open_delim/close_delim in one spot.
The `DelimToken` here is `NoDelim`, which means the returned delim
tokens will just be ignored by `Parser::bump()`. This commit changes
things so the delim tokens won't be returned.
2022-04-20 12:26:49 +10:00
Nicholas Nethercote
804103b0ae Add a size assertion for Parser. 2022-04-20 11:48:07 +10:00
Nicholas Nethercote
f1c32c10c4 Move desugaring code into its own function.
It's not hot, so shouldn't be within the always inlined part.
2022-04-20 08:33:25 +10:00
Nicholas Nethercote
d235ac7801 Handle Delimited opening immediately.
Instead of letting the next iteration of the loop handle it.
2022-04-19 17:02:49 +10:00
Nicholas Nethercote
29c78cc086 Add {open,close}_delim arguments to TokenCursorFrame::new().
This will facilitate the change in the next commit.

`boolean` arguments aren't great, but the function is only used in three
places within this one file.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
02317542eb Rearrange TokenCursor::inlined_next().
In particular, avoid wrapping a token within `TokenTree::Token` and then
immediately matching it and returning the token within. Just return the
token immediately.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
b1e6dee596 Merge TokenCursor::{next,next_desugared}.
And likewise for the inlined variants.

I did this for simplicity, but interesting it was a performance win as
well.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
89ec75b0e9 Inline and remove Parser::next_tok().
It has a single call site.
2022-04-19 17:02:48 +10:00
Nicholas Nethercote
aefbbeec34 Inline and remove TokenTree::{open_tt,close_tt}.
They both have a single call site.
2022-04-19 17:02:48 +10:00
Dylan DPC
bd334984e2
Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelix
Stablize `const_extern_fn` for "Rust" and "C"

All other ABIs are left unstable for now.

cc #64926
2022-04-17 00:07:23 +02:00
Dylan DPC
22d554657d
Rollup merge of #94985 - dtolnay:constattr, r=pnkfelix
Parse inner attributes on inline const block

According to https://github.com/rust-lang/rust/pull/84414#issuecomment-826150936, inner attributes are intended to be supported *"in all containers for statements (or some subset of statements)"*.

This PR adds inner attribute parsing and pretty-printing for inline const blocks (https://github.com/rust-lang/rust/issues/76001), which contain statements just like an unsafe block or a loop body.

```rust
let _ = const {
    #![allow(...)]

    let x = ();
    x
};
```
2022-04-16 19:42:00 +02:00
Dylan DPC
946d76ec0e
Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, r=petrochenkov
Improve diagnostics for unterminated nested block comment

close #95283

(This is my first time try to messing around with rust compiler and might get a lot of things wrong... 🙇 )
2022-04-16 07:12:44 +02:00
rainy-me
1b7008dc77 refactor: change to use peekable 2022-04-14 21:18:27 +09:00
Matthias Krüger
7c2d57e0fa couple of clippy::complexity fixes 2022-04-13 22:51:34 +02:00
rainy-me
4a0f8d5175 improve diagnostics for unterminated nested block comment 2022-04-14 03:22:02 +09:00
Takayuki Maeda
29c41280a1 use to_string instead of format! 2022-04-12 07:51:23 +09:00
Michael Goulet
b65265b5e1 better error for binder on associated type bound 2022-04-10 16:41:15 -07:00
bors
fa72316031 Auto merge of #95715 - nnethercote:shrink-Nonterminal, r=davidtwco
Shrink `Nonterminal`

Small consistency and performance improvements.

r? `@petrochenkov`
2022-04-07 12:52:32 +00:00
Nicholas Nethercote
d9592c2d9f Shrink Nonterminal.
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`.
This slightly reduces cumulative and peak allocation amounts, most
notably on `deep-vector`.
2022-04-07 12:51:50 +10:00
León Orell Valerian Liehr
5ab0548500 Stop flagging certain inner attrs as outer ones 2022-04-06 19:54:05 +02:00
David Wood
7f91697b50 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.
2022-04-05 07:01:02 +01:00
David Wood
c45f29595d 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>
2022-04-05 07:01:00 +01:00
David Wood
8c684563a5 errors: introduce DiagnosticMessage
Introduce a `DiagnosticMessage` type that will enable diagnostic
messages to be simple strings or Fluent identifiers.
`DiagnosticMessage` is now used in the implementation of the standard
`DiagnosticBuilder` APIs.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 06:53:39 +01:00
bors
133859d680 Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwco
Suggest `i += 1` when we see `i++` or `++i`

Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--`
is tricky to handle).

This is a continuation of #83536.

r? `@estebank`
2022-04-03 05:24:20 +00:00
bors
c1550e3f8c Auto merge of #95590 - GuillaumeGomez:multi-line-attr-handling-doctest, r=notriddle
Fix multiline attributes handling in doctests

Fixes #55713.

I needed to have access to the `unclosed_delims` field in order to check that the attribute was completely parsed and didn't have missing parts, so I created a getter for it.

r? `@notriddle`
2022-04-02 23:39:25 +00:00
Guillaume Gomez
c37cd911a4 Fix doctest multi-line mod attributes handling 2022-04-02 20:53:19 +02:00
Matthias Krüger
8f493fd46a
Rollup merge of #95293 - compiler-errors:braces, r=davidtwco
suggest wrapping single-expr blocks in square brackets

Suggests a fix in cases like:

```diff
- const A: [i32; 1] = { 1 };

+ const A: [i32; 1] = [ 1 ];
                      ^   ^
```

Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`).

Fixes #95289
2022-04-01 06:59:42 +02:00
Dylan DPC
1b7d6dbd30
Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31 04:57:28 +02:00
Dylan DPC
86388f6171
Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnay
Reduce max hash in raw strings from u16 to u8

[Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)
2022-03-31 00:26:31 +02:00
Yuri Astrakhan
a6dd658254 Addressed comments by @compiler-errors and @bjorn3 2022-03-30 17:04:46 -04:00
Yuri Astrakhan
5160f8f843 Spellchecking compiler comments
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30 15:14:15 -04:00
Grisha Vartanyan
759d1e6af8 Update error message & remove outdated test comment 2022-03-30 18:20:30 +02:00
Dylan DPC
03b3993ae8
Rollup merge of #95461 - nyurik:spelling, r=lcnr
Spellchecking some comments

This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 09:10:07 +02:00
Yuri Astrakhan
7e8201ae0a Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
Dylan DPC
e10d5039bc
Rollup merge of #95318 - rust-lang:notriddle/issue-95208, r=wesleywiser
diagnostics: correct generic bounds with doubled colon

Fixes #95208
2022-03-28 20:41:50 +02:00
Dylan DPC
ae037a86f9
Rollup merge of #95301 - nnethercote:rm-NtTT, r=petrochenkov
Remove `Nonterminal::NtTT`.

It's only needed for macro expansion, not as a general element in the
AST. This commit removes it, adds `NtOrTt` for the parser and macro
expansion cases, and renames the variants in `NamedMatch` to better
match the new type.

r? `@petrochenkov`
2022-03-28 16:08:07 +02:00
Michael Goulet
928388bad2 Make fatal DiagnosticBuilder yield never 2022-03-27 22:25:32 -07:00
Nicholas Nethercote
364b908d57 Remove Nonterminal::NtTT.
It's only needed for macro expansion, not as a general element in the
AST. This commit removes it, adds `NtOrTt` for the parser and macro
expansion cases, and renames the variants in `NamedMatch` to better
match the new type.
2022-03-28 10:03:02 +11:00
Noah Lev
4943688e9d Fix from rebase
I changed the test functions to be `pub` rather than called from a
`main` function too, for easier future modification of tests.
2022-03-27 13:54:34 -07:00
bors
ab0c2e18dc Auto merge of #94495 - estebank:missing-closing-gt, r=jackh726
Provide suggestion for missing `>` in a type parameter list

When encountering an inproperly terminated type parameter list, provide
a suggestion to close it after the last non-constraint type parameter
that was successfully parsed.

Fix #94058.
2022-03-27 18:55:58 +00:00
Esteban Kuber
157c67b7a8 Handle , to ; substitution in arg params 2022-03-27 06:05:18 +00:00
Esteban Kuber
6874bd27f5 Provide suggestion for missing > in a type parameter list
When encountering an inproperly terminated type parameter list, provide
a suggestion to close it after the last non-constraint type parameter
that was successfully parsed.

Fix #94058.
2022-03-27 02:50:04 +00:00
Aaron Hill
8035796b9a
Stablize const_extern_fn for "Rust" and "C"
All other ABIs are left unstable for now.

cc #64926
2022-03-26 18:23:54 -04:00
bors
c74925438c Auto merge of #95149 - cjgillot:once-diag, r=estebank
Remove `Session::one_time_diagnostic`

This is untracked mutable state, which modified the behaviour of queries.
It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes).

It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter.
A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics.

As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-26 00:54:54 +00:00
Michael Howell
2a7837262f diagnostics: correct generic bounds with doubled colon
Fixes #95208
2022-03-25 13:57:05 -07:00
Michael Goulet
91ac9cf595 suggest wrapping single-expr blocks in square brackets 2022-03-24 21:40:20 -07:00
Noah Lev
86220d6e51 Fix rustfix panic on test
`run-rustfix` applies all suggestions regardless of their Applicability.
There's a flag, `rustfix-only-machine-applicable`, that does what it
says, but then the produced `.fixed` file would have invalid code from
the suggestions that weren't applied. So, I moved the cases of postfix
increment, in which case multiple suggestions are given, to the
`-notfixed` test, which does not run rustfix.

I also changed the Applicability to Unspecified since MaybeIncorrect
requires that the code be valid, even if it's incorrect.
2022-03-23 22:31:57 -07:00
Noah Lev
725cde42d5 Use multipart_suggestions
This records that the suggestions are mutually-exclusive (i.e., only one
should be applied).
2022-03-23 22:31:57 -07:00
Noah Lev
ef74796178 Change temporary variable name if it would conflict 2022-03-23 22:31:57 -07:00
Noah Lev
95960b7d54 Make standalone an enum 2022-03-23 22:31:57 -07:00
Noah Lev
4212835d99 Add heuristic to avoid treating x + +2 as increment 2022-03-23 22:31:57 -07:00
Noah Lev
29a5c363c7 Improve function names 2022-03-23 22:31:57 -07:00
Noah Lev
073010d425 Improve handling of tmp variable name conflicts 2022-03-23 22:31:57 -07:00
Noah Lev
62b8ea67b7 Emit both subexp and standalone sugg for postfix
This solves the TODO.
2022-03-23 22:31:57 -07:00
Noah Lev
7287f929b9 Emit structured suggestions for field accesses too 2022-03-23 22:31:57 -07:00
Noah Lev
67a9adbb54 Refactor, handle fields better, add field tests 2022-03-23 22:31:57 -07:00