Commit Graph

505 Commits

Author SHA1 Message Date
Janusz Marcinkiewicz
4c5eb8ecfc Explicitly suggest 'type_ascription' feature 2019-05-30 22:44:39 +02:00
memoryruins
a1d1d7a2c6 Update test/ui/parser for bare_trait_object warnings 2019-05-28 14:45:27 -04:00
Esteban Küber
4e68ddca90 review comments: move back some methods and clean up wording 2019-05-25 12:15:06 -07:00
Esteban Küber
976541884f Tweak self arg not as first argument of a method diagnostic
Mention that `self` is only valid on "associated functions"
```
error: unexpected `self` argument in function
  --> $DIR/self-in-function-arg.rs:1:15
   |
LL | fn foo(x:i32, self: i32) -> i32 { self }
   |               ^^^^ not valid as function argument
   |
   = note: `self` is only valid as the first argument of an associated function
```

When it is a method, mention it must be first
```
error: unexpected `self` argument in function
  --> $DIR/trait-fn.rs:4:20
   |
LL |     fn c(foo: u32, self) {}
   |                    ^^^^ must be the first associated function argument
```
2019-05-25 12:05:18 -07:00
Esteban Küber
5c5fa775e5 review comments 2019-05-24 11:50:21 -07:00
Esteban Küber
24160171e4 Tweak macro parse errors when reaching EOF during macro call parse
- Add detail on origin of current parser when reaching EOF and stop
  saying "found <eof>" and point at the end of macro calls
- Handle empty `cfg_attr` attribute
- Reword empty `derive` attribute error
2019-05-24 11:49:33 -07:00
bors
d96c01e77c Auto merge of #60803 - varkor:remove-in-place-syntax, r=petrochenkov
Remove `ObsoleteInPlace`

The in place syntax has been deprecated for over a year. As it is, this is accumulated cruft: the error messages are unlikely to be helpful any more and it conflicts with some useful syntax (e.g. const generics in some instances).

It may be that removing `Token::LArrow` is backwards-incompatible. We should do a crater run to check.

cc @eddyb
2019-05-24 09:54:17 +00:00
varkor
36f654262d Update tests 2019-05-24 01:27:32 +01:00
Mazdak Farrokhzad
26f3528434 Rollup merge of #61056 - euclio:custom-discriminant-error, r=estebank
tweak discriminant on non-nullary enum diagnostic

Adds notes pointing at the non-nullary variants, and uses "custom
discriminant" language to be consistent with the Reference.

Fixes #61039.

r? @estebank
2019-05-24 01:30:21 +02:00
Andy Russell
3cbf5864a6 tweak discriminant on non-nullary enum diagnostic
Adds notes pointing at the non-nullary variants, and uses "custom
discriminant" language to be consistent with the Reference.
2019-05-23 11:13:48 -04:00
Vadim Petrochenkov
90d15e7704 syntax: Some code cleanup 2019-05-23 12:46:41 +03:00
Vadim Petrochenkov
694f76d561 syntax: More consistent wording for some literal parsing errors 2019-05-23 12:44:05 +03:00
Vadim Petrochenkov
fcc2f92f45 syntax: Return named errors from literal parsing functions 2019-05-23 12:44:05 +03:00
Alexander Regueiro
ce75a23c0d Reinstated shallow disallowing of maybe bounds in trait objects. 2019-05-20 16:12:49 +01:00
Alexander Regueiro
fd7c253acc Update tests. 2019-05-20 16:12:49 +01:00
Vadim Petrochenkov
3f064cae3d Move literal parsing code into a separate file
Remove some dead code
2019-05-11 16:03:16 +03:00
Mazdak Farrokhzad
39edc68c69 Rollup merge of #60188 - estebank:recover-block, r=varkor
Identify when a stmt could have been parsed as an expr

There are some expressions that can be parsed as a statement without
a trailing semicolon depending on the context, which can lead to
confusing errors due to the same looking code being accepted in some
places and not others. Identify these cases and suggest enclosing in
parenthesis making the parse non-ambiguous without changing the
accepted grammar.

Fix #54186, cc #54482, fix #59975, fix #47287.
2019-05-09 23:56:09 +02:00
Esteban Küber
e0cef5cf40 fix typo 2019-05-02 15:53:09 -07:00
Aleksey Kladov
bfa5f27847 introduce unescape module
Currently, we deal with escape sequences twice: once when we lex a
string, and a second time when we unescape literals. This PR aims to
remove this duplication, by introducing a new `unescape` mode as a
single source of truth for character escaping rules
2019-05-02 15:31:57 +03:00
Esteban Küber
617ce2b7ee Reword ambigous parse error to fit with the current error 2019-04-30 20:37:42 -07:00
Esteban Küber
bff0be3784 Add test case for #47287 2019-04-29 14:35:09 -07:00
Esteban Küber
f007e6f442 Identify when a stmt could have been parsed as an expr
There are some expressions that can be parsed as a statement without
a trailing semicolon depending on the context, which can lead to
confusing errors due to the same looking code being accepted in some
places and not others. Identify these cases and suggest enclosing in
parenthesis making the parse non-ambiguous without changing the
accepted grammar.
2019-04-29 14:07:02 -07:00
Mazdak Farrokhzad
a4ef188ab6 Rollup merge of #60160 - xldenis:fix-overlapping-zero-width-annotation, r=estebank
Fix #58270, fix off-by-one error in error diagnostics.

This fixes #58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.
2019-04-25 03:05:24 +02:00
varkor
5392f44a92 Remove unnecessary tidy ignore directives 2019-04-23 11:42:15 +01:00
Xavier Denis
4a073dda93 Fix #58270, fix off-by-one error in error diagnostics. 2019-04-22 18:14:45 -05:00
Vadim Petrochenkov
aa393b0cde Some cleanup to maybe_parse_struct_expr 2019-04-19 10:32:44 -07:00
Esteban Küber
2f36b54f0f Emit specific error for struct literal in conditions 2019-04-19 10:13:44 -07:00
Andy Russell
b6f148c8bd hide --explain hint if error has no extended info 2019-04-18 13:29:28 -04:00
Esteban Küber
9b6b3d618c review comments 2019-04-11 14:45:23 -07:00
Esteban Küber
ac037c1359 Recover from missing semicolon based on the found token
When encountering one of a few keywords when a semicolon was
expected, suggest the semicolon and recover:

```
error: expected one of `.`, `;`, `?`, or an operator, found `let`
  --> $DIR/recover-missing-semi.rs:4:5
   |
LL |     let _: usize = ()
   |                      - help: missing semicolon here
LL |
LL |     let _ = 3;
   |     ^^^

error[E0308]: mismatched types
  --> $DIR/recover-missing-semi.rs:2:20
   |
LL |     let _: usize = ()
   |                    ^^ expected usize, found ()
   |
   = note: expected type `usize`
              found type `()`
```
2019-04-10 18:07:52 -07:00
Mazdak Farrokhzad
d2fd3fe957 Rollup merge of #59041 - saleemjaffer:trait_doc_comment_better_error_msg, r=pnkfelix
fixes rust-lang#56766

fixes #56766
2019-04-01 17:29:53 +02:00
Mazdak Farrokhzad
61222b5731 Rollup merge of #59572 - davidtwco:issue-59508, r=varkor
Include bounds in generic re-ordering diagnostic

Fixes #59508.

r? @estebank
cc @varkor
2019-03-31 16:10:37 +02:00
David Wood
0270d565d9 Only mention const generics if enabled.
This commit updates the generic parameter re-ordering diagnostic to only
mention const generics if the feature is enabled.
2019-03-31 00:14:21 +01:00
Mazdak Farrokhzad
c28704c2a8 Rollup merge of #59453 - estebank:recover-tuple-parse, r=petrochenkov
Recover from parse error in tuple syntax
2019-03-30 07:51:36 +01:00
Esteban Küber
3592079765 revert change to test file as per review request 2019-03-29 06:41:15 -07:00
Mazdak Farrokhzad
fda206633d Rollup merge of #59467 - hgallagher1993:local_branch, r=estebank
Better diagnostic for binary operation on BoxedValues

Fixes #59458
2019-03-29 12:32:26 +01:00
Esteban Küber
b7dc8e71cc fix text after rebase 2019-03-28 19:58:00 -07:00
Mazdak Farrokhzad
06a9196055 Rollup merge of #59408 - euclio:compiletest-normalization, r=oli-obk
compiletest: make path normalization smarter

Fixes #59109.
2019-03-28 13:35:43 +01:00
Esteban Küber
e3918cf621 Recover from parse error in tuple syntax 2019-03-28 04:47:37 -07:00
Mazdak Farrokhzad
dcd531ea15 Rollup merge of #59198 - estebank:recovered-pattern, r=zackmdavis
Do not complain about unmentioned fields in recovered patterns

When the parser has to recover from malformed code in a pattern, do not
complain about missing fields.

Fix #59145.
2019-03-28 08:43:32 +01:00
Josh Stone
be34621ffc Rollup merge of #59421 - estebank:tuple-index-suffix, r=petrochenkov
Reject integer suffix when tuple indexing

Fix #59418.

r? @varkor
2019-03-27 18:15:35 -07:00
hgallagher1993
4d648ce1b9 Better diagnostic for binary operation on BoxedValues 2019-03-27 13:13:09 -04:00
Esteban Küber
8d1cc72cf9 Add specific message for tuple struct invoked with suffixed numeric field name 2019-03-26 12:32:32 -07:00
Esteban Küber
1bb3694b1a Reword invalid suffixe errors 2019-03-26 12:09:13 -07:00
Esteban Küber
c7ddb83980 Use expect_no_suffix for error 2019-03-26 10:18:18 -07:00
Mazdak Farrokhzad
b316514dbd Rollup merge of #59150 - estebank:type-ascription, r=varkor
Expand suggestions for type ascription parse errors

Fix #51222. CC #48016, #47666, #54516, #34255.
2019-03-26 09:05:39 +01:00
Esteban Küber
6ad77b0938 review comments 2019-03-25 21:38:23 -07:00
Esteban Küber
91b7423760 Reject integer suffix when tuple indexing 2019-03-25 16:11:21 -07:00
Andy Russell
695dfe7dff compiletest: make path normalization smarter 2019-03-25 01:06:45 -04:00
Esteban Küber
9bfb0ef818 Tweak unsupported negative trait bounds message 2019-03-23 13:05:30 -07:00