Commit Graph

3791 Commits

Author SHA1 Message Date
Alexander Regueiro 3816958f18 Implemented for function bounds, type bounds, and named existential types. 2019-06-05 21:09:26 +01:00
Alexander Regueiro 35585c499f Aggregation of drive-by cosmetic changes. 2019-06-05 21:09:26 +01:00
bors 2a1d6c83d3 Auto merge of #61484 - nnethercote:avoid-more-hygiene-lookups, r=petrochenkov
Avoid more hygiene lookups

Mostly by combining multiple `HygieneData::with` calls into a single call on hot paths.

r? @petrochenkov
2019-06-05 12:46:15 +00:00
Nicholas Nethercote ab9bbf48db Avoid unnecessary rust_2018 calls.
The commit combines two calls into one by saving the result in a local
variable. The commit also moves the check for `async` later, so that
when a different keyword is present the `rust_2018` call will be avoided
completely.
2019-06-05 07:43:15 +10:00
Pietro Albini 46344122d1 Rollup merge of #61500 - estebank:expregression, r=petrochenkov
Fix regression 61475

Addresses #61475.
2019-06-04 22:39:39 +02:00
Mazdak Farrokhzad 3a06a93f59 Rollup merge of #61413 - davidtwco:async-argument-order-in-a-sane-way, r=eddyb
Re-implement async fn drop order lowering

This PR re-implements the async fn drop order lowering changes so
that it all takes place in HIR lowering, building atop the work done by
@eddyb to refactor `Res::Upvar`.

Previously, this types involved in the lowering were constructed in
libsyntax as they had to be used during name resolution and HIR
lowering. This was awful because none of that logic should have existed
in libsyntax.

This commit also changes `ArgSource` to keep a `HirId` to the original
argument pattern rather than a cloned copy of the pattern.

Only b7aa4ed and 71fb8fa should be reviewed, any other commits
are from #61276 (though 447e336 might end up staying in this PR).

As a nice side effect, it also fixes #61187 (cc #61192).

r? @eddyb
cc @cramertj
2019-06-04 04:48:11 +02:00
Mazdak Farrokhzad 1563514196 Rollup merge of #61409 - varkor:condition-trait-param-ice, r=oli-obk
Fix an ICE with a const argument in a trait

This goes some way towards fixing https://github.com/rust-lang/rust/issues/61383 (the reduced test case is fixed).
2019-06-04 04:48:08 +02:00
Esteban Küber 288202ec29 Fix regression #61475 2019-06-03 12:06:49 -07:00
Eduard-Mihai Burtescu d0c78dd7aa syntax: revert ast::AsyncArgument and associated changes.
Here follows the main reverts applied in order to make this commit:

Revert "Rollup merge of #60676 - davidtwco:issue-60674, r=cramertj"

This reverts commit 45b09453db, reversing
changes made to f6df1f6c30.

Revert "Rollup merge of #60437 - davidtwco:issue-60236, r=nikomatsakis"

This reverts commit 16939a50ea, reversing
changes made to 12bf981552.

Revert "Rollup merge of #59823 - davidtwco:issue-54716, r=cramertj"

This reverts commit 62d1574876, reversing
changes made to 4eff8526a7.
2019-06-03 10:20:35 +01:00
varkor 2b27c6235b Allow true and false in const generic arguments 2019-06-03 09:59:45 +01:00
bors c57ed9d947 Auto merge of #61331 - estebank:fn-arg-parse-recovery, r=varkor
Recover gracefully from argument with missing type or param name
2019-06-03 05:40:53 +00:00
Mazdak Farrokhzad 83b74f2aad Rollup merge of #61438 - estebank:generics-span, r=varkor
Point at individual type args on arg count mismatch

- Point at individual type arguments on arg count mismatch
- Make generics always have a valid span, even when there are no args
- Explain that `impl Trait` introduces an implicit type argument

Fix #55991.
2019-06-02 15:23:49 +02:00
Esteban Küber e275f2caf6 Extend docstring 2019-06-01 14:13:57 -07:00
Esteban Küber 8e595f5610 Make generics always have a valid span 2019-05-31 22:19:30 -07:00
Pietro Albini e36b90752c Rollup merge of #61374 - VirrageS:master, r=Centril
Explicitly suggest 'type_ascription' feature

Closes: #61325

r? @estebank
2019-05-31 13:34:07 +02:00
Esteban Küber ad0d3b5d40 Move code from parser to diagnostics 2019-05-30 18:19:48 -07:00
Esteban Küber 1ee45da2b9 Remove ArgSource::Recovery 2019-05-30 18:02:40 -07:00
Esteban Küber b3ac88ad92 Recover gracefully from argument with missing type or param name 2019-05-30 17:59:05 -07:00
Mazdak Farrokhzad 2ebfbb4fab Parse 'async unsafe fn' instead of 'unsafe async fn'. 2019-05-31 00:53:10 +02:00
Janusz Marcinkiewicz 4c5eb8ecfc Explicitly suggest 'type_ascription' feature 2019-05-30 22:44:39 +02:00
Mazdak Farrokhzad 5d72ac3639 libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'. 2019-05-29 17:58:44 +02:00
Nicholas Nethercote 8ae01a9008 Use Symbol equality in is_ident_named. 2019-05-27 14:05:05 +10:00
Nicholas Nethercote 303bf1509b Avoid some re-interning in to_lit_token. 2019-05-27 14:05:05 +10:00
Nicholas Nethercote 21f28448e0 Add to_symbol methods. 2019-05-27 14:05:02 +10:00
Nicholas Nethercote 9c7d28d4fd Pre-intern "0", "1", ..., "9", and use where appropriate. 2019-05-27 13:58:38 +10:00
Nicholas Nethercote 26451ef7b5 Avoid unnecessary internings.
Most involving `Symbol::intern` on string literals.
2019-05-27 13:58:38 +10: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 d1364d5284 Move some methods to diagnostics.rs away from parser.rs
Move a bunch of error recovery methods to `diagnostics.rs` away from
`parser.rs`.
2019-05-25 12:11:41 -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 ee7593e0ac Revert changes that belong to separate PR 2019-05-24 15:17:32 -07:00
Esteban Küber da57ac38a6 Move diagnostic logic out of parser 2019-05-24 11:50:21 -07:00
Esteban Küber a2f853a691 Fix rebase 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 90d15e7704 syntax: Some code cleanup 2019-05-23 12:46:41 +03:00
Vadim Petrochenkov ca2a50fad7 syntax: Turn token::Lit into a struct 2019-05-23 12:46:24 +03:00
Vadim Petrochenkov 558559e70f syntax: Remove an obsolete hack from literal comparisons 2019-05-23 12:44:05 +03:00
Vadim Petrochenkov 9450e7d142 syntax: Fix spans for boolean literals passed to proc macros 2019-05-23 12:44:05 +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
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 a1885cdba3 Restore the old behavior of the rustdoc keyword check + Fix rebase 2019-05-22 20:20:12 +03: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
Mazdak Farrokhzad 3c9ac30dd9 Rollup merge of #60995 - topecongiro:parser-from-stream-and-base-dir, r=michaelwoerister
Add stream_to_parser_with_base_dir

This PR adds `stream_to_parser_with_base_dir`, which creates a parser from a token stream and a base directory.

Context: I would like to parse `cfg_if!` macro and get a list of modules defined inside it from rustfmt so that rustfmt can format those modules (cc https://github.com/rust-lang/rustfmt/issues/3253). To do so, I need to create a parser from `TokenStream` and set the directory of `Parser` to the same directory as the parent directory of a file which contains `cfg_if!` invocation. AFAIK there is no way to achieve this, and hence this PR.

Alternatively, I could change the visibility of `Parser.directory` from `crate` to `pub` so that the value can be modified after initializing a parser. I don't have a preference over either approach (or others, as long as it works).
2019-05-22 03:47:38 +02:00