Commit Graph

3771 Commits

Author SHA1 Message Date
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
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
John Kåre Alsaker a1f2dceaeb Move edition outside the hygiene lock and avoid accessing it 2019-05-21 18:17:05 +02:00
topecongiro 1f1a9176e7 Fix tidy: remove a trailing whitespace 2019-05-21 23:17:59 +09:00
topecongiro b07dbe1d44 Add doc comment 2019-05-21 22:57:34 +09:00
topecongiro e186d3f3e0 Add stream_to_parser_with_base_dir 2019-05-21 13:18:20 +09:00
Vadim Petrochenkov 88fa5c6a45 Improve type size assertions
Now they
- Tell what the new size is, when it changes
- Do not require passing an identifier
2019-05-19 13:59:44 +03: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 c084d0ed7d review comments 2019-05-16 15:25:58 -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 024c25dc79 Auto merge of #60763 - matklad:tt-parser, r=petrochenkov
Move token tree related lexer state to a separate struct

Just a types-based refactoring.

We only used a bunch of fields when tokenizing into a token tree, so let's move them out of the base lexer
2019-05-16 04:15:12 +00:00