about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2018-02-23Rollup merge of #48083 - ↵Manish Goregaokar-5/+3
jseyfried:improve_tuple_struct_field_access_hygiene, r=petrochenkov Improve tuple struct field access hygiene Fixes #47312 by fixing a span bug. r? @nrc
2018-02-23Auto merge of #47799 - topecongiro:fix-span-of-visibility, r=petrochenkovbors-19/+34
Fix span of visibility This PR 1. adds a closing parenthesis to the span of `Visibility::Crate` (e.g. `pub(crate)`). The current span only covers `pub(crate`. 2. adds a `span` field to `Visibility::Restricted`. This span covers the entire visibility expression (e.g. `pub (in self)`). Currently all we can have is a span for `Path`. This PR is motivated by the bug found in rustfmt (https://github.com/rust-lang-nursery/rustfmt/issues/2398). The first change is a strict improvement IMHO. The second change may not be desirable, as it adds a field which is currently not used by the compiler.
2018-02-17fix more typos found by codespell.Matthias Krüger-2/+2
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-22/+28
2018-02-18Add a span field to Visibility::RestrictedSeiichi Uchida-2/+10
This span covers the whole visibility expression: e.g. `pub (in path)`.
2018-02-18Add a closing parenthesis to the span of Visibility::CrateSeiichi Uchida-2/+3
2018-02-11Continue parsing function after finding `...` argEsteban Küber-5/+16
When encountering a variadic argument in a function definition that doesn't accept it, if immediately after there's a closing paren, continue parsing as normal. Otherwise keep current behavior of emitting error and stopping.
2018-02-08Fix span bug.Jeffrey Seyfried-5/+3
2018-02-07Rollup merge of #47613 - estebank:rustc_on_unimplemented, r=nikomatsakisManish Goregaokar-17/+14
Add filtering options to `rustc_on_unimplemented` - Add filtering options to `rustc_on_unimplemented` for local traits, filtering on `Self` and type arguments. - Add a way to provide custom notes. - Tweak binops text. - Add filter to detect wether `Self` is local or belongs to another crate. - Add filter to `Iterator` diagnostic for `&str`. Partly addresses #44755 with a different syntax, as a first approach. Fixes #46216, fixes #37522, CC #34297, #46806.
2018-02-01Fix test after rebaseEsteban Küber-4/+0
2018-02-01Remove support for `Self` in attributesEsteban Küber-7/+1
2018-02-01Fix testsEsteban Küber-1/+1
2018-02-01Rework `parse_ident_attr`Esteban Küber-25/+26
2018-02-01Add filtering options to `rustc_on_unimplemented`Esteban Küber-5/+11
- filter error on the evaluated value of `Self` - filter error on the evaluated value of the type arguments - add argument to include custom note in diagnostic - allow the parser to parse `Self` when processing attributes - add custom message to binops
2018-01-30stabilize match_beginning_vertJonathan Goodman-6/+1
2018-01-30Auto merge of #45294 - petrochenkov:prioplus, r=nikomatsakisbors-10/+25
syntax: Lower priority of `+` in `impl Trait`/`dyn Trait` Now you have to write `Fn() -> (impl A + B)` instead of `Fn() -> impl A + B`, this is consistent with priority of `+` in trait objects (`Fn() -> A + B` means `(Fn() -> A) + B`). To make this viable I changed the syntax to also permit `+` in return types in function declarations ``` fn f() -> dyn A + B { ... } // OK, don't have to write `-> (dyn A + B)` // This is acceptable, because `dyn A + B` here is an isolated type and // not part of a larger type with various operator priorities in play // like `dyn A + B` in `Fn() -> dyn A + B` despite syntax similarities. ``` but you still have to use `-> (dyn A + B)` in function types and function-like trait object types (see this PR's tests for examples). This can be a breaking change for code using `impl Trait` on nightly. The thing that is most likely to break is `&impl A + B`, it needs to be rewritten as `&(impl A + B)`. cc https://github.com/rust-lang/rust/issues/34511 https://github.com/rust-lang/rust/issues/44662 https://github.com/rust-lang/rfcs/pull/438
2018-01-28Auto merge of #47767 - estebank:as-suggestion, r=petrochenkovbors-0/+1
Correctly format `extern crate` conflict resolution help Closes #45799. Follow up to @Cldfire's #45820. If the `extern` statement that will have a suggestion ends on a `;`, synthesize a new span that doesn't include it.
2018-01-27Make `+` in `impl/dyn Trait` non-associativeVadim Petrochenkov-3/+19
2018-01-27syntax: Permit `+` in return types of function declarationsVadim Petrochenkov-6/+6
`+` is still disallowed in function types and function-like traits
2018-01-27syntax: Lower priority of `+` in `impl Trait`/`dyn Trait`Vadim Petrochenkov-4/+3
2018-01-27end_point handling multibyte characters correctly.David Wood-3/+5
2018-01-26Instead of modifying the item's span synthesize itEsteban Küber-2/+1
2018-01-25Correctly format `extern crate` conflict resolution helpCldfire-1/+3
2018-01-25Rollup merge of #47502 - petrochenkov:label, r=eddybAlex Crichton-41/+23
AST/HIR: Add a separate structure for labels
2018-01-23Adds support for immovable generators. Move checking of invalid borrows ↵John Kåre Alsaker-10/+35
across suspension points to borrowck. Fixes #44197, #45259 and #45093.
2018-01-22AST/HIR: Add a separate structure for labelsVadim Petrochenkov-41/+23
2018-01-15Point at unused arguments for format stringEsteban Küber-10/+15
Avoid overlapping spans by only pointing at the arguments that are not being used in the argument string. Enable libsyntax to have diagnostics with multiple primary spans by accepting `Into<MultiSpan>` instead of `Span`.
2018-01-14syntax: Disambiguate generics and qualified pathsVadim Petrochenkov-15/+33
2018-01-14syntax: Rewrite parsing of implsVadim Petrochenkov-154/+125
Properly parse impls for the never type `!` Recover from missing `for` in `impl Trait for Type` Prohibit inherent default impls and default impls of auto traits Change wording in more diagnostics to use "auto traits" Some minor code cleanups in the parser
2018-01-13Re-add support for `impl Trait for ..` to the parserVadim Petrochenkov-1/+5
2018-01-13Address review.leonardo.yvens-4/+4
2018-01-13Parse `auto trait` inside fns.leonardo.yvens-12/+16
Also refactored parsing auto traits.
2018-01-13Remove `impl Foo for ..` in favor of `auto trait Foo`leonardo.yvens-38/+19
No longer parse it. Remove AutoTrait variant from AST and HIR. Remove backwards compatibility lint. Remove coherence checks, they make no sense for the new syntax. Remove from rustdoc.
2018-01-13Auto merge of #47242 - estebank:issue-15980, r=petrochenkovbors-11/+42
`struct` pattern parsing and diagnostic tweaks - Recover from struct parse error on match and point out missing match body. - Point at struct when finding non-identifier while parsing its fields. - Add label to "expected identifier, found {}" error. Fix #15980.
2018-01-13Rollup merge of #47298 - cramertj:path-as-modrs, r=nikomatsakiskennytm-4/+8
Treat #[path] files as mod.rs files Fixes https://github.com/rust-lang/rust/issues/46936, cc @briansmith, @SergioBenitez, @nikomatsakis. This (insta-stable) change treats files included via `#[path = "bla.rs"] mod foo;` as though they were `mod.rs` files. Namely, it allows them to include `mod` statements and looks for the child modules in sibling directories, rather than in relative `modname/childmodule.rs` files as happens for non-`mod.rs` files. This change makes the `non_modrs_mods` feature backwards compatible with the existing usage in https://github.com/briansmith/ring, several versions of which are currently broken in beta. If we decide to merge, this change should be backported to beta. cc https://github.com/rust-lang/rust/issues/37872 r? @jseyfried
2018-01-09Treat #[path] files as mod.rs filesTaylor Cramer-4/+8
2018-01-08Auto merge of #47232 - keatinge:master, r=petrochenkovbors-2/+14
Add help message for incorrect pattern syntax When I was getting started with rust I often made the mistake of using `||` instead of `|` to match multiple patterns and spent a long time staring at my code wondering what was wrong. for example: ``` fn main() { let x = 1; match x { 1 || 2 => println!("1 or 2"), _ => println!("Something else"), } } ``` If you compile this with current rustc you will see ``` error: expected one of `...`, `..=`, `..`, `=>`, `if`, or `|`, found `||` --> test.rs:5:11 | 5 | 1 || 2 => println!("1 or 2"), | -^^ unexpected token | | | expected one of `...`, `..=`, `..`, `=>`, `if`, or `|` here error: aborting due to previous error ``` With my proposed change it will show: ``` error: unexpected token `||` after pattern --> test.rs:5:11 | 5 | 1 || 2 => println!("1 or 2"), | ^^ | = help: did you mean to use `|` to specify multiple patterns instead? error: aborting due to previous error ```
2018-01-07`struct` pattern parsing and diagnostic tweaksEsteban Küber-11/+42
- Recover from struct parse error on match and point out missing match body. - Point at struct when finding non-identifier while parsing its fields. - Add label to "expected identifier, found {}" error.
2018-01-06Fix tidy errorkeatinge-2/+5
2018-01-06Use span_suggestion instead of span_err_helpkeatinge-3/+3
2018-01-06fix stylekeatinge-4/+2
2018-01-06Emit non-fatal error insteadkeatinge-8/+10
2018-01-06fix capitalizationkeatinge-2/+2
2018-01-06Add help message for incorrect pattern syntaxkeatinge-1/+10
2018-01-03Support `extern` in pathsVadim Petrochenkov-4/+11
2018-01-01Auto merge of #46895 - ricochet1k:macro-lifetimes, r=jseyfriedbors-8/+10
Allow lifetimes in macros This is a resurrection of PR #41927 which was a resurrection of #33135, which is intended to fix #34303. In short, this allows macros_rules! to use :lifetime as a matcher to match 'lifetimes. Still to do: - [x] Feature gate
2017-12-30in which leading zeroes on tuple-struct accesses are abjuredZack M. Davis-3/+12
Resolves #47073.
2017-12-30refactor lifetime out of is_lifetimeMatt Peterson-13/+6
2017-12-28CleanupMatt Peterson-4/+3
2017-12-28Fix testsMatt Peterson-7/+17