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 Howell
2a7837262f
diagnostics: correct generic bounds with doubled colon
...
Fixes #95208
2022-03-25 13:57:05 -07: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
Michael Howell
26e299a4a7
Use consistent prose for ::
...
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-03-12 08:20:36 -07:00
Michael Howell
7e323370b3
diagnostics: single colon within <> probably, not type ascription
...
Fixes #94812
2022-03-11 15:35:18 -07:00
Takayuki Maeda
9a6532276e
replace self.clone() with self.create_snapshot_for_diagnostic()
2022-03-10 22:11:00 +09:00
Takayuki Maeda
2db8236857
add doc comments
2022-03-10 19:34:42 +09:00
Takayuki Maeda
3ded25204b
implement SnapshotParser struct
2022-03-09 23:13:04 +09:00
Takayuki Maeda
a34015c0d0
implement and use diagnostic_snapshot
2022-03-09 13:48:40 +09:00
Esteban Kuber
004f2ed219
Do not recover from Ty? in macro parsing
...
Follow up to #92746 . Address #94510 .
2022-03-04 02:03:55 +00:00
mark
e489a94dee
rename ErrorReported -> ErrorGuaranteed
2022-03-02 09:45:25 -06:00
Matthias Krüger
5be38d2bb3
Rollup merge of #94445 - c410-f3r:more-let-chains, r=cjgillot
...
4 - Make more use of `let_chains`
Continuation of #94376 .
cc #53667
2022-02-28 20:05:17 +01: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
Caio
e3e902bb06
4 - Make more use of let_chains
...
Continuation of #94376 .
cc #53667
2022-02-28 07:49:56 -03:00
Michael Goulet
6b52ac240a
Suggest {} around more bad const generic exprs
2022-02-25 17:16:58 -08: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
02ff9e0aef
Replace &mut DiagnosticBuilder, in signatures, with &mut Diagnostic.
2022-02-23 05:38:19 +00:00
Matthias Krüger
b80057d08d
compiler: clippy::complexity fixes
...
useless_format
map_flatten
useless_conversion
needless_bool
filter_next
clone_on_copy
needless_option_as_deref
2022-02-03 23:16:03 +01:00
Noah Lev
c8198a608e
Improve suggestion for escaping reserved keywords
2022-01-27 14:53:39 -08: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
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
Matthias Krüger
9323a0d1be
Rollup merge of #92746 - estebank:question-mark-in-type, r=davidtwco
...
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-16 16:58:18 +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
Lucas Kent
08829853d3
eplace usages of vec![].into_iter with [].into_iter
2022-01-09 14:09:25 +11:00
Matthias Krüger
97e844a032
fix clippy::single_char_pattern perf findings
2021-12-14 12:40:28 +01:00
est31
15de4cbc4b
Remove redundant [..]s
2021-12-09 00:01:29 +01:00
Michael Howell
74437e477e
Do not add ; to expected tokens list when it's wrong
...
There's a few spots where semicolons are checked for to do error recovery,
and should not be suggested (or checked for other stuff).
Fixes #87647
2021-12-04 11:05:30 -07:00
Esteban Kuber
c02710530c
review comments: clean up
2021-11-29 18:39:08 +00: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 Kuber
505b09e326
Tweak span and add more tests
2021-11-24 22:04:52 +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
Michael Howell
bff1645bdb
fix(doctest): detect extern crate items in statement doctests
...
This partially reverts #91026 , because rustdoc needs to detect the extern statements,
even when they appear inside implicit `main()`. It does not entirely revert it,
so the old bug is still fixed, by duplicating some of the logic from `parse_mod`
instead of trying to use it directly.
Fixes #91134
2021-11-22 19:47:58 -07:00
r00ster91
3c1d55422a
Some "parenthesis" and "parentheses" fixes
2021-10-17 12:04:01 +02:00
bors
a0648eab36
Auto merge of #88835 - FabianWolff:issue-88770, r=petrochenkov
...
Fix error recovery in format macro parsing
Fixes #88770 . Basically, the assumption in the following comment is incorrect:
b69fe57261/compiler/rustc_builtin_macros/src/format.rs (L167-L172)
This is only true in the first iteration of the loop, when [`p.clear_expected_tokens()`](b69fe57261/compiler/rustc_builtin_macros/src/format.rs (L164) ) is called. In subsequent iterations, `p.expected_tokens` won't be empty, so `p.expect()` won't actually call `unexpected_try_recover()`:
b69fe57261/compiler/rustc_parse/src/parser/mod.rs (L487-L498)
Instead, it will call `expect_one_of()`, which _can_ recover and return `Ok()`. This PR handles this case to fix the ICE in #88770 .
2021-09-24 11:54:29 +00:00
Guillaume Gomez
1b7896716e
Rollup merge of #87566 - JohnTitor:find-eqeq-on-assoc-type-bounds, r=estebank
...
Recover invalid assoc type bounds using `==`
Fix #87493
r? `@estebank`
2021-09-17 17:41:14 +02:00
Yuki Okushi
ee99bb3939
Apply review comments
2021-09-17 14:10:41 +09:00
Yuki Okushi
9342be5538
Recover invalid assoc type bounds using ==
2021-09-17 14:02:00 +09:00
Yuki Okushi
e9bf73cb2b
Use multipart_suggestion
2021-09-17 13:39:26 +09:00
Yuki Okushi
58765d61ee
Emit clearer diagnostics for parens around for loop heads
2021-09-17 13:14:23 +09:00
bors
9bb77da74d
Auto merge of #87915 - estebank:fancy-spans, r=oli-obk
...
Use smaller spans for some structured suggestions
Use more accurate suggestion spans for
* argument parse error
* fully qualified path
* missing code block type
* numeric casts
2021-09-13 16:31:12 +00:00
Fabian Wolff
a8421cacfe
Fix error recovery in format macro parsing
2021-09-10 22:33:44 +02:00
bors
b4e8596e3e
Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser
...
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`.
2021-09-04 01:40:36 +00:00
Esteban Kuber
12ce6e9c60
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`.
2021-09-03 14:43:04 +00:00
Esteban Kuber
c6d800d854
Point at unclosed delimiters as part of the primary MultiSpan
...
Both the place where the parser encounters a needed closed delimiter and
the unclosed opening delimiter are important, so they should get the
same level of highlighting in the output.
2021-08-27 14:24:47 +00:00
Esteban Kuber
34d19634f5
Use smaller spans for some structured suggestions
...
Use more accurate suggestion spans for
* argument parse error
* fully qualified path
* missing code block type
* numeric casts
* E0212
2021-08-12 09:52:38 +00:00
Esteban Küber
0b8f192cfe
Use multispan suggestions more often
...
* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often
2021-07-30 09:26:31 -07:00