about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2018-05-16label-break-value: Parsing and AST/HIR changesest31-7/+15
2018-05-13Macros: Add a 'literal' fragment specifierDan Aloni-9/+9
Implements RFC 1576. See: https://github.com/rust-lang/rfcs/blob/master/text/1576-macros-literal-matcher.md Changes are mostly in libsyntax, docs, and tests. Feature gate is enabled for 1.27.0. Many thanks to Vadim Petrochenkov for following through code reviews and suggestions. Example: ````rust macro_rules! test_literal { ($l:literal) => { println!("literal: {}", $l); }; ($e:expr) => { println!("expr: {}", $e); }; } fn main() { let a = 1; test_literal!(a); test_literal!(2); test_literal!(-3); } ``` Output: ``` expr: 1 literal: 2 literal: -3 ```
2018-05-10Fix tuple struct field spansEsteban Küber-1/+1
2018-05-03Auto merge of #50413 - kennytm:rollup, r=kennytmbors-1/+1
Rollup of 12 pull requests Successful merges: - #50302 (Add query search order check) - #50320 (Fix invalid path generation in rustdoc search) - #50349 (Rename "show type declaration" to "show declaration") - #50360 (Clarify wordings of the `unstable_name_collision` lint.) - #50365 (Use two vectors in nearest_common_ancestor.) - #50393 (Allow unaligned reads in constants) - #50401 (Revert "Implement FromStr for PathBuf") - #50406 (Forbid constructing empty identifiers from concat_idents) - #50407 (Always inline simple BytePos and CharPos methods.) - #50416 (check if the token is a lifetime before parsing) - #50417 (Update Cargo) - #50421 (Fix ICE when using a..=b in a closure.) Failed merges:
2018-05-03check if the token is a lifetime before parsingrleungx-1/+1
2018-05-02make it compile againflip1995-3/+3
2018-05-02Remove Option from the return type of Attribute::name()Seiichi Uchida-4/+4
2018-04-26rustc_target: move in syntax::abi and flip dependency.Irina Popa-1/+1
2018-04-23Auto merge of #48946 - PramodBisht:issues/48636, r=estebankbors-1/+16
Doc comments present after a particular syntax error cause an unhelpful error message to be output. fixed: #48636 r? @estebank
2018-04-221) Addresses #48636Pramod Bisht-1/+16
2) Changed position of help message, incase comma is missing 3) added few missing spaces and handled span_suggestion for vscode 4) updated stderr file
2018-04-22parser: Do not override syntactic context for dummy spansVadim Petrochenkov-1/+2
2018-04-12Avoid comparing fields by name when possibleVadim Petrochenkov-3/+2
Resolve them into field indices once and then use those resolutions + Fix rebase
2018-04-12AST/HIR: Merge field access expressions for named and numeric fieldsVadim Petrochenkov-32/+5
2018-04-11Rollup merge of #49525 - varkor:sort_by_cached_key-conversion, r=scottmcmkennytm-1/+1
Use sort_by_cached_key where appropriate A follow-up to https://github.com/rust-lang/rust/pull/48639, converting various slice sorting calls to `sort_by_cached_key` when the key functions are more expensive.
2018-04-09in which `!` is suggested for erroneous identifier `not`Zack M. Davis-1/+42
Impressing confused Python users with magical diagnostics is perhaps worth this not-grossly-unreasonable (only 40ish lines) extra complexity in the parser? Thanks to Vadim Petrochenkov for guidance. This resolves #46836.
2018-04-09don't suggest placing code in block if next token is open-braceZack M. Davis-0/+5
Thanks to the inestimably inimitable Esteban "Estebank" Küber for pointing this out. This is relevant to #46836.
2018-04-09Convert sort_by to sort_by_cached_keyvarkor-1/+1
2018-04-06Use `Ident` instead of `Name` in `MetaItem`Vadim Petrochenkov-2/+2
2018-04-06Make lifetime nonterminals closer to identifier nonterminalsVadim Petrochenkov-8/+13
2018-04-06Remove more duplicated spansVadim Petrochenkov-26/+17
2018-04-06Rename `ast::Variant_::name` into `ident` + Fix rebaseVadim Petrochenkov-1/+1
2018-04-06Get rid of `SpannedIdent`Vadim Petrochenkov-39/+28
2018-04-06Rename `PathSegment::identifier` to `ident`Vadim Petrochenkov-2/+2
2018-04-05Rollup merge of #49350 - abonander:macros-in-extern, r=petrochenkovAlex Crichton-55/+69
Expand macros in `extern {}` blocks This permits macro and proc-macro and attribute invocations (the latter only with the `proc_macro` feature of course) in `extern {}` blocks, gated behind a new `macros_in_extern` feature. A tracking issue is now open at #49476 closes #48747
2018-04-03expand macro invocations in `extern {}` blocksAustin Bonander-55/+69
2018-04-03Remove all unstable placement featuresAidan Hobson Sayers-13/+0
Closes #22181, #27779
2018-04-02Auto merge of #49124 - abonander:attr-macro-stmt-expr, r=abonanderbors-0/+3
Expand Attributes on Statements and Expressions This enables attribute-macro expansion on statements and expressions while retaining the `stmt_expr_attributes` feature requirement for attributes on expressions. closes #41475 cc #38356 @petrochenkov @jseyfried r? @nrc
2018-04-02Expand attribute macros on statements and expressions.Austin Bonander-0/+3
Retains the `stmt_expr_attributes` feature requirement for attributes on expressions. closes #41475 cc #38356
2018-04-01Auto merge of #49478 - Phlosioneer:fix-windows-file-not-found, r=petrochenkovbors-1/+1
Fix escaped backslash in windows file not found message When a module is declared, but no matching file exists, rustc gives an error like `help: name the file either foo.rs or foo/mod.rs inside the directory "src/bar"`. However, at on windows, the backslash was double-escaped when naming the directory. It did this because the string was printed in debug mode (`"{:?}"`) to surround it with quotes. However, it should just be printed like any other directory in an error message and surrounded by escaped quotes, rather than relying on the debug print to add quotes (`"\"{}\""`). I also checked the test suite to see if this output is being correctly tested. It's not - it only tests up to the word "directory". Presumably this is so that the test is not dependent on its exact position in the source tree. I don't know a better way to test this, unless the test suite supports regex?
2018-03-29Fix escaped backslash in windows file not found messagePhlosioneer-1/+1
When a module is declared, but no matching file exists, rustc gives an error like 'help: name the file either foo.rs or foo/mod.rs inside the directory "src/bar"'. However, at on windows, the backslash was double-escaped when naming the directory. It did this because the string was printed in debug mode ( "{:?}" ) to surround it with quotes. However, it should just be printed like any other directory in an error message and surrounded by escaped quotes, rather than relying on the debug print to add quotes ( "\"{}\"" ).
2018-03-27libsyntax: Remove obsolete.rsVadim Petrochenkov-6/+0
2018-03-24Better diagnostics for '..' pattern fragment not in the last positionHidehito Yabuuchi-1/+7
2018-03-23Merge branch 'master' of https://github.com/Lymia/rust into rollupAlex Crichton-12/+17
2018-03-20Stabilize slice patterns without `..`Vadim Petrochenkov-1/+1
Merge `feature(advanced_slice_patterns)` into `feature(slice_patterns)`
2018-03-18Move raw_identifiers check to the lexer.Lymia Aluysia-4/+1
2018-03-18Feature gate raw identifiers.Lymia Aluysia-1/+4
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-12/+17
2018-03-18Auto merge of #48917 - petrochenkov:import, r=oli-obkbors-80/+36
syntax: Make imports in AST closer to the source and cleanup their parsing This is a continuation of https://github.com/rust-lang/rust/pull/45846 in some sense.
2018-03-17Cleanup import parsingVadim Petrochenkov-53/+22
Fix spans of root segments
2018-03-17Rename `Span::empty` to `Span::shrink_to_lo`, add `Span::shrink_to_hi`Vadim Petrochenkov-1/+1
2018-03-17AST: Keep distinction between `path` and `::path` in imports and visibilitiesVadim Petrochenkov-10/+5
Add the root segment for name resolution purposes only
2018-03-17AST: Make renames in imports closer to the sourceVadim Petrochenkov-3/+1
Fix `unused_import_braces` lint false positive on `use prefix::{self as rename}`
2018-03-17AST/HIR: Clarify what the optional name in extern crate items meanVadim Petrochenkov-13/+7
2018-03-17syntax: Make `_` an identifierVadim Petrochenkov-20/+16
2018-03-16Auto merge of #49051 - kennytm:rollup, r=kennytmbors-1/+5
Rollup of 17 pull requests - Successful merges: #48706, #48875, #48892, #48922, #48957, #48959, #48961, #48965, #49007, #49024, #49042, #49050, #48853, #48990, #49037, #49049, #48972 - Failed merges:
2018-03-15Disallow &a..=b and box a..=b in pattern.kennytm-2/+27
They are disallowed because they have different precedence than expressions. I assume parenthesis in pattern will be soon stabilized and thus write that as suggestion directly.
2018-03-14Implement import renaming with `_` (RFC 2166)Vadim Petrochenkov-1/+5
2018-03-11in which some labels and notes are upgraded to structured suggestionsZack M. Davis-5/+8
(Meanwhile, a couple of parse-fail tests are moved to UI tests so that the reader can see the new output, and an existing UI test is given a more evocative name.)
2018-03-09Auto merge of #48326 - RalfJung:generic-bounds, r=petrochenkovbors-12/+3
Warn about ignored generic bounds in `for` This adds a new lint to fix #42181. For consistency and to avoid code duplication, I also moved the existing "bounds in type aliases are ignored" here. Questions to the reviewer: * Is it okay to just remove a diagnostic error code like this? Should I instead keep the warning about type aliases where it is? The old code provided a detailed explanation of what's going on when asked, that information is now lost. On the other hand, `span_warn!` seems deprecated (after this patch, it has exactly one user left!). * Did I miss any syntactic construct that can appear as `for` in the surface syntax? I covered function types (`for<'a> fn(...)`), generic traits (`for <'a> Fn(...)`, can appear both as bounds as as trait objects) and bounds (`for<'a> F: ...`). * For the sake of backwards compatibility, this adds a warning, not an error. @nikomatsakis suggested an error in https://github.com/rust-lang/rust/issues/42181#issuecomment-306924389, but I feel that can only happen in a new epoch -- right? Cc @eddyb
2018-03-08in which parentheses are suggested for should-have-been-tuple-patternsZack M. Davis-5/+39
Programmers used to working in some other languages (such as Python or Go) might expect to be able to destructure values with comma-separated identifiers but no parentheses on the left side of an assignment. Previously, the first name in such code would get parsed as a single-indentifier pattern—recognizing, for example, the `let a` in `let a, b = (1, 2);`—whereupon we would have a fatal syntax error on seeing an unexpected comma rather than the expected semicolon (all the way nearer to the end of `parse_full_stmt`). Instead, let's look for that comma when parsing the pattern, and if we see it, momentarily make-believe that we're parsing the remaining elements in a tuple pattern, so that we can suggest wrapping it all in parentheses. We need to do this in a separate wrapper method called on the top-level pattern (or `|`-patterns) in a `let` statement, `for` loop, `if`- or `while let` expression, or match arm rather than within `parse_pat` itself, because `parse_pat` gets called recursively to parse the sub-patterns within a tuple pattern. Resolves #48492.