Commit Graph

2767 Commits

Author SHA1 Message Date
petrochenkov b33fd6d759 Change some terminology around keywords and reserved identifiers 2017-06-29 15:19:53 +03:00
Vadim Petrochenkov e03948ef3e Make $crate a keyword 2017-06-29 15:19:52 +03:00
Alex Burka 0dfd9c30f2 syntax: allow negative integer literal expression to be interpolated as pattern 2017-06-27 18:39:38 +00:00
kennytm 4711982314 Removed as many "```ignore" as possible.
Replaced by adding extra imports, adding hidden code (`# ...`), modifying
examples to be runnable (sorry Homura), specifying non-Rust code, and
converting to should_panic, no_run, or compile_fail.

Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-23 15:31:53 +08:00
bors 44eeb2109b Auto merge of #42578 - estebank:recover-binop, r=nikomatsakis
Learn to parse `a as usize < b`

Parsing `a as usize > b` always works, but `a as usize < b` was a
parsing error because the parser would think the `<` started a generic
type argument for `usize`. The parser now attempts to parse as before,
and if a DiagnosticError is returned, try to parse again as a type with
no generic arguments. If this fails, return the original
`DiagnosticError`.

Fix #22644.
2017-06-16 03:31:09 +00:00
Esteban Küber ad260ffc88 Review comments
- generate error instead of warning
- remove `RewindPoint` and just keep a copy of `Parser` to rewind state.
- `dont_parse_generics: bool` -> `parse_generics: bool`
- remove `eat_lt`
- move error handling code to separate method
2017-06-15 08:45:24 -07:00
Esteban Küber 46a6af12aa Change < interpreted as generic arg start warning
```
warning: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
  --> $DIR/issue-22644.rs:16:33
   |
16 |     println!("{}", a as usize < b);
   |                               - ^ interpreted as generic argument
   |                               |
   |                               not interpreted as comparison
   |
help: if you want to compare the casted value then write:
   |     println!("{}", (a as usize) < b);
```
2017-06-12 10:22:08 -07:00
Esteban Küber 5fcfa08e98 Fix affected tests 2017-06-12 07:51:55 -07:00
Esteban Küber 3a7dbf48fe Suggest non-ambiguous comparison after cast
```
warning: `<` is interpreted as a start of generic arguments for `usize`, not comparison
  --> $DIR/issue-22644.rs:16:33
   |
16 |     println!("{}", a as usize < b);
   |                                 ^ expected one of `!`, `(`, `+`, `,`, `::`, or `>` here
   |
help: if you want to compare the casted value then write
   |     println!("{}", (a as usize) < b);
```
2017-06-11 23:47:26 -07:00
Esteban Küber a6d32153a6 Learn to parse a as usize < b
Parsing `a as usize > b` always works, but `a as usize < b` was a
parsing error because the parser would think the `<` started a generic
type argument for `usize`. The parser now attempts to parse as before,
and if a DiagnosticError is returned, try to parse again as a type with
no generic arguments. If this fails, return the original
`DiagnosticError`.
2017-06-11 13:40:04 -07:00
Masaki Hara ab72611d8f Replace some matches with try. 2017-06-07 12:15:39 +09:00
bors e862695158 Auto merge of #41990 - qnighy:disallow-underscore-suffix-for-string-like-literals, r=nikomatsakis
Disallow underscore suffix for string-like literals.

This patch turns string/bytestring/char/byte literals followed by an underscore, like `"Foo"_`, to an error.

`scan_optional_raw_name` will parse `_` as a valid raw name, but it will be rejected by the parser. I also considered just stopping parsing when the suffix is `_`, but in that case `"Foo"_` will be lexed as two valid tokens.

Fixes the latter half of #41723.
2017-06-06 02:56:17 +00:00
Mark Simulacrum 85e5e20363 Rollup merge of #42319 - Manishearth:const-extern, r=nikomatsakis
Improve error message for const extern fn

It's currently ``error: unmatched visibility `pub` ``, which is a nonsensical error in this context.
2017-06-02 09:10:43 -06:00
Manish Goregaokar 22c4ee365c Improve error message for const extern fn 2017-05-31 11:26:19 -07:00
Masaki Hara b670930933 Emit proper expectation for the "default" keyword. 2017-05-31 23:22:33 +09:00
Masaki Hara 54edfee71a Parse macros named "default" correctly. 2017-05-31 19:24:01 +09:00
Masaki Hara 0b8c3de678 Add warning cycle #42326. 2017-05-31 16:43:47 +09:00
Jeffrey Seyfried 7fdc1fb2e4 Hygienize lifetimes. 2017-05-25 05:52:09 +00:00
Jeffrey Seyfried 2a1d2edb82 Declarative macros 2.0 without hygiene. 2017-05-25 05:51:06 +00:00
Jeffrey Seyfried 9c6430b325 Refactor out ast::MacroDef. 2017-05-25 05:47:25 +00:00
Mark Simulacrum 989c8e86e1 Rollup merge of #42120 - euclio:unicode, r=arielb1
remove "much" from unicode diagnostic

The English seems slightly awkward to me, and it's unnecessary.
2017-05-24 19:50:00 -06:00
Andy Russell 9ad0dbab5b remove "much" from unicode diagnostic 2017-05-20 11:18:26 -04:00
Nick Cameron a2566301e1 Add an option to the parser to avoid parsing out of line modules
This is useful if parsing from stdin or a String and don't want to try and read in a module from another file. Instead we just leave a stub in the AST.
2017-05-18 11:03:07 +12:00
Mark Simulacrum 4066c8ec71 Rollup merge of #41957 - llogiq:clippy-libsyntax, r=petrochenkov
Fix some clippy warnings in libsyntax

This is mostly removing stray ampersands, needless returns and lifetimes. Basically a lot of small changes.
2017-05-16 17:31:50 -06:00
Andre Bogus 958c67d9c8 adressed comments by @kennytm and @petrochenkov 2017-05-15 23:56:09 +02:00
Masaki Hara ed6c6c9a11 Disallow underscore suffix for string-like literals. 2017-05-14 21:37:50 +09:00
Andre Bogus a9c163ebe9 Fix some clippy warnings in libsyntax
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-12 20:05:39 +02:00
Masaki Hara 7b535e1096 Disallow ._ in float literal. 2017-05-12 22:00:06 +09:00
Corey Farwell 933df894a6 Rollup merge of #41827 - qnighy:allow-bare-cr-in-nondoc-comment, r=estebank
Allow bare CR in ////-style comment.

Fixes #40624 in a way that bare CR is allowed in all non-doc comments.
2017-05-08 22:34:49 -04:00
Masaki Hara 0e8e45c740 Allow bare CR in ////-style comment. 2017-05-08 22:29:24 +09:00
Oliver Schneider dd87eabd83 Remove need for &format!(...) or &&"" dances in span_label calls 2017-05-08 12:56:15 +02:00
bors 9956e81c19 Auto merge of #41729 - ubsan:master, r=nrc
Delete features which are easily removed, in libsyntax
2017-05-07 22:59:30 +00:00
ubsan 0be875827f fix the easy features in libsyntax 2017-05-07 01:20:15 -07:00
acdenisSK a257d5afb0 Fix "an" usage 2017-05-06 16:06:38 +02:00
Corey Farwell 9b2aacfdbe Rollup merge of #41722 - F001:warnTilde, r=petrochenkov
Suggest `!` for bitwise negation when encountering a `~`

Fix #41679

Here is a program

```rust
fn main() {
    let x = ~1;
}
```

It's output:
```
error: `~` can not be used as an unary operator
 --> /home/fcc/temp/test.rs:4:13
  |
4 |     let x = ~1;
  |             ^^
  |
  = help: use `!` instead of `~` if you meant to bitwise negation
```

cc @bstrie
2017-05-05 17:35:28 -04:00
F001 a9d3b3498e Suggest ! for bitwise negation when encountering a ~ 2017-05-05 02:38:58 -07:00
Tommy Ip 05329e5780 Remove use of Self: Sized from libsyntax
The bound is not required for compiling but it prevents using `next_token()` from a trait object.

Fixes #33506.
2017-05-04 13:19:36 +01:00
bors 33535afda4 Auto merge of #40851 - oli-obk:multisugg, r=jonathandturner
Minimize single span suggestions into a label

changes

```
14 |     println!("☃{}", tup[0]);
   |                     ^^^^^^
   |
help: to access tuple elements, use tuple indexing syntax as shown
   |     println!("☃{}", tup.0);
```

into

```
14 |     println!("☃{}", tup[0]);
   |                     ^^^^^^ to access tuple elements, use `tup.0`
```

Also makes suggestions explicit in the backend in preparation of adding multiple suggestions to a single diagnostic. Currently that's already possible, but results in a full help message + modified code snippet per suggestion, and has no rate limit (might show 100+ suggestions).
2017-05-02 01:04:27 +00:00
bors 810ed98d08 Auto merge of #41542 - petrochenkov:objpars2, r=nikomatsakis
syntax: Parse trait object types starting with a lifetime bound

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

This was originally implemented in https://github.com/rust-lang/rust/pull/40043, then reverted, then there was some [agreement](https://github.com/rust-lang/rust/issues/39318#issuecomment-289108720) that it should be supported.
(This is hopefully the last PR related to bound parsing.)
2017-04-28 22:28:11 +00:00
bors 2971d491b9 Auto merge of #41508 - michaelwoerister:generic-path-remapping, r=alexcrichton
Implement a file-path remapping feature in support of debuginfo and reproducible builds

This PR adds the `-Zremap-path-prefix-from`/`-Zremap-path-prefix-to` commandline option pair and is a more general implementation of #41419. As opposed to the previous attempt, this implementation should enable reproducible builds regardless of the working directory of the compiler.

This implementation of the feature is more general in the sense that the re-mapping will affect *all* paths the compiler emits, including the ones in error messages.

r? @alexcrichton
2017-04-28 12:09:37 +00:00
bors 54ef80043a Auto merge of #37860 - giannicic:defaultimpl, r=nagisa
#37653 support `default impl` for specialization

this commit implements the first step of the `default impl` feature:

> all items in a `default impl` are (implicitly) `default` and hence
> specializable.

In order to test this feature I've copied all the tests provided for the
`default` method implementation (in run-pass/specialization and
compile-fail/specialization directories) and moved the `default` keyword
from the item to the impl.
See [referenced](https://github.com/rust-lang/rust/issues/37653) issue for further info

r? @aturon
2017-04-27 02:48:17 +00:00
Gianni Ciccarelli b48eb5e0be support default impl for specialization
`[default] [unsafe] impl` and typecheck
2017-04-26 14:43:09 +00:00
Michael Woerister 39ffea31df Implement a file-path remapping feature in support of debuginfo and reproducible builds. 2017-04-26 15:44:02 +02:00
Vadim Petrochenkov d349e87d61 Parse trait object types starting with a lifetime bound 2017-04-25 23:58:05 +03:00
Guillaume Gomez 3f97b2a65c Add ui tests 2017-04-25 12:21:28 +02:00
Oliver Schneider f4b1e2af68 Improve E0178 suggestion placement 2017-04-25 11:07:42 +02:00
Oliver Schneider 3a5567bad4 Address PR comments 2017-04-25 11:07:42 +02:00
Oliver Schneider b857a1a39f Update affected tests 2017-04-25 11:04:35 +02:00
Gianni Ciccarelli 715811d0be support default impl for specialization
pr review
2017-04-25 05:28:22 +00:00
Guillaume Gomez b10c04472b Remove strip prefix 2017-04-24 15:16:52 +02:00