about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2017-01-11syntax: struct field attributes and cfgBenjamin Saunders-3/+10
2016-12-30Such large. Very 128. Much bits.Simonas Kazlauskas-1/+3
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-24Auto merge of #38268 - withoutboats:parse_where_higher_rank_hack, r=eddybbors-0/+17
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-22Refactor how global paths are represented (for both ast and hir).Jeffrey Seyfried-7/+9
2016-12-19Optimize `ast::PathSegment`.Jeffrey Seyfried-26/+14
2016-12-17Auto merge of #38279 - KalitaAlexey:issue-8521, r=jseyfriedbors-1/+1
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-16Allow path fragments to be parsed as type parameter bounds in macro expansionKalita Alexey-1/+1
2016-12-09Fix mistake.Without Boats-1/+1
2016-12-09Improve error message.Without Boats-1/+1
2016-12-09Prevent where < ident > from parsing.Without Boats-0/+17
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-07macros: fix the expected paths for a non-inline module matched by an `item` ↵Jeffrey Seyfried-7/+8
fragment.
2016-11-25Support `?Sized` in where clausesVadim Petrochenkov-27/+10
2016-11-22Auto merge of #37487 - goffrie:break, r=nikomatsakisbors-5/+15
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-21Implement the `loop_break_value` feature.Geoffry Song-5/+15
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-22Start warning cycle.Jeffrey Seyfried-10/+36
2016-11-22Clean up directory ownership semantics.Jeffrey Seyfried-55/+51
2016-11-21Cleanup `InternedString`.Jeffrey Seyfried-1/+1
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-42/+22
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-5/+6
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-3/+1
2016-11-14Auto merge of #37278 - matklad:lone-lifetime, r=jseyfriedbors-1/+1
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-14Fix where clauses parsingAleksey Kladov-1/+1
Don't allow lifetimes without any bounds at all
2016-11-13Auto merge of #37753 - est31:master, r=petrochenkovbors-3/+3
Fix empty lifetime list or one with trailing comma being rejected Fixes #37733
2016-11-13Fix empty lifetime list or one with trailing comma being rejectedest31-3/+3
Fixes #37733
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-16/+3
2016-11-04Improve `tt`-heavy expansion performance.Jeffrey Seyfried-1/+8
2016-11-03Move doc comment desugaring into the parser.Jeffrey Seyfried-0/+11
2016-11-03Reimplement "macros: Improve `tt` fragments" with better performance.Jeffrey Seyfried-18/+61
2016-11-03Reduce the size of `Token` and make it cheaper to clone by refactoringJeffrey Seyfried-143/+44
`Token::Interpolated(Nonterminal)` -> `Token::Interpolated(Rc<Nonterminal>)`.
2016-11-03Clean up `parser.parse_token_tree()`.Jeffrey Seyfried-22/+13
2016-10-31Changed most vec! invocations to use square bracesiirelu-4/+4
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-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-16/+3
2016-10-28Auto merge of #37367 - jseyfried:import_crate_root, r=nrcbors-4/+9
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
2016-10-28Rollup merge of #36206 - mcarton:35755, r=pnkfelixGuillaume Gomez-0/+11
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-28Fix bad error message with `::<` in typesmcarton-0/+11
2016-10-27Auto merge of #37245 - goffrie:recovery, r=nrcbors-2/+10
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-26Recover out of an enum or struct's braced block.Geoffry Song-2/+10
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-27Implement field shorthands in struct literal expressions.Eduard Burtescu-8/+21
2016-10-23Support `use *;` and `use ::*;`.Jeffrey Seyfried-4/+9
2016-10-20Tweak path parsing logicVadim Petrochenkov-15/+23
2016-10-20Refactor parser lookahead buffer and increase its sizeVadim Petrochenkov-38/+35
2016-10-19Improve `$crate`.Jeffrey Seyfried-3/+6
2016-10-05Rename Parser::last_token_kind as prev_token_kind.Nicholas Nethercote-17/+17
Likewise, rename LastTokenKind as PrevTokenKind. This is a [breaking-change] for libsyntax.
2016-10-05Rename Parser::last_span as prev_span.Nicholas Nethercote-158/+154
This is a [breaking-change] for libsyntax.
2016-10-01Rollup merge of #34764 - pnkfelix:attrs-on-generic-formals, r=eddybManish Goregaokar-9/+53
First step for #34761
2016-10-01Rollup merge of #36599 - ↵Manish Goregaokar-3/+3
jonas-schievink:whats-a-pirates-favorite-data-structure, r=pnkfelix Contains a syntax-[breaking-change] as a separate commit (cc #31645).nnAlso renames slice patterns from `PatKind::Vec` to `PatKind::Slice`.
2016-09-28Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakisJonathan Turner-9/+13
Allow more non-inline modules in blocks Currently, non-inline modules without a `#[path]` attribute are not allowed in blocks. This PR allows non-inline modules that have an ancestor module with a `#[path]` attribute, provided there is not a nearer ancestor block. For example, ```rust fn main() { #[path = "..."] mod foo { mod bar; //< allowed by this PR fn f() { mod bar; //< still an error } } } ``` Fixes #36772. r? @nikomatsakis
2016-09-28Allow non-inline modules in more places.Jeffrey Seyfried-9/+13
2016-09-28libsyntax: clearer names for some AST partsJonas Schievink-3/+3
This applies the HIR changes from the previous commits to the AST, and is thus a syntax-[breaking-change] Renames `PatKind::Vec` to `PatKind::Slice`, since these are called slice patterns, not vec patterns. Renames `TyKind::Vec`, which represents the type `[T]`, to `TyKind::Slice`. Renames `TyKind::FixedLengthVec` to `TyKind::Array`.
2016-09-26Rollup merge of #36669 - jseyfried:refactor_tok_result, r=nrcJonathan Turner-11/+0
Unify `TokResult` and `ResultAnyMacro` Fixes #36641. r? @nrc