Commit Graph

4192 Commits

Author SHA1 Message Date
Yuki Okushi 9617014aa6 Clarify diagnostics when using ~ as a unary op 2019-10-18 18:15:16 +09:00
Mazdak Farrokhzad 1a26fdf9b2 ui-fulldeps: make them pass again? 2019-10-16 17:21:32 +02:00
Mazdak Farrokhzad be40bbd2fb make tidy happy 2019-10-16 11:19:39 +02:00
Mazdak Farrokhzad 9dc07b05d5 parser: leave a FIXME for later 2019-10-16 10:59:54 +02:00
Mazdak Farrokhzad bf02d49e84 move SeqSep to parser.rs 2019-10-16 10:59:54 +02:00
Mazdak Farrokhzad d420d719c4 move syntax::ext to new crate syntax_expand 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad d160a4e422 syntax::parse: don't depend on syntax::ext 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad c189565edc syntax: reduce visibilities 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 98017ca53a move diagnostics.rs into parser/ 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 41bfe94d40 syntax: extract parse_cfg_attr 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 7d7969d065 syntax: extract parse_derive_paths 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad 9dba03f6cd move parse::attr -> parse::parser::attr 2019-10-16 10:59:53 +02:00
Mazdak Farrokhzad bc3e97a277 Rollup merge of #65426 - nnethercote:rm-custom-LocalInternedString-PartialEq-impls, r=petrochenkov
Remove custom `PartialEq` impls for `LocalInternedString`.

This is on-trend with the recent changes simplifying
`LocalInternedString` and reducing its use.

r? @petrochenkov
2019-10-15 13:27:29 +02:00
Mazdak Farrokhzad ae156a56d4 syntax::parse::sess -> syntax::sess 2019-10-15 09:41:58 +02:00
Mazdak Farrokhzad 79d02867b8 move parse_lit to expr.rs 2019-10-15 09:27:52 +02:00
Mazdak Farrokhzad 52d0e86b9a syntax: extract sess.rs for ParseSess 2019-10-15 09:25:56 +02:00
Mazdak Farrokhzad c29fe81ec4 move maybe_report_invalid_custom_discriminants to feature_gate 2019-10-15 09:22:13 +02:00
Nicholas Nethercote 57d33b155f Remove custom PartialEq impls for LocalInternedString.
This is on-trend with the recent changes simplifying
`LocalInternedString` and reducing its use.
2019-10-15 14:23:27 +11:00
Tyler Mandry 1b182371e1 Rollup merge of #65410 - Centril:intersection-pat-recover, r=davidtwco,varkor
syntax: add parser recovery for intersection- / and-patterns `p1 @ p2`

Fixes https://github.com/rust-lang/rust/issues/65400.

The recovery comes in two flavors:

1. We know that `p2` is a binding so we can invert as `p2 @ p1`:

```rust
error: pattern on wrong side of `@`
  --> $DIR/intersection-patterns.rs:13:9
   |
LL |         Some(x) @ y => {}
   |         -------^^^-
   |         |         |
   |         |         binding on the right, should be to the left
   |         pattern on the left, should be to the right
   |         help: switch the order: `y @ Some(x)`
```

2. Otherwise we emit a generic diagnostic for the lack of support for intersection patterns:

```rust
error: left-hand side of `@` must be a binding
  --> $DIR/intersection-patterns.rs:23:9
   |
LL |         Some(x) @ Some(y) => {}
   |         -------^^^-------
   |         |         |
   |         |         also a pattern
   |         interpreted as a pattern, not a binding
   |
   = note: bindings are `x`, `mut x`, `ref x`, and `ref mut x`
```

For more on and-patterns, see e.g. https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching#and-pattern.

r? @davidtwco
cc @varkor @lzutao
2019-10-14 17:52:42 -07:00
Tyler Mandry 6d28ed1ae6 Rollup merge of #65261 - nnethercote:rm-Option-from-TokenStream, r=petrochenkov
Remove `Option` from `TokenStream`

A code simplification.

r? @petrochenkov
2019-10-14 17:52:35 -07:00
Mazdak Farrokhzad 3a9f8deb1d recover_intersection_pat: adjust wording 2019-10-14 18:02:49 +02:00
Mazdak Farrokhzad 72ad8f716b syntax: use PatKind::Wild as our ::Err equivalent. 2019-10-14 17:25:50 +02:00
Mazdak Farrokhzad 29fb07d245 syntax: add recovery for intersection patterns p1 @ p2 2019-10-14 17:08:13 +02:00
Mazdak Farrokhzad 28d08f3986 Rollup merge of #65392 - Centril:nt-to-tt, r=Mark-Simulacrum
Move `Nonterminal::to_tokenstream` to parser & don't rely directly on parser in lowering

Split out from https://github.com/rust-lang/rust/pull/65324.

r? @petrochenkov
2019-10-14 07:36:59 +02:00
Mazdak Farrokhzad 2800bc240e Rollup merge of #65363 - Centril:less-pprust, r=Mark-Simulacrum
Remove implicit dependencies on syntax::pprust

Part of https://github.com/rust-lang/rust/pull/65324.

The main goal here is to facilitate the eventual move of pprust out from libsyntax and because an AST definition typically should not depend on its pretty printer.

r? @estebank
2019-10-14 07:36:57 +02:00
Mazdak Farrokhzad 66e428824b Rollup merge of #65362 - Centril:extract_fun, r=petrochenkov
syntax: consolidate function parsing in item.rs

Extracted from https://github.com/rust-lang/rust/pull/65324.

r? @estebank
2019-10-14 07:36:55 +02:00
Nicholas Nethercote 1ce0347fd4 Use TokenStream::default() in more places. 2019-10-14 09:19:31 +11:00
Nicholas Nethercote 5c93492da9 Remove the Option in TokenStream.
It means an allocation is required to create an empty `TokenStream`, but
all other operations are simpler and marginally faster due to not having
to check for `None`. Overall it simplifies the code for a negligible
performance effect.

The commit also removes `TokenStream::empty` by implementing `Default`,
which is now possible.
2019-10-14 09:14:39 +11:00
Mazdak Farrokhzad 42f32f06d6 token: extract Nonterminal::to_tokenstream to parser. 2019-10-13 20:13:18 +02:00
Mazdak Farrokhzad 4a0c487d1b syntax: consolidate function parsing in item.rs 2019-10-13 14:32:12 +02:00
Mazdak Farrokhzad af54a3e91d Rollup merge of #65359 - Centril:sil, r=davidtwco
simplify integer_lit

Extracted from https://github.com/rust-lang/rust/pull/65324.

r? @davidtwco
2019-10-13 13:34:42 +02:00
Mazdak Farrokhzad 742ec4b9bf ast: remove implicit pprust dependency via Display.
Instead just use `pprust::path_to_string(..)` where needed.

This has two benefits:

a) The AST definition is now independent of printing it.
   (Therefore we get closer to extracting a data-crate.)

b) Debugging should be easier as program flow is clearer.
2019-10-13 06:58:51 +02:00
Mazdak Farrokhzad 7effe633b0 simplify integer_lit 2019-10-13 06:20:03 +02:00
Mazdak Farrokhzad 9f09387f53 syntax: simplify maybe_annotate_with_ascription 2019-10-13 06:14:07 +02:00
Mazdak Farrokhzad 6b23c22cca syntax: refactor with new fn parse_use_tree_glob_or_nested. 2019-10-07 06:47:24 +02:00
Mazdak Farrokhzad 9c6582a2c0 syntax: use parse_extern_abi more. 2019-10-07 06:18:47 +02:00
Mazdak Farrokhzad a7ba754b6c syntax: unify and simplify fn signature parsing. 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad 7f9638d5d4 syntax: unify trait parsing a bit. 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad 090f3fd0c9 syntax: further item parsing cleanup 2019-10-07 06:01:38 +02:00
Mazdak Farrokhzad 3bdbfbe8b9 syntax: de-dups in item parsing. 2019-10-07 05:59:56 +02:00
Mazdak Farrokhzad e0fe4be465 syntax: cleanup associated const parsing. 2019-10-07 05:59:56 +02:00
bors 4ac4809ccf Auto merge of #64906 - Aaron1011:feature/extern-const-fn, r=Centril
Add support for `const unsafe? extern fn`

This works just as you might expect - an `const extern fn` is a `const fn` that is callable from foreign code.

Currently, panicking is not allowed in `const`s. When https://github.com/rust-lang/rfcs/pull/2345 (https://github.com/rust-lang/rust/issues/51999) is stabilized, then panicking in an `const extern fn` will produce a compile-time error when invoked at compile time, and an abort when invoked at runtime.

Since this is extending the language (we're allowing the `const` keyword in a new context), I believe that this will need an FCP. However, it's a very minor change, so I didn't think that filing an RFC was necessary.

This will allow libc (and other FFI crates) to make many functions `const`, without having to give up on making them `extern` as well.

Tracking issue: https://github.com/rust-lang/rust/issues/64926.
2019-10-07 00:12:12 +00:00
Tyler Mandry f5c8e12a7e Rollup merge of #65123 - Centril:mac-invoc-in-mut-pat, r=estebank
Account for macro invocation in `let mut $pat` diagnostic.

Fixes https://github.com/rust-lang/rust/issues/65122.

r? @estebank
2019-10-05 21:55:07 -07:00
Tyler Mandry c7d7e3730a Rollup merge of #64909 - estebank:turbofish-reloaded, r=Centril
When encountering chained operators use heuristics to recover from bad turbofish
2019-10-05 21:54:52 -07:00
Mazdak Farrokhzad 5f94a53d1a Account for macro invocation in let mut $pat diagnostic. 2019-10-05 04:34:26 +02:00
Esteban Küber 02f57f83a9 review comments 2019-10-03 13:22:18 -07:00
Esteban Küber f1499a8646 review comments 2019-10-03 11:55:19 -07:00
Esteban Küber dfdc369b40 review comments 2019-10-03 11:55:19 -07:00
Esteban Küber d7dceaa0c5 Account for missing turbofish in paths too 2019-10-03 11:55:18 -07:00
Esteban Küber 6c9f298a8b review comments 2019-10-03 11:55:18 -07:00