Commit Graph

2583 Commits

Author SHA1 Message Date
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
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
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
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 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
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
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
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 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 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
Nathan Corbyn 8300f51936 Deny async fn in 2015 edition
Fix style issues and update diagnostic messages

Update src/librustc_passes/diagnostics.rs

Co-Authored-By: doctorn <me@nathancorbyn.com>

Deny nested `async fn` in Rust 2015 edition

Deny nested `async fn` in Rust 2015 edition

Deny nested `async fn` in Rust 2015 edition
2019-02-24 16:33:12 +00:00
Mazdak Farrokhzad ae646687e0 Rollup merge of #57364 - hdhoang:33418_negative_bounds, r=estebank
Improve parsing diagnostic for negative supertrait bounds

closes #33418

r? @estebank
2019-02-24 05:55:55 +01:00
Mazdak Farrokhzad 2db0e489bc Rollup merge of #58654 - estebank:underflow, r=nikomatsakis
Do not underflow after resetting unmatched braces count

Fix #58638.

r? @oli-obk
2019-02-23 09:25:36 +01:00
Mazdak Farrokhzad 585d4d29d9 Rollup merge of #58476 - nnethercote:rm-LazyTokenStream, r=petrochenkov
Remove `LazyTokenStream`.

`LazyTokenStream` was added in #40939. Perhaps it was an effective optimization then, but no longer. This PR removes it, making the code both simpler and faster.

r? @alexcrichton
2019-02-23 09:25:26 +01:00
Hoàng Đức Hiếu 7cfddfb4e4 Improve parsing diagnostic for negative supertrait bounds 2019-02-23 07:58:16 +07:00
Esteban Küber cc1cd83657 Do not underflow after resetting unmatched braces count
Fix #58638.
2019-02-22 11:52:03 -08:00
Mazdak Farrokhzad 894141b57d Rollup merge of #58198 - igorsdv:suggest-removing-parentheses-surrounding-lifetimes, r=estebank
Suggest removing parentheses surrounding lifetimes

Fixes #57386.

r? @estebank
2019-02-22 14:57:59 +01:00
Dan Robertson f8b6449f80 Fix style nits
Fix style nits discovered in reading code.
2019-02-18 22:22:19 +00:00
Nicholas Nethercote f8801f3bf6 Remove LazyTokenStream.
It's present within `Token::Interpolated` as an optimization, so that if
a nonterminal is converted to a `TokenStream` multiple times, the
first-computed value is saved and reused.

But in practice it's not needed. `interpolated_to_tokenstream()` is a
cold function: it's only called a few dozen times while compiling rustc
itself, and a few hundred times across the entire `rustc-perf` suite.
Furthermore, when it is called, it is almost always the first
conversion, so no benefit is gained from it.

So this commit removes `LazyTokenStream`, along with the now-unnecessary
`Token::interpolated()`.

As well as a significant simplification, the removal speeds things up
slightly, mostly due to not having to `drop` the `LazyTokenStream`
instances.
2019-02-18 09:46:33 +11:00