Commit Graph

3614 Commits

Author SHA1 Message Date
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
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
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
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
Mazdak Farrokhzad 5a0e4510a8 Rollup merge of #59266 - estebank:struct-parse-recovery, r=petrochenkov
Do not complain about non-existing fields after parse recovery

When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.

Fix #57361.
2019-03-22 19:31:24 +01:00
bors a85ec7c2c0 Auto merge of #59031 - estebank:recover-from-comaless, r=petrochenkov
Recover from missing comma between enum variants and from bad `pub` kw

Fix #56579. Fix #56473.
2019-03-22 04:52:10 +00:00
Esteban Küber a8120d660a Tweak incorrect escaped char diagnostic 2019-03-20 11:45:25 -07:00
Esteban Küber 757eb67992 review comments 2019-03-19 13:17:25 -07:00
bors cd45b19bd2 Auto merge of #58872 - rep-nop:diagnostic-fix-56031, r=petrochenkov
Adds help message in error for invalid `impl for T` syntax

Fixes #56031.
2019-03-18 08:03:05 +00:00
Esteban Küber 6007e6f649 Do not complain about non-existing fields after parse recovery
When failing to parse struct-like enum variants, the ADT gets recorded
as having no fields. Record that we have actually recovered during
parsing of this variant to avoid complaing about non-existing fields
when actually using it.
2019-03-17 20:09:53 -07:00
Esteban Küber 0a09e76c96 Simplify check 2019-03-16 17:47:57 -07:00
Esteban Küber 1aa43af370 parse full visibility when recovering 2019-03-16 17:47:57 -07:00
Esteban Küber b2b9555f95 Recover from incorrect pub kw in "reasonable" places 2019-03-16 17:47:57 -07:00
Esteban Küber 532dd4475b Recover from missing comma between enum variants 2019-03-16 17:47:00 -07:00
Vadim Petrochenkov 2fd4cbb3f2 Fix rebase 2019-03-16 23:14:42 +03:00
Vadim Petrochenkov 0cf96131f4 Refactor away NestedMetaItemKind
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16 23:14:42 +03:00
Vadim Petrochenkov 63116d313d Rename MetaItem::ident to MetaItem::path 2019-03-16 23:13:15 +03:00
Vadim Petrochenkov 6ad55b3dec syntax: Introduce Ident::can_be_raw 2019-03-16 23:13:15 +03:00
Andy Russell 5abd6d9492 add suggestions to invalid macro item error 2019-03-13 15:24:36 -04:00
Mazdak Farrokhzad ad7b650815 Rollup merge of #58876 - estebank:numeric-lifetime, r=petrochenkov
Parse lifetimes that start with a number and give specific error

Fix #58786.
2019-03-13 03:33:36 +01:00
Vadim Petrochenkov 1ab8ca3532 Address review comments 2019-03-12 10:37:15 +03:00
Vadim Petrochenkov 79c3651988 syntax: Optimize maybe_whole/maybe_whole_expr slightly 2019-03-12 10:25:03 +03:00
Vadim Petrochenkov 18229bb1ad syntax: Better recovery for $ty::AssocItem and ty!()::AssocItem 2019-03-12 10:25:03 +03:00
Esteban Küber f690821d58 review comments 2019-03-09 11:08:51 -08:00
topecongiro 2309625941 Expose new_sub_parser_from_file
This function is useful when external tools like rustfmt want to parse
internal files without parsing a whole crate.
2019-03-09 21:59:54 +09:00
bors c9f8304351 Auto merge of #59012 - pietroalbini:rollup, r=pietroalbini
Rollup of 24 pull requests

Successful merges:

 - #58080 (Add FreeBSD armv6 and armv7 targets)
 - #58204 (On return type `impl Trait` for block with no expr point at last semi)
 - #58269 (Add librustc and libsyntax to rust-src distribution.)
 - #58369 (Make the Entry API of HashMap<K, V> Sync and Send)
 - #58861 (Expand where negative supertrait specific error is shown)
 - #58877 (Suggest removal of `&` when borrowing macro and appropriate)
 - #58883 (Suggest appropriate code for unused field when destructuring pattern)
 - #58891 (Remove stray ` in the docs for the FromIterator implementation for Option)
 - #58893 (race condition in thread local storage example)
 - #58906 (Monomorphize generator field types for debuginfo)
 - #58911 (Regression test for #58435.)
 - #58912 (Regression test for #58813)
 - #58916 (Fix release note problems noticed after merging.)
 - #58918 (Regression test added for an async ICE.)
 - #58921 (Add an explicit test for issue #50582)
 - #58926 (Make the lifetime parameters of tcx consistent.)
 - #58931 (Elide invalid method receiver error when it contains TyErr)
 - #58940 (Remove JSBackend from config.toml)
 - #58950 (Add self to mailmap)
 - #58961 (On incorrect cfg literal/identifier, point at the right span)
 - #58963 (libstd: implement Error::source for io::Error)
 - #58970 (delay_span_bug in wfcheck's ty.lift_to_tcx unwrap)
 - #58984 (Teach `-Z treat-err-as-bug` to take a number of errors to emit)
 - #59007 (Add a test for invalid const arguments)

Failed merges:

 - #58959 (Add release notes for PR #56243)

r? @ghost
2019-03-09 05:19:48 +00:00
Esteban Küber 0a505a71d3 Parse lifetimes that start with a number and give specific error 2019-03-08 16:56:31 -08:00
Pietro Albini 72d4c1ed67 Rollup merge of #58984 - estebank:multi-treat-err-as-bug, r=oli-obk
Teach `-Z treat-err-as-bug` to take a number of errors to emit

`-Z treat-err-as-bug` will cause `rustc` to panic after the first error is reported, like previously. `-Z treat-err-as-bug=2` will cause `rustc` to panic after 2 errors have been reported.

Fix #58983.
2019-03-08 09:42:13 +01:00
Pietro Albini 54a5073af9 Rollup merge of #58961 - estebank:issue-58462, r=varkor
On incorrect cfg literal/identifier, point at the right span

CC #58462
2019-03-08 09:42:09 +01:00
Vadim Petrochenkov e19b228959 Improve recovery for missing trait in a trait impl 2019-03-08 00:24:02 +03:00
Wesley Norris 00887f39d1 Adds diagnostic message and UI test. 2019-03-07 23:18:12 +03:00
Esteban Küber bc9b936290 Fix with_emitter callers 2019-03-07 11:15:47 -08:00
Esteban Küber 7a55a004fa Make -Z treat-err-as-bug take a number of errors to be emitted
`-Z treat-err-as-bug=0` will cause `rustc` to panic after the first
error is reported. `-Z treat-err-as-bug=2` will cause `rustc` to
panic after 3 errors have been reported.
2019-03-06 19:51:32 -08:00
Esteban Küber 551ea65c87 Rely on drop to emit unclosed delims 2019-03-06 19:09:24 -08:00
Esteban Küber 6f0f2fc6d6 Simplify code 2019-03-06 18:46:11 -08:00
Esteban Küber f156d92207 Always emit mismatched delim errors, never panic 2019-03-06 18:46:11 -08:00
Esteban Küber ac6cc2d6b0 Collect unclosed delimiters in parent parser 2019-03-06 18:46:11 -08:00
Esteban Küber 51d0e86c22 Emit missing unclosed delimiter errors 2019-03-06 18:46:11 -08:00
Esteban Küber c70a516c23 Panic when unmatched delimiters aren't emitted 2019-03-06 18:46:11 -08:00
Esteban Küber ed2de5a842 Emit unclosed delimiters during recovery 2019-03-06 18:45:59 -08:00
Esteban Küber cc535a2a19 Bail when encountering a second unexpected token in the same span 2019-03-06 18:45:59 -08:00
Esteban Küber 2ec7d0b228 Do not panic on missing close paren
Fix #58856.
2019-03-06 18:45:59 -08:00
Esteban Küber 02eb523d91 Surround found token with ` 2019-03-06 14:45:23 -08:00
Esteban Küber 669be1a0a6 On incorrect cfg literal/identifier, point at the right span 2019-03-05 19:05:03 -08:00
Esteban Küber dc4973dfd9 Expand where negative supertrait specific error is shown
Fix #58857.
2019-03-01 14:42:39 -08:00
bors 1999a22881 Auto merge of #57760 - dlrobertson:varargs1, r=alexreg
Support defining C compatible variadic functions

## Summary

Add support for defining C compatible variadic functions in unsafe rust with
`extern "C"` according to [RFC 2137].

## Details

### Parsing
When parsing a user defined function that is `unsafe` and `extern "C"` allow
variadic signatures and inject a "spoofed" `VaList` in the new functions
signature. This allows the user to interact with the variadic arguments via a
`VaList` instead of manually using `va_start` and `va_end` (See [RFC 2137] for
details).

### Codegen

When running codegen for a variadic function, remove the "spoofed" `VaList`
from the function signature and inject `va_start` when the arg local
references are created for the function and `va_end` on return.

## TODO

 - [x] Get feedback on injecting `va_start/va_end` in MIR vs codegen
 - [x] Properly inject `va_end` - It seems like it should be possible to inject
       `va_end` on the `TerminatorKind::Return`. I just need to figure out how
       to get the `LocalRef` here.
 - [x] Properly call Rust defined C variadic functions in Rust - The spoofed
       `VaList` causes problems here.

Related to: #44930

r? @ghost

[RFC 2137]: https://github.com/rust-lang/rfcs/blob/master/text/2137-variadic.md
2019-02-28 15:00:25 +00:00
Dan Robertson 08bd4ff998 Rename variadic to c_variadic
Function signatures with the `variadic` member set are actually
C-variadic functions. Make this a little more explicit by renaming the
`variadic` boolean value, `c_variadic`.
2019-02-27 10:21:54 -05:00
Dan Robertson 58147d486b Support defining C compatible variadic functions
Add support for defining C compatible variadic functions in unsafe rust
with extern "C".
2019-02-27 10:21:35 -05:00
Mazdak Farrokhzad f84a8cf28a Rollup merge of #58678 - doctorn:refuse-async-fn-2015-edition, r=varkor
Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves #58652 and also resolves #53714.

r? @varkor
2019-02-27 13:32:21 +01:00