about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2017-12-02Auto merge of #46343 - jseyfried:fix_hygiene_bug, r=nrcbors-3/+10
Fix hygiene bug. Fixes #42708. r? @nrc
2017-12-02Auto merge of #45904 - sunjay:gat-parser, r=nikomatsakisbors-4/+43
Generic Associated Types Parsing & Name Resolution Hi! This PR adds parsing for generic associated types! :tada: :tada: :tada: Tracking Issue: #44265 ## Notes For Reviewers * [x] I still need to add the stdout and stderr files to my ui tests. It takes me a *long* time to compile the compiler locally, so I'm going to add this as soon as possible in the next day or so. * [ ] My current ui tests aren't very good or very thorough. I'm reusing the `parse_generics` and `parse_where_clause` methods from elsewhere in the parser, so my changes work without being particularly complex. I'm not sure if I should duplicate all of the generics test cases for generic associated types. It might actually be appropriate to duplicate everything here, since we don't want to rely on an implementation detail in case it changes in the future. If you think so too, I'll adapt all of the generics test cases into the generic associated types test cases. * [ ] There is still more work required to make the run-pass tests pass here. In particular, we need to make the following errors disappear: ``` error[E0110]: lifetime parameters are not allowed on this type --> ./src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs:23:41 | 23 | bar: <T as StreamingIterator>::Item<'static>, | ^^^^^^^ lifetime parameter not allowed on this type ``` ``` error[E0261]: use of undeclared lifetime name `'a` --> ./src/test/run-pass/rfc1598-generic-associated-types/iterable.rs:15:47 | 15 | type Iter<'a>: Iterator<Item = Self::Item<'a>>; | ^^ undeclared lifetime ``` There is a FIXME comment in streaming_iterator. If you uncomment that line, you get the following: ``` error: expected one of `!`, `+`, `,`, `::`, or `>`, found `=` --> ./src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs:29:45 | 29 | fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ } | ^ expected one of `!`, `+`, `,`, `::`, or `>` here ``` r? @nikomatsakis
2017-12-01Testing and fixesSunjay Varma-1/+1
2017-12-01Parsing where clauses correctly and documenting the grammar being parsedSunjay Varma-2/+8
2017-12-01Added run-pass tests for associated generic typesSunjay Varma-2/+2
2017-12-01Parsing generics in both trait items and impl itemsSunjay Varma-3/+36
2017-12-01Auto merge of #45997 - estebank:pub-ident, r=nikomatsakisbors-10/+111
Account for missing keyword in fn/struct definition Fix #38911.
2017-11-30Implement RFC 2128 (use_nested_groups)Pietro Albini-58/+85
This commit adds support for nested groups inside `use` declarations, such as `use foo::{bar, sub::{baz::Foo, *}};`.
2017-11-29Point to next token when it is in the expected lineEsteban Küber-5/+22
2017-11-28Fix hygiene bug.Jeffrey Seyfried-3/+10
2017-11-25Changed from note to span_suggestion_shortcolinmarsh19-1/+2
2017-11-25Fixed Err by passing "err"colinmarsh19-1/+1
2017-11-25Remove semicolon notecolinmarsh19-1/+5
Added note that specifies a semicolon should be removed after a given struct
2017-11-24Consume trailing doc comments to avoid parse errorsEsteban Küber-3/+2
2017-11-24Revert to correct recovery behaviorEsteban Küber-0/+1
2017-11-24Emit `DocComment` in bad location error but continue parsing struct fieldsEsteban Küber-2/+10
2017-11-24Suggest macro call when not sure that it is fn definitionEsteban Küber-19/+16
2017-11-24Do not attemt to continue parsing after `pub ident`Esteban Küber-105/+23
Try to identify the following code in order to provide better diagnostics, but return the error to bail out early during the parse.
2017-11-24Do not rewind parser and ignore following blocksEsteban Küber-52/+179
When encountering `pub ident`, attempt to identify the code that comes afterwards, wether it is a brace block (assume it is a struct), a paren list followed by a colon (assume struct) or a paren list followed by a block (assume a fn). Consume those blocks to avoid any further parser errors and return a `Placeholder` item in order to allow the parser to continue. In the case of unenclosed blocks, the behavior is the same as it is currently: no further errors are processed.
2017-11-24Account for missing keyword in fn/struct definitionEsteban Küber-1/+52
2017-11-22Update parser.rsMichael Howell-1/+1
2017-11-21Auto merge of #45771 - petrochenkov:crate, r=nikomatsakisbors-3/+15
Support `::crate` in paths cc https://github.com/rust-lang/rust/issues/45477 Fixes https://github.com/rust-lang/rust/issues/45229
2017-11-21Support `::crate` in pathsVadim Petrochenkov-3/+15
2017-11-20address review commentsAlex Burka-3/+2
2017-11-19use -Z flag instead of env varAlex Burka-1/+2
2017-11-11Accept interpolated patterns in trait method parametersVadim Petrochenkov-17/+9
Remove some outdated messages from "no patterns allowed" errors
2017-11-10Auto merge of #45773 - Badel2:dotdoteq, r=petrochenkovbors-15/+19
Add error for `...` in expressions Follow-up to https://github.com/rust-lang/rust/pull/44709 Tracking issue: https://github.com/rust-lang/rust/issues/28237 * Using `...` in expressions was a warning, now it's an error * The error message suggests using `..` or `..=` instead, and explains the difference * Updated remaining occurrences of `...` to `..=` r? petrochenkov
2017-11-08Auto merge of #45452 - estebank:colon-typo, r=nikomatsakisbors-44/+88
Detect `=` -> `:` typo in let bindings When encountering a let binding type error, attempt to parse as initializer instead. If successful, it is likely just a typo: ```rust fn main() { let x: Vec::with_capacity(10); } ``` ``` error: expected type, found `10` --> file.rs:3:31 | 3 | let x: Vec::with_capacity(10, 20); | -- ^^ | || | |help: did you mean assign here?: `=` | while parsing the type for `x` ``` Fix #43703.
2017-11-06Using `...` in expressions is now an errorBadel2-15/+19
2017-11-04Auto merge of #45711 - tirr-c:unicode-span, r=estebankbors-0/+1
Display spans correctly when there are zero-width or wide characters Hopefully... * fixes #45211 * fixes #8706 --- Before: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` After: ``` error: invalid width `7` for integer literal --> unicode_2.rs:12:25 | 12 | let _ = ("a̐éö̲", 0u7); | ^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: invalid width `42` for integer literal --> unicode_2.rs:13:20 | 13 | let _ = ("아あ", 1i42); | ^^^^ | = help: valid widths are 8, 16, 32, 64 and 128 error: aborting due to 2 previous errors ``` Spans might display incorrectly on the browser. r? @estebank
2017-11-04Rollup merge of #45639 - LaurentMazare:master, r=petrochenkovkennytm-1/+7
Add a nicer error message for missing in for loop, fixes #40782. As suggested by @estebank in issue #40782, this works in the same way as #42578: if the in keyword is missing, we continue parsing the expression and if this works correctly an adapted error message is produced. Otherwise we return the old error. A specific test case has also been added. This is my first PR on rust-lang/rust so any feedback is very welcome.
2017-11-03Detect `=` -> `:` typo in let bindingsEsteban Küber-44/+88
When encountering a let binding type error, attempt to parse as initializer instead. If successful, it is likely just a typo: ```rust fn main() { let x: Vec::with_capacity(10); } ``` ``` error: expected type, found `10` --> file.rs:3:31 | 3 | let x: Vec::with_capacity(10, 20); | -- ^^ | || | |help: did you mean assign here?: `=` | while parsing the type for `x` ```
2017-11-03Parse auto traits the same as traits.leonardo.yvens-49/+32
This moves the well formedness checks to the AST validation pass. Tests were adjusted. The auto keyword should be back-compat now.
2017-11-03Add tests for `auto trait`, fix parsing bugleonardo.yvens-31/+31
Now we can do the well formedness checks in the parser, yay!
2017-11-03add `auto` keyword, parse `auto trait`, lower to HIRleonardo.yvens-2/+44
Adds an `IsAuto` field to `ItemTrait` which flags if the trait was declared as an `auto trait`. Auto traits cannot have generics nor super traits.
2017-11-03[Syntax Breaking] Rename DefaultImpl to AutoImplleonardo.yvens-3/+3
DefaultImpl is a highly confusing name for what we now call auto impls, as in `impl Send for ..`. The name auto impl is not formally decided but for sanity anything is better than `DefaultImpl` which refers neither to `default impl` nor to `impl Default`.
2017-11-03Display spans correctly when there are non-half-width charactersWonwoo Choi-0/+1
2017-11-01Remove the redundant span_label.laurent-1/+0
2017-11-01Preserve original formatting.laurent-4/+1
2017-11-01Remove the parser snapshot hack.laurent-40/+16
2017-10-31Formatting tweak.laurent-2/+1
2017-10-31Add some missing spaces.laurent-1/+1
2017-10-31Fix spans and error messages.laurent-13/+6
2017-10-30edit and fix bad spacing of inner-attribute-not-allowed noteZack M. Davis-5/+4
This multiline string literal was missing a backslash, leaving an awkward newline and 35 spaces in the middle of the message. But while we're here, the existing message seems kind of long in comparison to similar notes: to cut it down, we excise the mentions of doc comments, which seems sensible because we know that this erroneous attribute is not a doc comment (notice the `is_sugared_doc: false` at the end of the function; if it had been a doc comment, that error would get set in the `token::DocComment` match branch of `parse_outer_attributes`).
2017-10-30Add a nicer error message for missing in for loop, fixes #40782.laurent-6/+48
2017-10-28Auto merge of #44295 - plietar:extern-types, r=arielb1bors-0/+22
Implement RFC 1861: Extern types A few notes : - Type parameters are not supported. This was an unresolved question from the RFC. It is not clear how useful this feature is, and how variance should be treated. This can be added in a future PR. - `size_of_val` / `align_of_val` can be called with extern types, and respectively return 0 and 1. This differs from the RFC, which specified that they should panic, but after discussion with @eddyb on IRC this seems like a better solution. If/when a `DynSized` trait is added, this will be disallowed statically. - Auto traits are not implemented by default, since the contents of extern types is unknown. This means extern types are `!Sync`, `!Send` and `!Freeze`. This seems like the correct behaviour to me. Manual `unsafe impl Sync for Foo` is still possible. - This PR allows extern type to be used as the tail of a struct, as described by the RFC : ```rust extern { type OpaqueTail; } #[repr(C)] struct FfiStruct { data: u8, more_data: u32, tail: OpaqueTail, } ``` However this is undesirable, as the alignment of `tail` is unknown (the current PR assumes an alignment of 1). Unfortunately we can't prevent it in the general case as the tail could be a type parameter : ```rust #[repr(C)] struct FfiStruct<T: ?Sized> { data: u8, more_data: u32, tail: T, } ``` Adding a `DynSized` trait would solve this as well, by requiring tail fields to be bound by it. - Despite being unsized, pointers to extern types are thin and can be casted from/to integers. However it is not possible to write a `null<T>() -> *const T` function which works with extern types, as I've explained here : https://github.com/rust-lang/rust/issues/43467#issuecomment-321678621 - Trait objects cannot be built from extern types. I intend to support it eventually, although how this interacts with `DynSized`/`size_of_val` is still unclear. - The definition of `c_void` is unmodified
2017-10-28Auto merge of #45503 - thombles:tk/i44339-v5, r=petrochenkovbors-1/+27
Improve diagnostics when list of tokens has incorrect separators Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations: ``` struct S(pub () ()); // omitted separator use std::{foo. bar}; // used a similar but wrong separator ``` Fixes #44339 r? @petrochenkov
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-0/+22
2017-10-25Auto merge of #44636 - GuillaumeGomez:little-error-msg, r=michaelwoeristerbors-1/+3
Add short error message-format Fixes #42653.
2017-10-25Improve recovery after unexpected tokens parsing sequenceThomas Karpiniec-1/+27