Commit Graph

3661 Commits

Author SHA1 Message Date
bors 31a75a1728 Auto merge of #60124 - petrochenkov:stanomut, r=eddyb
Remove mutability from `Def::Static`

Querify `TyCtxt::is_static`.
Use `Mutability` instead of bool in foreign statics in AST/HIR.

cc https://github.com/rust-lang/rust/pull/60110
r? @eddyb
2019-04-21 13:40:22 +00:00
Vadim Petrochenkov 4eb94b4407 AST/HIR: Use Mutability instead of bool in foreign statics 2019-04-21 15:29:58 +03:00
bors 06a271a6eb Auto merge of #60119 - estebank:bad-recovery, r=davidtwco
Remove assumption from recovery code

Fix #60115.
2019-04-21 10:13:27 +00:00
bors 4d9c6cd722 Auto merge of #60132 - davidtwco:issue-60075, r=estebank
Fix fn front matter parsing ICE from invalid code.

Fixes #60075.

This PR fixes an "unreachable code" ICE that results from parsing
invalid code where the compiler is expecting the next trait item
declaration in the middle of the previous trait item due to extra
closing braces.

r? @estebank (thanks for the minimized test case)
2019-04-21 07:20:14 +00:00
bors 4530c528ba Auto merge of #59700 - matklad:simplify, r=eddyb
Simplify doc comment lexing

is_doc_comment function checks the first four chars, but this is
redundant, `doc_comment` local var has the same info.
2019-04-20 17:59:15 +00:00
David Wood 60c6ed9664 Fix fn front matter parsing ICE from invalid code.
This commit fixes an "unreachable code" ICE that results from parsing
invalid code where the compiler is expecting the next trait item
declaration in the middle of the previous trait item due to extra
closing braces.
2019-04-20 11:36:04 +01:00
Esteban Küber 30b779f398 Remove assumption from recovery code 2019-04-19 11:04:41 -07:00
Vadim Petrochenkov aa393b0cde Some cleanup to maybe_parse_struct_expr 2019-04-19 10:32:44 -07:00
Esteban Küber 4c4ca60edd remove duplicated code and simplify logic 2019-04-19 10:13:45 -07:00
Esteban Küber f1be8d16c5 Identify missing ambiguous case with best effort suggestion 2019-04-19 10:13:45 -07:00
Esteban Küber 2f36b54f0f Emit specific error for struct literal in conditions 2019-04-19 10:13:44 -07:00
Mazdak Farrokhzad c89bc54d4f Rollup merge of #59128 - oli-obk:colorful_json, r=mark-i-m,eddyb
Emit ansi color codes in the `rendered` field of json diagnostics

cc @ljedrz

Implemented for https://github.com/rust-lang/rust/pull/56595#issuecomment-447645115 (x.py clippy)
2019-04-17 10:31:30 +02:00
Mazdak Farrokhzad af4acd0533 Rollup merge of #59866 - estebank:recover-missing-semi, r=petrochenkov
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-12 20:36:16 +02:00
Mazdak Farrokhzad 8f111951a1 Rollup merge of #59847 - Kampfkarren:try-block-catch, r=estebank
Error when using `catch` after `try`

Part of https://github.com/rust-lang/rust/issues/31436
2019-04-12 20:36:11 +02:00
bors cd8b437362 Auto merge of #59227 - Zoxc:fix-get, r=eddyb
Fix lifetime on LocalInternedString::get function

cc @eddyb @nnethercote
2019-04-11 23:36:13 +00:00
Esteban Küber 9b6b3d618c review comments 2019-04-11 14:45:23 -07:00
Kampfkarren 1156ce6f54 Feedback 2019-04-10 19:22:43 -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
Kampfkarren de02dd96fd Adhere to tidy script 2019-04-10 10:41:47 -07:00
Kampfkarren 4a938b5b3c Special error when using catch after try 2019-04-10 10:35:48 -07:00
Mazdak Farrokhzad 2e7be1ed6c Rollup merge of #59687 - matklad:shebang, r=petrochenkov
cleanup shebang handling in the lexer
2019-04-05 12:46:49 +02:00
Aleksey Kladov 606e0aff81 Simplify doc comment lexing
is_doc_comment function checks the first four chars, but this is
redundant, `doc_comment` local var has the same info.
2019-04-04 19:51:13 +03:00
Aleksey Kladov fdb8752850 cleanup shebang handling in the lexer 2019-04-04 13:31:53 +03:00
Aleksey Kladov 1763aea7ba make StringReader methods private 2019-04-03 18:33:54 +03:00
Aleksey Kladov 555309d933 make StringReader fields private 2019-04-03 18:20:50 +03:00
Oliver Scherer 0a842e8c7a Update more unit test to new API 2019-04-02 16:14:59 +02: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
John Kåre Alsaker 438f6b04c6 Fix lifetime on LocalInternedString::get function 2019-03-31 03:11:55 +02: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 9ea6790a64 Deduplicate parse recovery code 2019-03-28 19:58:45 -07:00
Mazdak Farrokhzad 73f9832ee4 Rollup merge of #59476 - nnethercote:TokenStreamBuilder-SmallVec, r=petrochenkov
Use `SmallVec` in `TokenStreamBuilder`.

This reduces by 12% the number of allocations done for a "clean incremental" of `webrender_api`, which reduces the instruction count by about 0.5%.

r? @petrochenkov
2019-03-29 02:40:54 +01:00
Nicholas Nethercote 17a8aff20a Use SmallVec in TokenStreamBuilder.
This reduces by 12% the number of allocations done for a "clean
incremental" of `webrender_api`, which reduces the instruction count by
about 0.5%.

It also reduces instruction counts by up to 1.4% across a range of
rustc-perf benchmark runs.
2019-03-29 09:32:58 +11: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
Josh Stone c818c1a1d6 Rollup merge of #57565 - petrochenkov:turbowarn, r=Centril
syntax: Remove warning for unnecessary path disambiguators

`rustfmt` is now stable and it removes unnecessary turbofishes, so removing the warning as discussed in https://github.com/rust-lang/rust/pull/43540 (where it was introduced).
One hardcoded warning less.

Closes https://github.com/rust-lang/rust/issues/58055

r? @nikomatsakis
2019-03-27 18:15:19 -07: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
David Wood 5c3d1e5d76 Separate variant id and variant constructor id.
This commit makes two changes - separating the `NodeId` that identifies
an enum variant from the `NodeId` that identifies the variant's
constructor; and no longer creating a `NodeId` for `Struct`-style enum
variants and structs.

Separation of the variant id and variant constructor id will allow the
rest of RFC 2008 to be implemented by lowering the visibility of the
variant's constructor without lowering the visbility of the variant
itself.

No longer creating a `NodeId` for `Struct`-style enum variants and
structs mostly simplifies logic as previously this `NodeId` wasn't used.
There were various cases where the `NodeId` wouldn't be used unless
there was an unit or tuple struct or enum variant but not all uses of
this `NodeId` had that condition, by removing this `NodeId`, this must
be explicitly dealt with. This change mostly applied cleanly, but there
were one or two cases in name resolution and one case in type check
where the existing logic required a id for `Struct`-style enum variants
and structs.
2019-03-24 12:10:16 +03:00
Esteban Küber 9bfb0ef818 Tweak unsupported negative trait bounds message 2019-03-23 13:05:30 -07:00
Vadim Petrochenkov 4b382946e4 syntax: Remove warning for unnecessary path disambiguators 2019-03-23 17:20:11 +03:00
bors d51a437e28 Auto merge of #59058 - petrochenkov:assocrecov3, r=estebank
syntax: Better recovery for `$ty::AssocItem` and `ty!()::AssocItem`

This PR improves on https://github.com/rust-lang/rust/pull/46788 covering a few missing cases.

Fixes https://github.com/rust-lang/rust/issues/52307
Fixes https://github.com/rust-lang/rust/issues/53776
r? @estebank
2019-03-23 05:51:16 +00:00
Esteban Küber d72ef21ddd Reword type ascription note to reduce verbosity 2019-03-22 20:14:20 -07:00
Esteban Küber 44a086ef39 Review comment 2019-03-22 19:50:18 -07:00
Esteban Küber 8ba1a97e37 Expand suggestions for type ascription parse errors 2019-03-22 19:50:18 -07:00
Mazdak Farrokhzad 9d33d6fa4b Rollup merge of #59322 - estebank:diag-tweak, r=davidtwco
Tweak incorrect escaped char diagnostic
2019-03-22 19:31:34 +01:00