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
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
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
Michael Goulet
91ac9cf595
suggest wrapping single-expr blocks in square brackets
2022-03-24 21:40:20 -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
62b8ea67b7
Emit both subexp and standalone sugg for postfix
...
This solves the TODO.
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
Noah Lev
c9cc43aa66
Move increment checks to improve errors
2022-03-23 22:31:57 -07:00
Michael Goulet
3516a16eeb
suggest removing type ascription in bad position
2022-03-18 21:22:26 -07:00
Takayuki Maeda
201a86046c
use self.create_snapshot_for_diagnostic
instead of self.clone()
2022-03-18 16:56:43 +09:00
Dylan DPC
5eb3433ed5
Rollup merge of #94731 - TaKO8Ki:const-generic-expr-recovery, r=davidtwco,oli-obk
...
Suggest adding `{ .. }` around a const function call with arguments
closes #91020
2022-03-17 22:55:04 +01:00
Takayuki Maeda
896b113ec3
use format_args_capture
in some parts of rustc_parse
2022-03-15 19:17:29 +09:00
Takayuki Maeda
9a6532276e
replace self.clone()
with self.create_snapshot_for_diagnostic()
2022-03-10 22:11:00 +09:00
Michael Howell
fbd4cfa0f8
diagnostics: only talk about Cargo.toml
if running under Cargo
...
Fixes #94646
2022-03-07 10:54:17 -07:00
mark
e489a94dee
rename ErrorReported -> ErrorGuaranteed
2022-03-02 09:45:25 -06:00
Esteban Kuber
f42b4f595e
Tweak diagnostics
...
* Recover from invalid `'label: ` before block.
* Make suggestion to enclose statements in a block multipart.
* Point at `match`, `while`, `loop` and `unsafe` keywords when failing
to parse their expression.
* Do not suggest `{ ; }`.
* Do not suggest `|` when very unlikely to be what was wanted (in `let`
statements).
2022-02-28 18:22:45 +00:00
Matthias Krüger
731cd3fbeb
Rollup merge of #94344 - notriddle:notriddle/suggest-parens-more, r=oli-obk
...
diagnostic: suggest parens when users want logical ops, but get closures
Fixes #93536
2022-02-25 14:14:40 +01:00
Michael Howell
fd35770e8d
diagnostic: suggest parens when users want logical ops, but get closures
2022-02-24 17:02:38 -07:00
Eduard-Mihai Burtescu
b7e95dee65
rustc_errors: let DiagnosticBuilder::emit
return a "guarantee of emission".
2022-02-23 06:38:52 +00:00
Eduard-Mihai Burtescu
0b9d70cf6d
rustc_errors: take self
by value in DiagnosticBuilder::cancel
.
2022-02-23 06:08:06 +00:00
Eduard-Mihai Burtescu
8562d6b752
rustc_errors: remove struct_dummy
.
2022-02-23 05:38:24 +00:00
Eduard-Mihai Burtescu
02ff9e0aef
Replace &mut DiagnosticBuilder
, in signatures, with &mut Diagnostic
.
2022-02-23 05:38:19 +00:00
est31
2ef8af6619
Adopt let else in more places
2022-02-19 17:27:43 +01:00
Matthias Krüger
602898a305
Rollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726
...
fix ICE when parsing lifetime as function argument
I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs...
cc: https://github.com/rust-lang/rust/issues/93282#issuecomment-1028052945
2022-02-12 09:26:21 +01:00
Matthias Krüger
de2abc29e9
clippy::perf fixes
...
single_char_pattern and to_string_in_format_args
2022-02-03 21:45:51 +01:00
Michael Goulet
b79fc92db3
fix ICE when parsing lifetime as function argument
2022-02-02 10:33:13 -08:00
5225225
ec3b711a4b
Write UI tests, tweak message
2022-01-31 17:34:10 +00:00
5225225
7f24778102
Suggest making base prefix lowercase if parsing fails
2022-01-27 21:31:28 +00:00
Michael Goulet
37bed05986
delay the bug once again, generalize turbofish suggestion
2022-01-25 11:11:13 -08:00
Michael Goulet
a090bb1dea
Remove delayed bug when encountering label in bad turbofish
2022-01-25 10:47:10 -08:00
Caio
cbb0fffe59
Fix let_chains and if_let_guard feature flags
2022-01-22 17:45:45 -03:00
Matthias Krüger
c6ff4be011
Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, r=nagisa
...
Fix suggesting turbofish with lifetime arguments
Now we suggest turbofish correctly given exprs like `foo<'_>`.
Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-17 06:08:15 +01:00
Michael Goulet
867554ad7c
Fix suggesting turbofish with lifetime arguments
2022-01-13 19:45:29 -08:00
Esteban Kuber
cfc0bd1258
Parse Ty?
as Option<Ty>
and provide structured suggestion
...
Swift has specific syntax that desugars to `Option<T>` similar to our
`?` operator, which means that people might try to use it in Rust. Parse
it and gracefully recover.
2022-01-14 00:07:23 +00:00
bors
a41a6925ba
Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obk
...
Remove `SymbolStr`
This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544 . As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences.
Best reviewed one commit at a time.
r? `@oli-obk`
2021-12-19 09:31:37 +00:00
Nicholas Nethercote
056d48a2c9
Remove unnecessary sigils around Symbol::as_str()
calls.
2021-12-15 17:32:14 +11:00
Jacob Pratt
d95f749f14
Stabilize destructuring_assignment
2021-12-14 22:38:51 -05:00
Nicholas Nethercote
8cddcd39ba
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`!
2021-12-15 13:30:26 +11:00
Matthias Krüger
4b37cfc50c
Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obk
...
Recover on invalid operators `<>` and `<=>`
Thanks to #89871 for showing me how to do this.
Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.
2021-12-14 20:47:27 +01:00
r00ster91
f194c9b26a
Recover on invalid operators <> and <=>
2021-12-14 18:05:02 +01:00
threadexception
b4c4bc09dd
Do not attempt to suggest help for overly malformed struct/function call
2021-12-08 22:00:44 +01:00
Fabian Wolff
ba7374e517
Improve diagnostic for missing half of binary operator in if
condition
2021-12-01 22:36:50 +01:00
bors
c6eda7d8a7
Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkor
...
Account for incorrect `impl Foo<const N: ty> {}` syntax
Fix #84946
2021-11-25 05:09:51 +00:00
Esteban Küber
7190bc3097
Account for incorrect impl Foo<const N: ty> {}
syntax
...
Fix #84946
2021-11-24 20:02:09 +00:00
Gary Guo
6d61d87b22
Split inline const to two feature gates
2021-11-22 22:17:03 +00:00
threadexception
5f6059d9a2
Fix float ICE
...
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-11-20 16:41:36 +01:00
Matthias Krüger
ff6601e0fc
some clippy::perf fixes
2021-10-07 22:31:33 +02:00
Fabian Wolff
079c075f24
Use TokenKind::similar_tokens()
2021-10-04 22:13:00 +02:00