Commit Graph

2609 Commits

Author SHA1 Message Date
bors
8d65c8d64e Auto merge of #38268 - withoutboats:parse_where_higher_rank_hack, r=eddyb
Prevent where < ident > from parsing.

In order to be forward compatible with `where<'a>` syntax for higher
rank parameters, prevent potential conflicts with UFCS from parsing
correctly for the near term.
2016-12-24 00:22:00 +00:00
Jeffrey Seyfried
f10f50b426 Refactor how global paths are represented (for both ast and hir). 2016-12-22 06:14:35 +00:00
Jeffrey Seyfried
8e61ff25d8 Optimize ast::PathSegment. 2016-12-19 20:57:00 +00:00
bors
ec8bb45624 Auto merge of #38279 - KalitaAlexey:issue-8521, r=jseyfried
macros: allow a `path` fragment to be parsed as a type parameter bound

Allow a `path` fragment to be parsed as a type parameter bound.
Fixes #8521.
2016-12-17 21:49:51 +00:00
bors
f99d4dfef2 Auto merge of #38205 - jseyfried:fix_module_directory_regression, r=eddyb
macros: fix the expected paths for a non-inline module matched by an `item` fragment

Fixes #38190.
r? @nrc
2016-12-17 06:43:16 +00:00
Kalita Alexey
12a6cf1123 Allow path fragments to be parsed as type parameter bounds in macro expansion 2016-12-16 14:16:46 +03:00
bors
b4b1e5ece2 Auto merge of #38049 - frewsxcv:libunicode, r=alexcrichton
Rename 'librustc_unicode' crate to 'libstd_unicode'.

Fixes https://github.com/rust-lang/rust/issues/26554.
2016-12-12 13:19:33 +00:00
Without Boats
14e4b00933 Fix mistake. 2016-12-09 21:17:58 -08:00
Without Boats
ddae271b78 Improve error message. 2016-12-09 20:39:42 -08:00
Without Boats
90f6219f49 Prevent where < ident > from parsing.
In order to be forward compatible with `where<'a>` syntax for higher
rank parameters, prevent potential conflicts with UFCS from parsing
correctly for the near term.
2016-12-09 10:54:05 -08:00
Jeffrey Seyfried
fd98a8d795 macros: fix the expected paths for a non-inline module matched by an item fragment. 2016-12-07 10:56:55 +00:00
Oliver Schneider
5e51edb0de
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor 2016-12-06 11:28:51 +01:00
Corey Farwell
274777a158 Rename 'librustc_unicode' crate to 'libstd_unicode'.
Fixes #26554.
2016-11-30 01:24:01 -05:00
Vadim Petrochenkov
7d15250b0e Support ?Sized in where clauses 2016-11-25 00:43:00 +03:00
bors
1cabe21512 Auto merge of #37487 - goffrie:break, r=nikomatsakis
Implement the `loop_break_value` feature.

This implements RFC 1624, tracking issue #37339.
- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
  currently deduced type of that loop, the desired type, and a list of
  break expressions currently seen. `loop` loops get a fresh type
  variable as their initial type (this logic is stolen from that for
  arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
  `expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop.
- ~~I have also changed the loop scoping in MIR-building so that the test
  of a while loop is not considered to be part of that loop. This makes
  the rules consistent with #37360. The new loop scopes in typeck also
  follow this rule. That means that `loop { while (break) {} }` now
  terminates instead of looping forever. This is technically a breaking
  change.~~
- ~~On that note, expressions like `while break {}` and `if break {}` no
  longer parse because `{}` is interpreted as an expression argument to
  `break`. But no code except compiler test cases should do that anyway
  because it makes no sense.~~
- The RFC did not make it clear, but I chose to make `break ()` inside
  of a `while` loop illegal, just in case we wanted to do anything with
  that design space in the future.

This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-11-22 17:51:59 -06:00
Geoffry Song
9d42549df4
Implement the loop_break_value feature.
This implements RFC 1624, tracking issue #37339.

- `FnCtxt` (in typeck) gets a stack of `LoopCtxt`s, which store the
  currently deduced type of that loop, the desired type, and a list of
  break expressions currently seen. `loop` loops get a fresh type
  variable as their initial type (this logic is stolen from that for
  arrays). `while` loops get `()`.
- `break {expr}` looks up the broken loop, and unifies the type of
  `expr` with the type of the loop.
- `break` with no expr unifies the loop's type with `()`.
- When building MIR, `loop` loops no longer construct a `()` value at
  termination of the loop; rather, the `break` expression assigns the
  result of the loop. `while` loops are unchanged.
- `break` respects contexts in which expressions may not end with braced
  blocks. That is, `while break { break-value } { while-body }` is
  illegal; this preserves backwards compatibility.
- The RFC did not make it clear, but I chose to make `break ()` inside
  of a `while` loop illegal, just in case we wanted to do anything with
  that design space in the future.

This is my first time dealing with this part of rustc so I'm sure
there's plenty of problems to pick on here ^_^
2016-11-21 20:20:42 -08:00
Jeffrey Seyfried
fa8c53bae4 Start warning cycle. 2016-11-22 01:52:04 +00:00
Jeffrey Seyfried
5675d9d280 Clean up directory ownership semantics. 2016-11-22 01:48:10 +00:00
Jeffrey Seyfried
a8e86f0f81 Fix fallout in rustdoc and tests. 2016-11-21 12:16:46 +00:00
Jeffrey Seyfried
36c8f6b0d3 Cleanup InternedString. 2016-11-21 09:00:56 +00:00
Jeffrey Seyfried
e85a0d70b8 Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Jeffrey Seyfried
d2f8fb0a0a Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00
Jeffrey Seyfried
f177a00ac9 Refactor P<ast::MetaItem> -> ast::MetaItem. 2016-11-20 12:36:41 +00:00
Jeffrey Seyfried
e97686d048 Move MetaItemKind's Name to a field of MetaItem. 2016-11-20 12:36:30 +00:00
Jeffrey Seyfried
4b9b0d3474 Refactor CrateConfig. 2016-11-20 12:35:57 +00:00
Jeffrey Seyfried
a2626410d7 Refactor MetaItemKind to use Names instead of InternedStrings. 2016-11-20 11:46:06 +00:00
Jeffrey Seyfried
ff4994235a Avoid clearing the string interner. 2016-11-20 11:46:01 +00:00
Jeffrey Seyfried
3ea2bc4e93 Refactor away ast::Attribute_. 2016-11-20 11:46:00 +00:00
bors
8289a8916f Auto merge of #37278 - matklad:lone-lifetime, r=jseyfried
Fix syntax error in the compiler

Currently `rustc` accepts the following code: `fn f<'a>() where 'a {}`. This should be a syntax error, shouldn't it?

Not sure if my changes actually compile, waiting for the LLVM to build.
2016-11-14 02:46:12 -08:00
Aleksey Kladov
cf9ff2b59b Fix where clauses parsing
Don't allow lifetimes without any bounds at all
2016-11-14 10:23:20 +03:00
bors
876b761010 Auto merge of #37753 - est31:master, r=petrochenkov
Fix empty lifetime list or one with trailing comma being rejected

Fixes #37733
2016-11-13 09:53:30 -08:00
est31
34f33ec789 Fix empty lifetime list or one with trailing comma being rejected
Fixes #37733
2016-11-13 17:55:17 +01:00
Eduard Burtescu
49772fbf5d syntax: don't fake a block around closures' bodies during parsing. 2016-11-10 01:44:45 +02:00
Jeffrey Seyfried
b7eed53b55 Remove field TtReader::next_tok. 2016-11-04 02:39:20 +00:00
Jeffrey Seyfried
23ad6fdb66 Improve tt-heavy expansion performance. 2016-11-04 02:38:54 +00:00
Jeffrey Seyfried
7ae083383d Move doc comment desugaring into the parser. 2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
e2b3fec778 Avoid recontructing the Parser in macro_parser.rs. 2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
6e9bf12c6f Reimplement "macros: Improve tt fragments" with better performance. 2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
eb3ac29a10 Reduce the size of Token and make it cheaper to clone by refactoring
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-11-03 23:48:24 +00:00
Jeffrey Seyfried
5f280a5c60 Clean up parser.parse_token_tree(). 2016-11-03 23:48:24 +00:00
iirelu
e593c3b893 Changed most vec! invocations to use square braces
Most of the Rust community agrees that the vec! macro is clearer when
called using square brackets [] instead of regular brackets (). Most of
these ocurrences are from before macros allowed using different types of
brackets.

There is one left unchanged in a pretty-print test, as the pretty
printer still wants it to have regular brackets.
2016-10-31 22:51:40 +00:00
Jeffrey Seyfried
cbd24757eb Move CrateConfig from Crate to ParseSess. 2016-10-29 07:52:58 +00:00
bors
f0ab4a4f2a Auto merge of #37367 - jseyfried:import_crate_root, r=nrc
Support `use *;` and `use ::*;`.

Fixes #31484.
r? @nrc
2016-10-28 13:42:23 -07:00
Guillaume Gomez
f02577d491 Rollup merge of #36206 - mcarton:35755, r=pnkfelix
Fix bad error message with `::<` in types

Fix #36116.

Before:
```rust
error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^

error: chained comparison operators require parentheses
  --> src/test/compile-fail/issue-36116.rs:16:52
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                    ^^^^^^
   |
   = help: use `::<...>` instead of `<...>` if you meant to specify type arguments

error: expected expression, found `)`
  --> src/test/compile-fail/issue-36116.rs:16:57
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                         ^

error: expected identifier, found `<`
  --> src/test/compile-fail/issue-36116.rs:20:17
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |                 ^

error: aborting due to 5 previous errors
```

After:
```rust
error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:16:50
   |
16 |     let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>);
   |                                                  ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: unexpected token: `::`
  --> src/test/compile-fail/issue-36116.rs:20:15
   |
20 |     let g: Foo::<i32> = Foo { _a: 42 };
   |               ^^
   |
   = help: use `<...>` instead of `::<...>` if you meant to specify type arguments

error: aborting due to 2 previous errors
```
2016-10-28 17:05:47 +02:00
mcarton
f7cc6dc1ed
Fix bad error message with ::< in types 2016-10-28 12:52:41 +02:00
bors
07436946b6 Auto merge of #37245 - goffrie:recovery, r=nrc
Recover out of an enum or struct's braced block.

If we encounter a syntax error inside of a braced block, then we should
fail by consuming the rest of the block if possible.
This implements such recovery for enums and structs.

Fixes #37113.
2016-10-27 07:19:16 -07:00
Geoffry Song
c9036ccffe Recover out of an enum or struct's braced block.
If we encounter a syntax error inside of a braced block, then we should
fail by consuming the rest of the block if possible.
This implements such recovery for enums and structs.

Fixes #37113.
2016-10-26 22:27:14 -04:00
Eduard Burtescu
9908711e5e Implement field shorthands in struct literal expressions. 2016-10-27 03:15:13 +03:00
Jeffrey Seyfried
4a93648689 Support use *; and use ::*;. 2016-10-23 22:02:39 +00:00
Vadim Petrochenkov
fea630ef9d Tweak path parsing logic 2016-10-20 20:28:10 +03:00