Commit Graph

472 Commits

Author SHA1 Message Date
John Kåre Alsaker cbdf4ec03e Remove syntax and syntax_pos thread locals 2018-03-14 11:56:01 +01:00
John Kåre Alsaker 728c16c88f Move REGISTERED_DIAGNOSTICS to a ParseSess field 2018-03-08 05:30:43 +01:00
John Kåre Alsaker b74e97cf42 Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00
Seiichi Uchida 291c51b9c8 Fix up tests and typos 2018-02-18 00:10:40 +09:00
Seiichi Uchida b5099a708d Replace dummy spans with empty spans 2018-02-18 00:10:40 +09:00
Seiichi Uchida d6bdf296a4 Change ast::Visibility to Spanned type 2018-02-18 00:10:40 +09:00
John Kåre Alsaker 9a8d6b8bb5 Do not capture stderr in the compiler. Instead just panic silently for fatal errors 2018-01-26 04:52:30 +01:00
Eduard-Mihai Burtescu 210ac01792 rustc: use {U,I}size instead of {U,I}s shorthands. 2018-01-04 03:12:04 +02:00
bors c2ecab1121 Auto merge of #46732 - estebank:silence-recovered-blocks, r=petrochenkov
Do not emit type errors on recovered blocks

When a parse error occurs on a block, the parser will recover and create
a block with the statements collected until that point. Now a flag
stating that a recovery has been performed in this block is propagated
so that the type checker knows that the type of the block (which will be
identified as `()`) shouldn't be checked against the expectation to
reduce the amount of irrelevant diagnostic errors shown to the user.

Fix #44579.
2017-12-22 07:22:33 +00:00
Esteban Küber aaf3e318fc Do not emit type errors on recovered blocks
When a parse error occurs on a block, the parser will recover and create
a block with the statements collected until that point. Now a flag
stating that a recovery has been performed in this block is propagated
so that the type checker knows that the type of the block (which will be
identified as `()`) shouldn't be checked against the expectation to
reduce the amount of irrelevant diagnostic errors shown to the user.
2017-12-21 14:57:42 -08:00
Jonas Platte 78493ed21a Add GenericParam, refactor Generics in ast, hir, rustdoc
The Generics now contain one Vec of an enum for the generic parameters,
rather than two separate Vec's for lifetime and type parameters.

Additionally, places that previously used Vec<LifetimeDef> now use
Vec<GenericParam> instead.
2017-12-21 13:38:10 +01:00
Taylor Cramer 07f51fb868 Implement non-mod.rs mod statements 2017-12-19 14:58:51 -08:00
Oliver Schneider d732da813b Use PathBuf instead of String where applicable 2017-12-14 11:22:08 +01:00
bors 11f64d8f88 Auto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkov
Accept underscores in unicode escapes

Fixes #43692.

I don't know if this need an RFC, but at least the impl is here!
2017-09-12 01:25:23 +00:00
Vadim Petrochenkov 3da868dcb6 Make fields of Span private 2017-08-30 01:38:54 +03:00
Malo Jaffré d4e0e52281 Accept underscores in unicode escapes
Fixes #43692.
2017-08-17 20:03:32 +02:00
Zack M. Davis 1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
Bastien Orivel 47cb3c5bc2 Fix some typos 2017-08-11 00:16:18 +02:00
Tobias Schottdorf 851c77088d default binding modes: add pat_binding_modes
This PR kicks off the implementation of the [default binding modes RFC][1] by
introducing the `pat_binding_modes` typeck table mentioned in the [mentoring
instructions][2].

`pat_binding_modes` is populated in `librustc_typeck/check/_match.rs` and
used wherever the HIR would be scraped prior to this PR. Unfortunately, one
blemish, namely a two callers to `contains_explicit_ref_binding`, remains.
This will likely have to be removed when the second part of [1], the
`pat_adjustments` table, is tackled. Appropriate comments have been added.

See #42640.

[1]: https://github.com/rust-lang/rfcs/pull/2005
[2]: https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
2017-07-30 10:19:53 -04:00
Mark Simulacrum e61e73fcc4 Rollup merge of #43501 - topecongiro:span-to-whereclause, r=nrc
Add Span to ast::WhereClause

This PR adds `Span` field to `ast::WhereClause`. The motivation here is to make rustfmt's life easier when recovering comments before and after where clause.
r? @nrc
2017-07-29 18:03:52 -06:00
Alex Crichton 4886ec8665 syntax: Capture a TokenStream when parsing items
This is then later used by `proc_macro` to generate a new
`proc_macro::TokenTree` which preserves span information. Unfortunately this
isn't a bullet-proof approach as it doesn't handle the case when there's still
other attributes on the item, especially inner attributes.

Despite this the intention here is to solve the primary use case for procedural
attributes, attached to functions as outer attributes, likely bare. In this
situation we should be able to now yield a lossless stream of tokens to preserve
span information.
2017-07-28 10:47:01 -07:00
topecongiro 6375b77ebb Add Span to ast::WhereClause 2017-07-29 00:43:35 +09:00
Alex Crichton d316874c87 Update and fix a few tests 2017-06-26 02:08:14 +00:00
Jeffrey Seyfried d4488b7df9 Simplify hygiene::Mark application, and
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-26 02:05:45 +00: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
Andre Bogus 958c67d9c8 adressed comments by @kennytm and @petrochenkov 2017-05-15 23:56:09 +02: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
ubsan 0be875827f fix the easy features in libsyntax 2017-05-07 01:20:15 -07: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
Jeffrey Seyfried 8fde04b4a2 Improve Path spans. 2017-03-30 05:44:56 +00:00
Jeffrey Seyfried f08d5ad4c5 Refactor how spans are combined in the parser. 2017-03-29 11:17:59 +00:00
bors 9c15de4fd5 Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
`TokenStream`-based attributes, paths in attribute and derive macro invocations

This PR
 - refactors `Attribute` to use  `Path` and `TokenStream` instead of `MetaItem`.
 - supports macro invocation paths for attribute procedural macros.
   - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;`
 - supports macro invocation paths for derive procedural macros.
   - e.g. `#[derive(foo::Bar, super::Baz)] struct S;`
 - supports arbitrary tokens as arguments to attribute procedural macros.
   - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;`
 - supports using arbitrary tokens in "inert attributes" with derive procedural macros.
   - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);`
where `#[proc_macro_derive(Foo, attributes(inert))]`

r? @nrc
2017-03-19 10:56:08 +00:00
Jeffrey Seyfried 68c1cc68b4 Refactor Attribute to use Path and TokenStream instead of MetaItem. 2017-03-14 04:03:43 +00:00
Vadim Petrochenkov 32575a0487 Give spans to individual path segments in AST 2017-03-10 08:21:45 -08:00
Jeffrey Seyfried 0d554139ad Fix fallout in unit tests. 2017-03-03 02:15:39 +00:00
Jeffrey Seyfried f6eaaf350e Integrate TokenStream. 2017-03-03 02:15:37 +00:00
Jeffrey Seyfried 0143774cb5 Remove lifetime parameter from syntax::tokenstream::Cursor. 2017-03-03 01:52:48 +00:00
Jeffrey Seyfried 61a9a14d29 Add warning cycle. 2017-02-28 22:15:12 +00:00
Jeffrey Seyfried d8b34e9a74 Add syntax::ext::tt::quoted::{TokenTree, ..} and remove tokenstream::TokenTree::Sequence. 2017-02-28 22:14:29 +00:00
Alex Crichton 626e754473 Bump version, upgrade bootstrap
This commit updates the version number to 1.17.0 as we're not on that version of
the nightly compiler, and at the same time this updates src/stage0.txt to
bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03 13:25:46 -08:00
Jeffrey Seyfried 49f5b0a8cf Remove open_span and close_span from Delimited. 2017-01-23 06:49:06 +00:00
Jeffrey Seyfried 2dc60b1180 Refactor TokenStream. 2017-01-22 21:37:38 +00:00
Alex Crichton 17294d98b9 Rollup merge of #39118 - jseyfried:token_tree_based_parser, r=nrc
Refactor the parser to consume token trees

This is groundwork for efficiently parsing attribute proc macro invocations, bang macro invocations, and `TokenStream`-based attributes and fragment matchers.

This improves parsing performance by 8-15% and expansion performance by 0-5% on a sampling of the compiler's crates.

r? @nrc
2017-01-20 08:35:47 -08:00
Jeffrey Seyfried debcbf0b8e Refactor the parser to consume token trees. 2017-01-17 08:17:26 +00:00
Jeffrey Seyfried de46b24758 Introduce string_reader.parse_all_token_trees(). 2017-01-17 08:16:49 +00:00
Jeffrey Seyfried 6466f55ebc Give the StringReader a sess: &ParseSess. 2017-01-17 08:16:47 +00:00
Vadim Petrochenkov 03620dba25 Use resizable Vec instead of P<[T]> in AST 2017-01-17 01:54:59 +03:00
Simonas Kazlauskas b0e55a83a8 Such large. Very 128. Much bits.
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which
understands and supports 128-bit integers throughout.

The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to
iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported,
this strategy is good enough to get past the first bootstrap stages to end up with a fully working
128-bit capable compiler.

In order for this strategy to work, number of locations had to be changed to use associated
max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?)
had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works
(former not necessarily producing the right results in stage1).

This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-30 15:15:44 +01: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