about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2015-05-07Fix use of UFCS syntax to call methods on associated types.Sean Patrick Santos-35/+15
2015-05-05Use `empty()` instead of a special constTamir Duberstein-3/+2
2015-05-01Rollup merge of #24981 - carols10cents:remove-more-priv, r=alexcrichtonManish Goregaokar-1/+1
Hi! While researching stuff for the reference and the grammar, I came across a few mentions of using the `priv` keyword that was removed in 0.11.0 (#13547, #8122, rust-lang/rfcs#26, [RFC 0026](https://github.com/rust-lang/rfcs/blob/master/text/0026-remove-priv.md)). One occurrence is a mention in the reference, a few are in comments, and a few are marking test functions. I left the test that makes sure you can't name an ident `priv` since it's still a reserved keyword. I did a little grepping around for `priv `, priv in backticks, `Private` etc and I think the remaining instances are fine, but if anyone knows anywhere in particular I should check for any other lingering mentions of `priv`, please let me know and I would be happy to! :fallen_leaf: :ocean:
2015-04-29Remove mention of 'priv'; visibility is either PUB or nothingCarol Nichols-1/+1
2015-04-29FalloutTamir Duberstein-17/+20
2015-04-27Auto merge of #23606 - quantheory:associated_const, r=nikomatsakisbors-81/+134
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-25Interpolate AST nodes in quasiquote.Geoffry Song-180/+13
This changes the `ToTokens` implementations for expressions, statements, etc. with almost-trivial ones that produce `Interpolated(*Nt(...))` pseudo-tokens. In this way, quasiquote now works the same way as macros do: already-parsed AST fragments are used as-is, not reparsed. The `ToSource` trait is removed. Quasiquote no longer involves pretty-printing at all, which removes the need for the `encode_with_hygiene` hack. All associated machinery is removed. A new `Nonterminal` is added, NtArm, which the parser now interpolates. This is just for quasiquote, not macros (although it could be in the future). `ToTokens` is no longer implemented for `Arg` (although this could be added again) and `Generics` (which I don't think makes sense). This breaks any compiler extensions that relied on the ability of `ToTokens` to turn AST fragments back into inspectable token trees. For this reason, this closes #16987. As such, this is a [breaking-change]. Fixes #16472. Fixes #15962. Fixes #17397. Fixes #16617.
2015-04-25Auto merge of #24547 - bombless:comma, r=pnkfelixbors-1/+40
Closes #20616 It breaks code such as <https://github.com/rust-lang/rust/blob/c64feb63418fd05bd6e5adc6f9ad763aa6a594b1/src/librustc_typeck/check/method/suggest.rs#L367>, so this is a [breaking-change], you have to add missing comma after the last lifetime arguement now.
2015-04-25Fix #20616York Xiang-1/+40
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-4/+4
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-23Get associated consts working in match patterns.Sean Patrick Santos-79/+110
2015-04-23Functional changes for associated constants. Cross-crate usage of associated ↵Sean Patrick Santos-2/+24
constants is not yet working.
2015-04-24Do not include attributes in trait item spans.Nick Cameron-5/+4
(And other kinds of items).
2015-04-23Auto merge of #24683 - P1start:help-suggestions, r=nrcbors-3/+8
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-22Auto merge of #24685 - nrc:span-pred, r=huonwbors-3/+3
2015-04-22Fix spans for predicates in where clausesNick Cameron-3/+3
2015-04-21rollup merge of #24636: alexcrichton/remove-deprecatedAlex Crichton-2/+0
Conflicts: src/libcore/result.rs
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-2/+0
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-21syntax: Copy unstable str::char_at into libsyntaxErick Tryzelaar-16/+18
2015-04-21syntax: Remove #[feature(path_ext)]Erick Tryzelaar-2/+3
Replace Path::exists with stable metadata call.
2015-04-21syntax: replace Vec::push_all with stable Vec::extendErick Tryzelaar-9/+14
2015-04-21syntax: Replace String::from_str with the stable String::fromErick Tryzelaar-2/+2
2015-04-21syntax: remove uses of `.into_cow()`Erick Tryzelaar-4/+4
2015-04-21syntax: Remove uses of #[feature(slice_patterns)]Erick Tryzelaar-15/+31
2015-04-21syntax: remove #![feature(box_syntax, box_patterns)]Erick Tryzelaar-6/+6
2015-04-21Change a few error messages to give code suggestionsP1start-3/+8
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.
2015-04-16Omit 'obsolete' note for warning if -AwarningMathijs van de Nes-1/+2
2015-04-16Auto merge of #23682 - tamird:DRY-is-empty, r=alexcrichtonbors-11/+11
r? @alexcrichton
2015-04-16Auto merge of #24485 - brson:is, r=alexcrichtonbors-2/+0
It was an oversight that this was not done in the great int upheaval. [breaking-change]
2015-04-15Forbid is/us suffixes. Fixes #22496Brian Anderson-2/+0
It was an oversight that this was not done in the great int upheaval. [breaking-change]
2015-04-15Rollup merge of #24438 - nrc:tuple-span, r=sfacklerSteve Klabnik-1/+1
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-4/+4
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14Positive case of `len()` -> `is_empty()`Tamir Duberstein-7/+7
`s/(?<!\{ self)(?<=\.)len\(\) == 0/is_empty()/g`
2015-04-15Fix the span for tuple expressionsNick Cameron-1/+1
2015-04-14rollup merge of #24381: erickt/cleanupAlex Crichton-1/+1
Just some minor patches I've been sitting on.
2015-04-14std: Remove old_io/old_path/rand modulesAlex Crichton-16/+0
This commit entirely removes the old I/O, path, and rand modules. All functionality has been deprecated and unstable for quite some time now!
2015-04-14Auto merge of #24295 - contradictioned:master, r=alexcrichtonbors-1/+7
As i proposed in #24262 (and found acceptance in the IRC channel), added a compiler warning for wrong escaping of curly braces.
2015-04-13syntax: Publically expose printing where clauses, and add attr_to_stringErick Tryzelaar-1/+1
2015-04-13Added a help span which informs the user about the escaping of curly braces ↵Manuel Hoffmann-1/+7
in a format string if a wrongly escaped one is detected in a string.
2015-04-12Fix spans for macrosNick Cameron-9/+11
2015-04-09Fix the span for `for` expressionsNick Cameron-1/+1
2015-04-05Work towards a non-panicing parser (libsyntax)Phil Dawes-1247/+1306
- Functions in parser.rs return PResult<> rather than panicing - Other functions in libsyntax call panic! explicitly for now if they rely on panicing behaviour. - 'panictry!' macro added as scaffolding while converting panicing functions. (This does the same as 'unwrap()' but is easier to grep for and turn into try!()) - Leaves panicing wrappers for the following functions so that the quote_* macros behave the same: - parse_expr, parse_item, parse_pat, parse_arm, parse_ty, parse_stmt
2015-04-02Fix parsing of patterns in macrosVadim Petrochenkov-1/+3
2015-04-02syntax: Rewrite parsing of patternsVadim Petrochenkov-225/+127
2015-04-01Fallout in libsyntaxNiko Matsakis-3/+3
2015-03-31rollup merge of #23872: huonw/eager-lexingAlex Crichton-15/+40
Conflicts: src/libsyntax/parse/lexer/mod.rs
2015-03-31Stabilize std::numAaron Turon-9/+9
This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping<X>` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change]
2015-03-31Lex binary and octal literals more eagerly.Huon Wilson-14/+39
Previously 0b12 was considered two tokens, 0b1 and 2, as 2 isn't a valid base 2 digit. This patch changes that to collapse them into one (and makes `0b12` etc. an error: 2 isn't a valid base 2 digit). This may break some macro invocations of macros with `tt` (or syntax extensions) that rely on adjacent digits being separate tokens and hence is a [breaking-change] The fix is to separate the tokens, e.g. `0b12` -> `0b1 2`. cc https://github.com/rust-lang/rfcs/pull/879
2015-03-28Rollup merge of #23803 - richo:unused-braces, r=ManishearthManish Goregaokar-2/+2
Pretty much what it says on the tin.
2015-03-28cleanup: Remove unused braces in use statementsRicho Healey-2/+2