summary refs log tree commit diff
path: root/src/test/parse-fail
AgeCommit message (Collapse)AuthorLines
2016-01-15Auto merge of #30763 - gchp:issue/30033, r=nagisabors-6/+66
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-14Display better snippet for invalid char literalGreg Chapple-6/+66
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-10Cancel parse_ty error in Parser::parse_generic_values_after_ltFlorian Hahn-0/+19
2016-01-06Auto merge of #30654 - nrc:panictry, r=brsonbors-1/+2
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!
2015-12-31Auto merge of #30598 - est31:macro_export_help_note, r=Manishearthbors-0/+89
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-1/+2
[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-16/+0
RESTRICTION_STMT_EXPR restriction to allow subsequent expressions to contain braces. https://github.com/rust-lang/rust/issues/28777
2015-12-30Move pub-{item,methd}-macro.rs to the parse-fail subdir as wellest31-0/+62
2015-12-30Move pub-macro-rules.rs test to parse-fail directoryest31-0/+27
2015-12-17Removed test case. This now test successfully parses with theAaron Keen-16/+0
modification to parsing of binary operators. This is consistent with the behavior of grammar/parser-lalr.
2015-12-16Implement type ascription.Eduard Burtescu-3/+3
2015-11-26Add syntax support for attributes on expressions and all syntaxMarvin Löbel-73/+3
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.
2015-11-17Detect confusing unicode characters and show the alternativeRavi Shankar-0/+18
2015-11-09syntax: Merge parsing code for structures and variantsVadim Petrochenkov-25/+0
2015-11-05Improve error message for char literalsSteve Klabnik-2/+2
If you try to put something that's bigger than a char into a char literal, you get an error: fn main() { let c = 'ஶ்ரீ'; } error: unterminated character constant: This is a very compiler-centric message. Yes, it's technically 'unterminated', but that's not what you, the user did wrong. Instead, this commit changes it to error: character literal may only contain one codepoint As this actually tells you what went wrong. Fixes #28851
2015-10-28libsyntax: improve error message when a statement is prefixed with a match ↵Kevin Butler-0/+18
keyword
2015-10-27Add tests for newly introduced syntaxSimonas Kazlauskas-0/+54
Also add some (regression) tests for discovered parser oddities
2015-10-27Generalise associative operator parsingSimonas Kazlauskas-35/+0
This commit generalises parsing of associative operators from left-associative only (with some ugly hacks to support right-associative assignment) to properly left/right-associative operators. Parsing still is not general enough to handle non-associative, non-highest-precedence prefix or non-highest-precedence postfix operators (e.g. `..` range syntax), though. That should be fixed in the future. Lastly, this commit adds support for parsing right-associative `<-` (left arrow) operator with precedence higher than assignment as the operator for placement-in feature.
2015-10-25libsyntax: better error for lifetimes in patternsKevin Butler-0/+16
Previously, if you copied a signature from a trait definition such as: ``` fn foo<'a>(&'a Bar) -> bool {} ``` and moved it into an `impl`, there would be an error message: "unexpected token `'a`" Adding to the error message that a pattern is expected should help users to find the actual problem with using a lifetime here.
2015-10-13Test and gate empty structures and variants betterVadim Petrochenkov-15/+0
2015-10-13Unify structures and enum variants in ASTVadim Petrochenkov-15/+0
2015-09-24Remove the deprecated box(PLACE) syntax.Eduard Burtescu-19/+0
2015-09-18Implement empty struct with braces (RFC 218)Vadim Petrochenkov-96/+0
2015-09-14Auto merge of #28247 - christopherdumas:fix_28243, r=eddybbors-0/+16
as per #28243.
2015-09-14Fix tuple float bug.christopherdumas-0/+16
2015-09-11Remove some remains of virtual structs from the parserVadim Petrochenkov-3/+2
2015-09-03Use consistent terminology for byte string literalsVadim Petrochenkov-4/+4
Avoid confusion with binary integer literals and binary operator expressions in libsyntax
2015-08-15Fix span of invalid metavariable repetitionJonas Schievink-0/+19
2015-08-06Auto merge of #27296 - jroesch:type-macros, r=huonwbors-8/+9
This pull request implements the functionality for [RFC 873](https://github.com/rust-lang/rfcs/blob/master/text/0873-type-macros.md). This is currently just an update of @freebroccolo's branch from January, the corresponding commits are linked in each commit message. @nikomatsakis and I had talked about updating the macro language to support a lifetime fragment specifier, and it is possible to do that work on this branch as well. If so we can (collectively) talk about it next week during the pre-RustCamp work week.
2015-08-06Fix expected parse errorJared Roesch-8/+9
2015-08-03delete some old testsSteve Klabnik-32/+0
These are for syntaxes that haven't existed for a long time.
2015-07-31Fix `impl A .. {}`Seo Sanghyeon-3/+18
2015-07-29Replace illegal with invalid in most diagnosticsSimonas Kazlauskas-31/+31
2015-07-27Turn on `box(PLACE) expr` deprecation warning post-snapshot.Eduard Burtescu-0/+1
2015-07-23Update suggestion from parenthesized-box-expr-message to reflect new output ↵Felix S. Klock II-2/+2
spacing.
2015-07-18Fix doc comment parsing in macros.Lee Jeffery-0/+38
2015-07-13Tell unicode escapes can’t be used as bytes earlier/moreSimonas Kazlauskas-3/+5
2015-07-10Improve incomplete unicode escape reportingSimonas Kazlauskas-1/+1
This improves diagnostic messages when \u escape is used incorrectly and { is missing. Instead of saying “unknown character escape: u”, it will now report that unicode escape sequence is incomplete and suggest what the correct syntax is.
2015-07-01Add netbsd amd64 supportAlex Newman-0/+1
2015-06-13Use `assert_eq!` instead of `assert!` in testspetrochenkov-2/+2
2015-06-12ignore-test cleanupSteve Klabnik-234/+0
Most of these are old, but some specific messages for specific tests: * trait-contravariant-self.rs: failed due to a soundess hole: https://github.com/rust-lang/rust/commit/05e3248a7974f55b64f75a2483b37ff8c001a4ff * process-detatch: https://github.com/rust-lang/rust/commit/15966c3c1f99810ac81053769651776a67181dae says "this test is being ignored until signals are implemented" That's not happening for a long time, and when it is, we'll write tests for it. * deep-vector{,2}.rs: "too big for our poor macro infrastructure", and has been ignored over a year. * borrowck-nested-calls.rs's FIXME #6268 was closed in favor of rust-lang/rfcs#811 * issue-15167.rs works properly now * issue-9737.rs works properly now * match-var-hygiene.rs works properly now Addresses a chunk of #3965
2015-06-09Exise 'unsafe pointer' in favor of 'raw pointer'Steve Klabnik-4/+4
Using two terms for one thing is confusing, these are called 'raw pointers' today.
2015-05-16Clarify the error message for malformed `extern crate` statementsP1start-1/+12
Closes #25468.
2015-04-27Auto merge of #23606 - quantheory:associated_const, r=nikomatsakisbors-6/+58
Closes #17841. The majority of the work should be done, e.g. trait and inherent impls, different forms of UFCS syntax, defaults, and cross-crate usage. It's probably enough to replace the constants in `f32`, `i8`, and so on, or close to good enough. There is still some significant functionality missing from this commit: - ~~Associated consts can't be used in match patterns at all. This is simply because I haven't updated the relevant bits in the parser or `resolve`, but it's *probably* not hard to get working.~~ - Since you can't select an impl for trait-associated consts until partway through type-checking, there are some problems with code that assumes that you can check constants earlier. Associated consts that are not in inherent impls cause ICEs if you try to use them in array sizes or match ranges. For similar reasons, `check_static_recursion` doesn't check them properly, so the stack goes ka-blooey if you use an associated constant that's recursively defined. That's a bit trickier to solve; I'm not entirely sure what the best approach is yet. - Dealing with consts associated with type parameters will raise some new issues (e.g. if you have a `T: Int` type parameter and want to use `<T>::ZERO`). See rust-lang/rfcs#865. - ~~Unused associated consts don't seem to trigger the `dead_code` lint when they should. Probably easy to fix.~~ Also, this is the first time I've been spelunking in rustc to such a large extent, so I've probably done some silly things in a couple of places.
2015-04-25`qquote-2.rs` -> `run-fail/qquote.rs`Tamir Duberstein-63/+0
Re-enables the test.
2015-04-25`qquote-1.rs` -> `compile-fail-fulldeps/qquote.rs`Tamir Duberstein-70/+0
Re-enables the test.
2015-04-23Get associated consts working in match patterns.Sean Patrick Santos-0/+34
2015-04-23Functional changes for associated constants. Cross-crate usage of associated ↵Sean Patrick Santos-6/+24
constants is not yet working.
2015-04-23Auto merge of #24683 - P1start:help-suggestions, r=nrcbors-1/+3
This PR uses the inline error suggestions introduced in #24242 to modify a few existing `help` messages. The new errors look like this: foobar.rs:5:12: 5:25 error: expected a path on the left-hand side of `+`, not `&'static Copy` [E0178] foobar.rs:5 let x: &'static Copy + 'static; ^~~~~~~~~~~~~ foobar.rs:5:12: 5:35 help: try adding parentheses (per RFC 438): foobar.rs: let x: &'static (Copy + 'static); foobar.rs:2:13: 2:23 error: cast to unsized type: `&_` as `core::marker::Copy` foobar.rs:2 let x = &1 as Copy; ^~~~~~~~~~ foobar.rs:2:19: 2:23 help: try casting to a reference instead: foobar.rs: let x = &1 as &Copy; foobar.rs:7:24: 7:25 error: expected expression, found `;` foobar.rs:7 let x = box (1 + 1); ^ foobar.rs:7:13: 7:16 help: try using `box()` instead: foobar.rs: let x = box() (1 + 1); This also modifies compiletest to give the ability to directly test suggestions given by error messages.
2015-04-21Change a few error messages to give code suggestionsP1start-1/+3
PR #24242 added the ability to the compiler to directly give suggestions about how to modify code to fix an error. The new errors look like this: foobar.rs:5:12: 5:25 error: expected a path on the left-hand side of `+`, not `&'static Copy` [E0178] foobar.rs:5 let x: &'static Copy + 'static; ^~~~~~~~~~~~~ foobar.rs:5:12: 5:35 help: try adding parentheses (per RFC 438): foobar.rs: let x: &'static (Copy + 'static); foobar.rs:2:13: 2:23 error: cast to unsized type: `&_` as `core::marker::Copy` foobar.rs:2 let x = &1 as Copy; ^~~~~~~~~~ foobar.rs:2:19: 2:23 help: try casting to a reference instead: foobar.rs: let x = &1 as &Copy; foobar.rs:7:24: 7:25 error: expected expression, found `;` foobar.rs:7 let x = box (1 + 1); ^ foobar.rs:7:13: 7:16 help: try using `box()` instead: foobar.rs: let x = box() (1 + 1); This also modifies compiletest to give the ability to directly test suggestions given by error messages.