about summary refs log tree commit diff
path: root/src/test/parse-fail
AgeCommit message (Collapse)AuthorLines
2017-02-02Rollup merge of #39420 - oli-obk:sugg, r=pnkfelixGuillaume Gomez-1/+2
parser: use suggestions instead of helps with code in them
2017-01-31use suggestions instead of helps with code in themOliver Schneider-1/+2
2017-01-28Add clearer error message using `&str + &str`Michael Gattozzi-0/+28
This is the first part of #39018. One of the common things for new users coming from more dynamic languages like JavaScript, Python or Ruby is to use `+` to concatenate strings. However, this doesn't work that way in Rust unless the first type is a `String`. This commit adds a check for this use case and outputs a new error as well as a suggestion to guide the user towards the desired behavior. It also adds a new test case to test the output of the error.
2017-01-27Auto merge of #39158 - petrochenkov:bounds, r=nikomatsakisbors-15/+144
Bounds parsing refactoring 2 See https://github.com/rust-lang/rust/pull/37511 for previous discussion. cc @matklad Relaxed parsing rules: - zero bounds after `:` are allowed in all contexts. - zero predicates are allowed after `where`. - trailing separator `,` is allowed after predicates in `where` clauses not followed by `{`. Other parsing rules: - trailing separator `+` is still allowed in all bound lists. Code is also cleaned up and tests added. I haven't touched parsing of trait object types yet, I'll do it later.
2017-01-25Auto merge of #35712 - oli-obk:exclusive_range_patterns, r=nikomatsakisbors-20/+2
exclusive range patterns adds `..` patterns to the language under a feature gate (`exclusive_range_pattern`). This allows turning ``` rust match i { 0...9 => {}, 10...19 => {}, 20...29 => {}, _ => {} } ``` into ``` rust match i { 0..10 => {}, 10..20 => {}, 20..30 => {}, _ => {} } ```
2017-01-24parser: Permit trailing +'s in bound listsVadim Petrochenkov-50/+8
2017-01-24Improve some expected/found error messages from parserVadim Petrochenkov-2/+2
2017-01-24Add testsVadim Petrochenkov-0/+179
2017-01-24Refactor parsing of generic arguments/parameters and where clausesVadim Petrochenkov-15/+7
2017-01-20Rollup merge of #39179 - petrochenkov:objparen, r=eddybAlex Crichton-0/+15
Fix regression in parsing of trait object types Fixes https://github.com/rust-lang/rust/issues/39169 Accepting parens in this position is a regression itself, introduced in Rust 1.6 by https://github.com/rust-lang/rust/pull/29870, so I hope to revert this in my next bounds refactoring patch (possibly with a warning, crater run, etc). r? @eddyb
2017-01-19Fix regression in parsing of trait object typesVadim Petrochenkov-0/+15
2017-01-19add exclusive range patterns under a feature gateOliver Schneider-20/+2
2017-01-17Refactor the parser to consume token trees.Jeffrey Seyfried-1/+1
2016-12-30Fix parse-fail and compile-fail testsSimonas Kazlauskas-6/+6
2016-12-09Add test.Without Boats-0/+16
2016-11-22Fix fallout in tests.Jeffrey Seyfried-0/+1
2016-11-21Fix fallout in `rustdoc` and tests.Jeffrey Seyfried-1/+1
2016-11-14Auto merge of #37278 - matklad:lone-lifetime, r=jseyfriedbors-1/+4
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-2/+5
Don't allow lifetimes without any bounds at all
2016-11-11Auto merge of #37246 - goffrie:no-loop, r=jseyfriedbors-0/+19
Don't spin expanding stmt macros. If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 and #37234 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state. I'm not sold on this strategy (checking `tokens_consumed`), so if anyone has a better idea, I'm all ears!
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-1/+2
2016-11-01add -Z continue-parse-after-error to parse-fail testsNiko Matsakis-13/+15
The new handling fixed a latent bug in the parser error handling where it would only abort after the second error (when configured to stop after the first error). This is because the check for `error_count != 0` was occuring before the increment. Since the increment is tied to the `emit()` call now this no longer occurs.
2016-10-31Changed most vec! invocations to use square bracesiirelu-1/+1
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-27Auto merge of #37245 - goffrie:recovery, r=nrcbors-0/+102
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-26Don't spin expanding stmt macros.Geoffry Song-0/+19
If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state.
2016-10-26Recover out of an enum or struct's braced block.Geoffry Song-0/+102
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-1/+20
2016-10-20Tweak path parsing logicVadim Petrochenkov-45/+0
2016-09-23Fix fallout in tests.Jeffrey Seyfried-2/+3
2016-09-13Remove parsing of obsolete pre-1.0 syntaxesVadim Petrochenkov-18/+0
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-17/+25
2016-08-19Auto merge of #33922 - estebank:doc-comment, r=alexcrichtonbors-3/+115
Specific error message for missplaced doc comments Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-07-15syntax: Better error message for inner attr following doc commentAravind Gollakota-0/+36
2016-07-05Specific error message for missplaced doc commentsEsteban Küber-3/+115
Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-06-29Rollup merge of #34460 - dsprenkels:issue-33455, r=alexcrichtonManish Goregaokar-0/+11
Add regression test for #33455 Closes #33455.
2016-06-25add regression test for #33455Daan Sprenkels-0/+11
2016-06-13Add support for macro expansion inside trait itemsJoseph Dunne-0/+20
2016-05-27Auto merge of #33900 - GuillaumeGomez:rollup, r=GuillaumeGomezbors-0/+18
Rollup of 10 pull requests - Successful merges: #33753, #33815, #33829, #33858, #33865, #33866, #33870, #33874, #33891, #33898 - Failed merges:
2016-05-26Address review commentsVadim Petrochenkov-1/+1
2016-05-26Implement `..` in tuple (struct) patternsVadim Petrochenkov-4/+104
2016-05-26Fix ICE on failure to parse token treeJeffrey Seyfried-0/+18
2016-05-14syntax: Refactor parsing of method declarationsVadim Petrochenkov-4/+22
Fix spans and expected token lists, fix #33413 + other cosmetic improvements Add test for #33413 Convert between `Arg` and `ExplicitSelf` precisely Simplify pretty-printing for methods
2016-05-07Rollup merge of #33336 - birkenfeld:issue-27361, r=sfacklerSteve Klabnik-2/+2
parser: do not try to continue with `unsafe` on foreign fns The changed line makes it look like `unsafe` is allowed, but the first statement of `parse_item_foreign_fn` is: ``` self.expect_keyword(keywords::Fn)?; ``` So we get the strange "expected one of `fn`, `pub`, `static`, or `unsafe`, found `unsafe`". Fixes: #27361
2016-05-07Auto merge of #33333 - birkenfeld:issue-30318, r=Manishearthbors-0/+19
parser: show a helpful note on unexpected inner comment Fixes: #30318.
2016-05-06Auto merge of #33311 - birkenfeld:issue33262, r=nrcbors-0/+18
parser: fix suppression of syntax errors in range RHS Invalid expressions on the RHS were just swallowed without generating an error. The new version more closely mirrors the code for parsing `..x` in the `parse_prefix_range_expr` method below, where no cancel is done either. Fixes #33262.
2016-05-03parser: show a helpful note on unexpected inner commentGeorg Brandl-0/+19
Fixes: #30318.
2016-05-02parser: change warning into an error on `T<A=B, C>`Georg Brandl-0/+17
Fixes: #32214
2016-05-02parser: do not try to continue with `unsafe` on foreign fnsGeorg Brandl-2/+2
The changed line makes it look like `unsafe` is allowed, but the first statement of `parse_item_foreign_fn` is: `self.expect_keyword(keywords::Fn)?;` So we get the strange "expected one of `fn`, `pub`, `static`, or `unsafe`, found `unsafe`". Fixes: #27361
2016-05-01parser: fix suppression of syntax errors in range RHSGeorg Brandl-0/+18
Invalid expressions on the RHS were just swallowed without generating an error. The new code more closely mirrors the code for parsing `..x` in the `parse_prefix_range_expr` method, where no cancel is done either. Fixes #33262.
2016-04-24Fix keyword parsing testsVadim Petrochenkov-60/+169