Commit Graph

2691 Commits

Author SHA1 Message Date
Esteban Küber
da57ac38a6 Move diagnostic logic out of parser 2019-05-24 11:50:21 -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
bors
46805805ab Auto merge of #60984 - matthewjasper:borrowck-error-reporting-cleanup, r=pnkfelix
Borrowck error reporting cleanup

* Don't show variables created by desugarings in borrowck errors
* Move "conflict error" reporting to it's own module, so that `error_reporting` contains only common error reporting methods.
* Remove unused `ScopeTree` parameter.

r? @pnkfelix
2019-05-24 03:07:07 +00:00
varkor
7948b68d02 Remove ObsoleteInPlace 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
ca2a50fad7 syntax: Turn token::Lit into a struct 2019-05-23 12:46:24 +03:00
Vadim Petrochenkov
fcc2f92f45 syntax: Return named errors from literal parsing functions 2019-05-23 12:44:05 +03:00
bors
85334c5092 Auto merge of #60174 - matthewjasper:add-match-arm-scopes, r=pnkfelix
Add match arm scopes and other scope fixes

* Add drop and lint scopes for match arms.
* Lint attributes are now respected on match arms.
* Make sure we emit a StorageDead if we diverge when initializing a temporary.
* Adjust MIR pretty printing of scopes for locals.
* Don't generate duplicate lint scopes for `let statements`.
* Add some previously missing fake borrows for matches.

closes #46525

cc @rust-lang/compiler
2019-05-23 04:48:21 +00:00
Vadim Petrochenkov
c389a39c97 Eliminate unnecessary Ident::with_empty_ctxts 2019-05-22 19:48:56 +03:00
Vadim Petrochenkov
59a382122f Simplify use of keyword symbols 2019-05-22 19:48:56 +03:00
Matthew Jasper
ebd6c7164e Dont show variables from desugarings in borrowck errors 2019-05-21 20:38:17 +01:00
Matthew Jasper
4bfb0453f5 Give match arms an HirId and a Span 2019-05-21 19:37:38 +01:00
bors
548add7f61 Auto merge of #60910 - nnethercote:avoid-some-unnecessary-interning, r=petrochenkov
Avoid some unnecessary interning

r? @petrochenkov
2019-05-18 02:10:21 +00:00
Manish Goregaokar
ba0e2518c8
Rollup merge of #60901 - estebank:str-str-str, r=Centril
Handle more string addition cases with appropriate suggestions
2019-05-17 11:34:12 -07:00
Nicholas Nethercote
86cc326d06 Avoid unnecessary interning in Ident::from_str() calls.
A lot of these static symbols are pre-interned.
2019-05-17 20:10:50 +10:00
Esteban Küber
2cb91816f2 Fix binop span 2019-05-16 19:56:11 -07:00
Esteban Küber
4117c6d33c Move some parser recovery methods to diagnostics 2019-05-16 14:31:07 -07:00
Esteban Küber
27a2881402 Fix span for await macro call 2019-05-16 14:30:39 -07:00
Esteban Küber
b9d6fe3ae9 Review comments
- Change wording of suggestion
- Move recovery logic to `diagnostics.rs`
- Reduce ammount of code duplication
2019-05-16 13:58:44 -07:00
Esteban Küber
01c6689604 Simplify span usage for incorrect await 2019-05-16 13:58:44 -07:00
Esteban Küber
ee02661474 Split parser logic to its own method 2019-05-16 13:56:44 -07:00
Esteban Küber
d763faf921 Parse alternative incorrect uses of await and recover 2019-05-16 13:56:44 -07:00
Mazdak Farrokhzad
013e4daa41
Rollup merge of #60691 - topecongiro:await-macro-span, r=Centril
Include expression to wait for to the span of Await

Currently the span of `await!` only includes itself:

```rust
    await!(3);
//  ^^^^^
```

This PR changes it so that the span holds the whole `await!` expression:

```rust
    await!(3);
//  ^^^^^^^^^
2019-05-16 10:43:30 +02:00
bors
fe5f42cdb8 Auto merge of #60630 - nnethercote:use-Symbol-more, r=petrochenkov
Use `Symbol` more

A `Symbol` can be equated with a string (e.g. `&str`). This involves a
TLS lookup to get the chars (and a Mutex lock in a parallel compiler)
and then a char-by-char comparison. This functionality is convenient but
avoids one of the main benefits of `Symbol`s, which is fast equality
comparisons.

This PR removes the `Symbol`/string equality operations, forcing a lot
of existing string occurrences to become `Symbol`s. Fortunately, these
are almost all static strings (many are attribute names) and we can add
static `Symbol`s as necessary, and very little extra interning occurs.
The benefits are (a) a slight speedup (possibly greater in a parallel
compiler), and (b) the code is a lot more principled about `Symbol` use.
The main downside is verbosity, particularly with more `use
syntax::symbol::symbols` items.

r? @Zoxc
2019-05-13 00:28:38 +00:00
Nicholas Nethercote
999c1fc281 Remove the equality operation between Symbol and strings.
And also the equality between `Path` and strings, because `Path` is made
up of `Symbol`s.
2019-05-13 09:31:30 +10:00
Nicholas Nethercote
fb084a48e2 Pass a Symbol to check_name, emit_feature_err, and related functions. 2019-05-13 09:29:22 +10:00
bors
4443957f27 Auto merge of #60767 - Centril:rollup-4cbsb73, r=Centril
Rollup of 4 pull requests

Successful merges:

 - #60694 (Fix HIR printing of existential type #60662)
 - #60750 (syntax: Remove some legacy nonterminal tokens)
 - #60751 (Assorted cleanup in parser & AST validation)
 - #60752 (Fix minor typos for ItemLocalId)

Failed merges:

r? @ghost
2019-05-12 20:28:19 +00:00
Mazdak Farrokhzad
c0aeaa1bfd
Rollup merge of #60751 - Centril:general-cleanup, r=petrochenkov
Assorted cleanup in parser & AST validation

r? @petrochenkov

Extracted out of a larger PR.
2019-05-12 21:14:10 +02:00
Mazdak Farrokhzad
4aa4a8f776 Minor cleanup in parse_assoc_expr_with. 2019-05-12 02:17:34 +02:00
Mazdak Farrokhzad
b680b66ddd parse_bottom_expr: extract common 'return' out. 2019-05-12 02:01:32 +02:00
Mazdak Farrokhzad
9b4a630baa syntax::parse::parser: convert unnecessary '&mut self's to '&self'. 2019-05-12 02:00:06 +02:00
Vadim Petrochenkov
14b353820f syntax: Remove some legacy nonterminal tokens 2019-05-12 02:01:56 +03:00
Vadim Petrochenkov
3f064cae3d Move literal parsing code into a separate file
Remove some dead code
2019-05-11 16:03:16 +03:00
Vadim Petrochenkov
8739668438 Simplify conversions between tokens and semantic literals 2019-05-11 14:24:21 +03:00
Vadim Petrochenkov
a5b3f33cb9 Eliminate comments::Literal 2019-05-11 14:24:21 +03:00
Vadim Petrochenkov
f2834a403a Keep the original token in ast::Lit 2019-05-11 14:24:21 +03:00
Vadim Petrochenkov
28b125b83d Turn ast::Lit into a struct 2019-05-11 14:24:21 +03:00
topecongiro
c921aaed39 Include expression to wait for to the span of Await 2019-05-10 14:44:43 +09:00
Mazdak Farrokhzad
45b09453db
Rollup merge of #60676 - davidtwco:issue-60674, r=cramertj
Fix async desugaring providing wrong input to procedural macros.

Fixes #60674.

This PR fixes a minor oversight introduced by #60535 where unused `mut` binding modes were removed from the arguments to an `async fn` (as they were added to the statement that we insert into the closure body). However, this meant that the input to procedural macros was incorrect. This removes that and instead fixes the `unused_mut` error that it avoided.

r? @cramertj
cc @taiki-e
2019-05-09 23:56:18 +02: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
David Wood
d5e04067cb
Add FIXME about construct_async_arguments.
This is unrelated to the rest of this PR but it made sense to add a
FIXME explaining that the function shouldn't really be in the parser.
2019-05-09 19:14:39 +01:00
David Wood
dcd3cf7017
Do not modify mutability of simple bindings.
This commit removes the modification of the mutability of simple
bindings. While the mutability isn't used, it is important that it is
kept so that the input to procedural macros matches what the user wrote.
This commit also modifies the span of the binding mode so that it is
considered a compiler desugaring and won't be linted against for being
unused..
2019-05-09 19:10:27 +01:00
bors
33cde4aac2 Auto merge of #60586 - cramertj:await, r=oli-obk
Implement built-in await syntax

Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.

This new syntax is not final, but is the consensus solution proposed by the lang team, as explained in https://boats.gitlab.io/blog/post/await-decision/

Fix https://github.com/rust-lang/rust/issues/51719
Fix https://github.com/rust-lang/rust/issues/51751
Fix https://github.com/rust-lang/rust/issues/60016
2019-05-07 22:33:12 +00:00
Taylor Cramer
fe8760cb84 Implement built-in await syntax
Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.
2019-05-07 14:45:53 -07:00
Mazdak Farrokhzad
9995bb5855
Rollup merge of #60583 - varkor:const-generics-emplace, r=petrochenkov
Fix parsing issue with negative literals as const generic arguments
2019-05-07 19:30:09 +02:00
Mazdak Farrokhzad
535db2f357
Rollup merge of #60535 - taiki-e:async-fn-arguments, r=cramertj
Correct handling of arguments in async fn

Fixes #60509
Fixes #60566

r? @cramertj or @davidtwco
2019-05-07 19:30:06 +02:00
Esteban Küber
54430ad53a review comments: fix typo and add comments 2019-05-06 16:00:21 -07:00