about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2016-01-25libsyntax: note that `let a = (let b = something)` is invalidDaan Sprenkels-0/+6
in parse_bottom_expr (parser.rs)
2016-01-22The war on abort_if_errorsNick Cameron-15/+12
2016-01-22Some basic error correction in the parser after a dotNick Cameron-42/+62
2016-01-16libsyntax: accept only whitespace with the PATTERN_WHITE_SPACE propertyKevin Butler-9/+12
This aligns with unicode recommendations and should be stable for all future unicode releases. See http://unicode.org/reports/tr31/#R3. This renames `libsyntax::lexer::is_whitespace` to `is_pattern_whitespace` so potentially breaks users of libsyntax.
2016-01-15Auto merge of #30763 - gchp:issue/30033, r=nagisabors-10/+15
This is achieved by adding the scan_back method. This method looks back through the source_text of the StringReader until it finds the target char, returning it's offset in the source. We use this method to find the offset of the opening single quote, and use that offset as the start of the error. Given this code: ```rust fn main() { let _ = 'abcd'; } ``` The compiler would give a message like: ``` error: character literal may only contain one codepoint: '; let _ = 'abcd'; ^~ ``` With this change, the message now displays: ``` error: character literal may only contain one codepoint: 'abcd'; let _ = 'abcd'; ^~~~~~~ ``` Fixes #30033
2016-01-14libsyntax: use char::is_whitespace instead of custom implementationsKevin Butler-4/+1
Fixes #29590.
2016-01-15Implement JSON error emissionNick Cameron-1/+1
[breaking-change] syntax::errors::Handler::new has been renamed to with_tty_emitter Many functions which used to take a syntax::errors::ColorConfig, now take a rustc::session::config::ErrorOutputType. If you previously used ColorConfig::Auto as a default, you should now use ErrorOutputType::default().
2016-01-14Display better snippet for invalid char literalGreg Chapple-10/+15
Given this code: fn main() { let _ = 'abcd'; } The compiler would give a message like: error: character literal may only contain one codepoint: '; let _ = 'abcd'; ^~ With this change, the message now displays: error: character literal may only contain one codepoint: 'abcd' let _ = 'abcd' ^~~~~~ Fixes #30033
2016-01-13Auto merge of #30813 - fhahn:fix-ice-semicolon-in-lifetime, r=nrcbors-4/+6
This PR fixes an ICE due to an DiagnosticsBuilder not being canceld or emitted. Ideally it would use `Handler::cancel`, but I did not manage to get a `&mut` reference to the diagnostics handler.
2016-01-13Auto merge of #30684 - tshepang:rustfmt-lexer-part2, r=nrcbors-511/+756
2016-01-12re-instate comment that was mysteriously disappearedTshepang Lekhonkhobe-0/+1
2016-01-10Cancel parse_ty error in Parser::parse_generic_values_after_ltFlorian Hahn-4/+6
2016-01-07Auto merge of #30723 - nrc:macro-err-bug, r=Manishearthbors-2/+9
Fixes #30715
2016-01-06Rollup merge of #30729 - huonw:delete-bad-comment, r=sanxiynSteve Klabnik-3/+0
The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.
2016-01-06Auto merge of #30654 - nrc:panictry, r=brsonbors-295/+300
The motivation (other than removing boilerplate) is that this is a baby step towards a parser with error recovery. [breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2016-01-06Remove irrelevant commentHuon Wilson-3/+0
The fundamental problem of duplication was fixed in https://github.com/rust-lang/rust/pull/10891, but the comment was preserved. Closes https://github.com/rust-lang/rust/issues/9762.
2016-01-06Cancel an error before it panicsNick Cameron-2/+9
Fixes #30715
2016-01-04address review commentTshepang Lekhonkhobe-10/+2
2016-01-03fix "make tidy" failureTshepang Lekhonkhobe-1/+2
2016-01-03run rustfmt on syntax::parse::lexerTshepang Lekhonkhobe-513/+764
2015-12-31Auto merge of #30598 - est31:macro_export_help_note, r=Manishearthbors-5/+17
The current help message is too much about "normal" macros to be used as general message. Keep it for normal macros, and add custom help and error messages for macro definitions.
2015-12-31Cut out a bunch of Result and panictry! boilerplate from libsyntax.Nick Cameron-295/+300
[breaking-change] if you use any of the changed functions, you'll need to remove a try! or panictry!
2015-12-30Auto merge of #30375 - aaronkeen:issue_28777, r=eddybbors-6/+15
RESTRICTION_STMT_EXPR restriction to allow subsequent expressions to contain braces. https://github.com/rust-lang/rust/issues/28777
2015-12-30Limit line length to below 100 charsest31-2/+4
2015-12-30whitespace after colon, not beforeest31-1/+1
2015-12-30Custom help message for people trying to make macro publicest31-5/+15
The current help message is too much about "normal" macros to be used as general message. Keep it for normal macros, and add custom help and error messages for macro definitions.
2015-12-30Auto merge of #30526 - Ms2ger:PathParameters, r=brsonbors-7/+8
2015-12-30Rebasing and review commentsNick Cameron-1/+1
2015-12-30use structured errorsNick Cameron-288/+337
2015-12-22Stop re-exporting PathParameters's variants.Ms2ger-7/+8
2015-12-21Auto merge of #30460 - Ms2ger:BindingMode, r=alexcrichtonbors-10/+10
2015-12-20Stop re-exporting the ast::BindingMode variants.Ms2ger-10/+10
2015-12-19Auto merge of #30184 - petrochenkov:ascr, r=nikomatsakisbors-3/+9
This PR is a rebase of the original PR by @eddyb https://github.com/rust-lang/rust/pull/21836 with some unrebasable parts manually reapplied, feature gate added + type equality restriction added as described below. This implementation is partial because the type equality restriction is applied to all type ascription expressions and not only those in lvalue contexts. Thus, all difficulties with detection of these contexts and translation of coercions having effect in runtime are avoided. So, you can't write things with coercions like `let slice = &[1, 2, 3]: &[u8];`. It obviously makes type ascription less useful than it should be, but it's still much more useful than not having type ascription at all. In particular, things like `let v = something.iter().collect(): Vec<_>;` and `let u = t.into(): U;` work as expected and I'm pretty happy with these improvements alone. Part of https://github.com/rust-lang/rust/issues/23416
2015-12-18Require exact type equality + add testsVadim Petrochenkov-1/+2
+ Rebase fixes
2015-12-18Rollup merge of #30420 - petrochenkov:owned2, r=nrcManish Goregaokar-19/+17
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults. r? @nrc
2015-12-18Rollup merge of #30384 - nrc:diagnostics, r=@nikomatsakisManish Goregaokar-56/+80
Should make it possible to add JSON or HTML errors. Also tidies up a lot.
2015-12-18Deprecate name `OwnedSlice` and don't use itVadim Petrochenkov-19/+17
2015-12-17Remove unused importsJeffrey Seyfried-3/+3
2015-12-17test errorsNick Cameron-27/+51
2015-12-17Move a bunch of stuff from Session to syntax::errorsNick Cameron-1/+1
The intention here is that Session is a very thin wrapper over the error handling infra.
2015-12-17move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*Nick Cameron-32/+32
Also split out emitters into their own module.
2015-12-16Add ExprType to HIR and make everything compileVadim Petrochenkov-1/+7
+ Apply parser changes manually + Add feature gate
2015-12-16Implement type ascription.Eduard Burtescu-2/+1
2015-12-16Rollup merge of #30388 - DanielJCampbell:macro-ident-spans, r=nrcManish Goregaokar-1/+1
r? @nrc
2015-12-16Corrected formatting mistakes.Aaron Keen-7/+7
Changed bit manipulation to use supported - (set difference) instead of explicit '& !'.
2015-12-15Generated code spans now point to callsite parameters (where applicable)Daniel Campbell-1/+1
2015-12-14[breaking-change] move ast_util functions to methodsfaineance-2/+2
2015-12-14Corrects issue #28777 by removing, once a binary operator is found, theAaron Keen-6/+15
RESTRICTION_STMT_EXPR restriction to allow subsequent expressions to contain braces. https://github.com/rust-lang/rust/issues/28777
2015-12-04Auto merge of #29850 - Kimundi:attributes_that_make_a_statement, r=pnkfelixbors-152/+315
See https://github.com/rust-lang/rfcs/pull/16 and https://github.com/rust-lang/rust/issues/15701 - Added syntax support for attributes on expressions and all syntax nodes in statement position. - Extended `#[cfg]` folder to allow removal of statements, and of expressions in optional positions like expression lists and trailing block expressions. - Extended lint checker to recognize lint levels on expressions and locals. - As per RFC, attributes are not yet accepted on `if` expressions. Examples: ```rust let x = y; { ... } assert_eq!((1, #[cfg(unset)] 2, 3), (1, 3)); let FOO = 0; ``` Implementation wise, there are a few rough corners and open questions: - The parser work ended up a bit ugly. - The pretty printer change was based mostly on guessing. - Similar to the `if` case, there are some places in the grammar where a new `Expr` node starts, but where it seemed weird to accept attributes and hence the parser doesn't. This includes: - const expressions in patterns - in the middle of an postfix operator chain (that is, after `.`, before indexing, before calls) - on range expressions, since `#[attr] x .. y` parses as `(#[attr] x) .. y`, which is inconsistent with `#[attr] .. y` which would parse as `#[attr] (.. y)` - Attributes are added as additional `Option<Box<Vec<Attribute>>>` fields in expressions and locals. - Memory impact has not been measured yet. - A cfg-away trailing expression in a block does not currently promote the previous `StmtExpr` in a block to a new trailing expr. That is to say, this won't work: ```rust let x = { #[cfg(foo)] Foo { data: x } #[cfg(not(foo))] Foo { data: y } }; ``` - One-element tuples can have their inner expression removed to become Unit, but just Parenthesis can't. Eg, `(#[cfg(unset)] x,) == ()` but `(#[cfg(unset)] x) == error`. This seemed reasonable to me since tuples and unit are type constructors, but could probably be argued either way. - Attributes on macro nodes are currently unconditionally dropped during macro expansion, which seemed fine since macro disappear at that point? - Attributes on `ast::ExprParens` will be prepend-ed to the inner expression in the hir folder. - The work on pretty printer tests for this did trigger, but not fix errors regarding macros: - expression `foo![]` prints as `foo!()` - expression `foo!{}` prints as `foo!()` - statement `foo![];` prints as `foo!();` - statement `foo!{};` prints as `foo!();` - statement `foo!{}` triggers a `None` unwrap ICE.
2015-11-28Use last_span for macro spansKevin Yeh-3/+4