about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2017-10-09Fix a bug in diagnostics for `x as usize < y`Vadim Petrochenkov-3/+16
Improve diagnostics for `x as usize << y`
2017-10-06Add a semicolon to span for ast::LocalSeiichi Uchida-1/+6
2017-10-03Rename FileMap::path and change to an OptionPhilip Craig-1/+1
2017-09-30Don't use remapped path when loading modules and include filesPhilip Craig-1/+1
2017-09-27Auto merge of #44709 - Badel2:inclusive-range-dotdoteq, r=petrochenkovbors-32/+63
Initial support for `..=` syntax #28237 This PR adds `..=` as a synonym for `...` in patterns and expressions. Since `...` in expressions was never stable, we now issue a warning. cc @durka r? @aturon
2017-09-22Add information about the syntax used in rangesBadel2-4/+7
... or ..=
2017-09-22Add support for `..=` syntaxAlex Burka-30/+58
Add ..= to the parser Add ..= to libproc_macro Add ..= to ICH Highlight ..= in rustdoc Update impl Debug for RangeInclusive to ..= Replace `...` to `..=` in range docs Make the dotdoteq warning point to the ... Add warning for ... in expressions Updated more tests to the ..= syntax Updated even more tests to the ..= syntax Updated the inclusive_range entry in unstable book
2017-09-22Include unary operator to span for ExprKind::UnarySeiichi Uchida-7/+7
2017-09-18rustc: Forbid interpolated tokens in the HIRAlex Crichton-0/+85
Right now the HIR contains raw `syntax::ast::Attribute` structure but nowadays these can contain arbitrary tokens. One variant of the `Token` enum is an "interpolated" token which basically means to shove all the tokens for a nonterminal in this position. A "nonterminal" in this case is roughly analagous to a macro argument: macro_rules! foo { ($a:expr) => { // $a is a nonterminal as an expression } } Currently nonterminals contain namely items and expressions, and this poses a problem for incremental compilation! With incremental we want a stable hash of all HIR items, but this means we may transitively need a stable hash *of the entire AST*, which is certainly not stable w/ node ids and whatnot. Hence today there's a "bug" where the "stable hash" of an AST is just the raw hash value of the AST, and this only arises with interpolated nonterminals. The downside of this approach, however, is that a bunch of errors get spewed out during compilation about how this isn't a great idea. This PR is focused at fixing these warnings, basically deleting them from the compiler. The implementation here is to alter attributes as they're lowered from the AST to HIR, expanding all nonterminals in-place as we see them. This code for expanding a nonterminal to a token stream already exists for the `proc_macro` crate, so we basically just reuse the same implementation there. After this PR it's considered a bug to have an `Interpolated` token and hence the stable hash implementation simply uses `bug!` in this location. Closes #40946
2017-09-17Remove rustc_bitflags; use the bitflags crateTamir Duberstein-23/+23
2017-09-14Auto merge of #44484 - tirr-c:issue-44332, r=petrochenkovbors-6/+38
Parse nested closure with two consecutive parameter lists properly This is a followup of #44332. --- Currently, in nightly, this does not compile: ```rust fn main() { let f = |_||x, y| x+y; println!("{}", f(())(1, 2)); // should print 3 } ``` `|_||x, y| x+y` should be parsed as `|_| (|x, y| x+y)`, but the parser didn't accept `||` between `_` and `x`. This patch fixes the problem. r? @petrochenkov
2017-09-12Auto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkovbors-47/+65
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-11Auto merge of #44375 - topecongiro:macrodef-span, r=petrochenkovbors-5/+5
Add visibility to span for macros 2.0 cc https://github.com/rust-lang-nursery/rustfmt/issues/1949. r? @nrc
2017-09-11Parse nested closure with two consecutive parameter lists properlyWonwoo Choi-6/+38
2017-09-07Add visibility to span for macros 2.0topecongiro-5/+5
2017-09-05Expect pipe symbol after closure parameter listsWonwoo Choi-1/+1
2017-09-01Implement RFC 1925Matt Ickstadt-0/+7
2017-08-31Auto merge of #43425 - matklad:lambda-restrictions, r=eddybbors-1/+4
Lambda expressions honor no struct literal restriction This is a fix for #43412 if we decide that it is indeed a bug :) closes #43412
2017-08-30Make fields of `Span` privateVadim Petrochenkov-49/+35
2017-08-25Merge remote-tracking branch 'origin/master' into genAlex Crichton-1/+19
2017-08-22Ensure that generic arguments don't end up in attribute paths.Jeffrey Seyfried-1/+7
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-21/+18
2017-08-22Auto merge of #43854 - estebank:missing-cond, r=nikomatsakisbors-0/+12
Point out missing if conditional On a case where an else conditional is missing, point this out instead of the token immediately after the (incorrect) else block: ``` error: missing condition for `if` statemementt push fork -f --> $DIR/issue-13483.rs:16:5 | 13 | } else if { | ^ expected if condition here ``` instead of ``` error: expected `{`, found `else` --> ../../src/test/ui/issue-13483.rs:14:7 | 14 | } else { | ^^^^ ``` Fix #13483.
2017-08-21Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakisbors-21/+18
syntax: Relax path grammar TLDR: Accept the disambiguator `::` in "type" paths (`Type::<Args>`), accept the disambiguator `::` before parenthesized generic arguments (`Fn::(Args)`). The "turbofish" disambiguator `::<>` in expression paths is a necessary evil required for path parsing to be both simple and to give reasonable results. Since paths in expressions usually refer to values (but not necessarily, e.g. `Struct::<u8> { field: 0 }` is disambiguated, but refers to a type), people often consider `::<>` to be inherent to *values*, and not *expressions* and want to write disambiguated paths for values even in contexts where disambiguation is not strictly necessary, for example when a path is passed to a macro `m!(Vec::<i32>::new)`. The problem is that currently, if the disambiguator is not *required*, then it's *prohibited*. This results in confusion - see https://github.com/rust-lang/rust/issues/41740, https://internals.rust-lang.org/t/macro-path-uses-novel-syntax/5561. This PR makes the disambiguator *optional* instead of prohibited in contexts where it's not strictly required, so people can pass paths to macros in whatever form they consider natural (e.g. disambiguated form for value paths). This PR also accepts the disambiguator in paths with parenthesized arguments (`Fn::(Args)`) for consistency and to simplify testing of stuff like https://github.com/rust-lang/rust/pull/41856#issuecomment-301219194. Closes https://github.com/rust-lang/rust/issues/41740 cc @rust-lang/lang r? @nikomatsakis
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-6/+4
2017-08-18Auto merge of #43904 - topecongiro:libsyntax/parse-attr, r=petrochenkovbors-6/+4
Eat open paren when parsing list in libsyntax/parse/attr.rs This PR adds a small refactoring: ```diff pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> { Ok(if self.eat(&token::Eq) { ast::MetaItemKind::NameValue(self.parse_unsuffixed_lit()?) - } else if self.token == token::OpenDelim(token::Paren) { + } else if self.eat(&token::OpenDelim(token::Paren)) { ast::MetaItemKind::List(self.parse_meta_seq()?) } else { - self.eat(&token::OpenDelim(token::Paren)); ast::MetaItemKind::Word }) } ``` in `parse_meta_item_kind()`, the parser calls `self.eat(&token::OpenDelim(token::Paren));` before returning `ast::MetaItemKind::Word` just to add `(` to expected token. It seems more natural to eat the paren when parsing `ast::MetaItemKind::List`.
2017-08-17Verify that an `if` condition block returns a valueEsteban Küber-1/+6
2017-08-17Check for `else` keyword on missing `if` conditionEsteban Küber-16/+11
2017-08-17Accept underscores in unicode escapesMalo Jaffré-47/+65
Fixes #43692.
2017-08-17Point out missing if conditionalEsteban Küber-4/+16
On a case where an else conditional is missing, point this out instead of the token immediately after the (incorrect) else block: ``` error: missing condition for `if` statemementt push fork -f --> $DIR/issue-13483.rs:16:5 | 13 | } else if { | ^ expected if condition here ``` instead of ``` error: expected `{`, found `else` --> ../../src/test/ui/issue-13483.rs:14:7 | 14 | } else { | ^^^^ ```
2017-08-16Merge remote-tracking branch 'origin/master' into genAlex Crichton-98/+98
2017-08-16Eat open paren when parsing listSeiichi Uchida-6/+4
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-98/+98
Like #43008 (f668999), but _much more aggressive_.
2017-08-14Merge remote-tracking branch 'origin/master' into genAlex Crichton-2/+2
2017-08-12Include 'let' keyword to the span for ast::Localtopecongiro-1/+1
2017-08-12Auto merge of #43794 - Eijebong:fix_typos, r=lukaramu,steveklanik,imperiobors-1/+1
Fix some typos I wrote a really naive script and found those typos in the documentation.
2017-08-11Merge remote-tracking branch 'origin/master' into genAlex Crichton-2/+2
2017-08-11Rollup merge of #43779 - mattico:fix-unicode-typo, r=aidanhsGuillaume Gomez-1/+1
Fix typo in unicode char definition Reference: http://www.fileformat.info/info/unicode/char/16ed/index.htm
2017-08-11Rollup merge of #43773 - ubsan:patch-1, r=eddybGuillaume Gomez-1/+1
fix a typo (this should not have been merged with this typo)
2017-08-11Issue warnings for unnecessary path disambiguatorsVadim Petrochenkov-10/+18
2017-08-11syntax: Relax path grammarVadim Petrochenkov-13/+2
2017-08-11Fix some typosBastien Orivel-1/+1
2017-08-10Merge remote-tracking branch 'origin/master' into genAlex Crichton-29/+138
2017-08-10Auto merge of #43720 - pornel:staticconst, r=petrochenkovbors-10/+13
Hint correct extern constant syntax Error message for `extern "C" { const …}` is terse, and the right syntax is hard to guess given unfortunate difference between meaning of `static` in C and Rust. I've added a hint for the right syntax.
2017-08-10Reword error hintKornel-1/+2
2017-08-09Fix typo in unicode char definitionMatt Ickstadt-1/+1
2017-08-10Better diagnostics and recovery for `const` in extern blocksVadim Petrochenkov-12/+12
2017-08-09fix a typonicole mazzuca-1/+1
(this should not have been merged with this typo)
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-17/+150
2017-08-07Hint correct extern constant syntaxKornel-1/+3