about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2016-03-31Rollup merge of #32494 - pnkfelix:gate-parser-recovery-via-debugflag, r=nrcManish Goregaokar-0/+9
Gate parser recovery via debugflag Gate parser recovery via debugflag Put in `-Z continue_parse_after_error` This works by adding a method, `fn abort_if_no_parse_recovery`, to the diagnostic handler in `syntax::errors`, and calling it after each error is emitted in the parser. (We might consider adding a debugflag to do such aborts in other places where we are currently attempting recovery, such as resolve, but I think the parser is the really important case to handle in the face of #31994 and the parser bugs of varying degrees that were injected by parse error recovery.) r? @nikomatsakis
2016-03-30Put in `-Z continue-parse-after-error`Felix S. Klock II-0/+9
This works by adding a boolean flag, `continue_after_error`, to `syntax::errors::Handler` that can be imperatively set to `true` or `false` via a new `fn set_continue_after_error`. The flag starts off true (since we generally try to recover from compiler errors, and `Handler` is shared across all phases). Then, during the `phase_1_parse_input`, we consult the setting of the `-Z continue-parse-after-error` debug flag to determine whether we should leave the flag set to `true` or should change it to `false`. ---- (We might consider adding a debugflag to do such aborts in other places where we are currently attempting recovery, such as resolve, but I think the parser is the really important case to handle in the face of #31994 and the parser bugs of varying degrees that were injected by parse error recovery.)
2016-03-28Auto merge of #32479 - eddyb:eof-not-even-twice, r=nikomatsakisbors-9/+28
Prevent bumping the parser past the EOF. Makes `Parser::bump` after EOF into an ICE, forcing callers to avoid repeated EOF bumps. This ICE is intended to break infinite loops where EOF wasn't stopping the loop. For example, the handling of EOF in `parse_trait_items`' recovery loop fixes #32446. But even without this specific fix, the ICE is triggered, which helps diagnosis and UX. This is a `[breaking-change]` for plugins authors who eagerly eat multiple EOFs. See https://github.com/docopt/docopt.rs/pull/171 for such an example and the necessary fix.
2016-03-28Auto merge of #32267 - durka:inclusive-range-error, r=nrcbors-29/+44
melt the ICE when lowering an impossible range Emit a fatal error instead of panicking when HIR lowering encounters a range with no `end` point. This involved adding a method to wire up `LoweringContext::span_fatal`. Fixes #32245 (cc @nodakai). r? @nrc
2016-03-27Type macro is tracked at rust-lang/rust#27245, not 27336NODA, Kai-1/+1
Signed-off-by: NODA, Kai <nodakai@gmail.com>
2016-03-26syntax: Stop the bump loop for trait items at } and EOF.Eduard Burtescu-9/+17
2016-03-26syntax: Prevent bumping the parser EOF to stop infinite loops.Eduard Burtescu-0/+11
2016-03-26Rollup merge of #32435 - nrc:fix-err-recover, r=nikomatsakisManish Goregaokar-24/+71
Some fixes for error recovery in the compiler
2016-03-26Rollup merge of #32199 - nikomatsakis:limiting-constants-in-patterns-2, ↵Manish Goregaokar-7/+69
r=pnkfelix Restrict constants in patterns This implements [RFC 1445](https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md). The primary change is to limit the types of constants used in patterns to those that *derive* `Eq` (note that implementing `Eq` is not sufficient). This has two main effects: 1. Floating point constants are linted, and will eventually be disallowed. This is because floating point constants do not implement `Eq` but only `PartialEq`. This check replaces the existing special case code that aimed to detect the use of `NaN`. 2. Structs and enums must derive `Eq` to be usable within a match. This is a [breaking-change]: if you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement `Eq`. Something like the following: ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*): ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`): ```rust match foo { c if c == SOME_CONST => ... } ``` Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details. cc https://github.com/rust-lang/rust/issues/31434 r? @pnkfelix
2016-03-25unit-test symbol-names and item-pathsNiko Matsakis-0/+7
2016-03-25do not overwrite spans as eagerlyNiko Matsakis-6/+61
this was required to preserve the span from the #[structural_match] attribute -- but honestly I am not 100% sure if it makes sense.
2016-03-25modify #[deriving(Eq)] to emit #[structural_match]Niko Matsakis-1/+8
to careful use of the span from deriving, we can permit it in stable code if it derives from deriving (not-even-a-pun intended)
2016-03-24Rollup merge of #32459 - nrc:json-err-text, r=nikomatsakisSteve Klabnik-1/+39
Include source text in JSON errors
2016-03-24address nitsAlex Burka-3/+4
2016-03-24error during parsing for malformed inclusive rangeAlex Burka-29/+38
Now it is impossible for `...` or `a...` to reach HIR lowering without a rogue syntax extension in play.
2016-03-24fatal error instead of ICE for impossible range during HIR loweringAlex Burka-0/+5
End-less ranges (`a...`) don't parse but bad syntax extensions could conceivably produce them. Unbounded ranges (`...`) do parse and are caught here. The other panics in HIR lowering are all for unexpanded macros, which cannot be constructed by bad syntax extensions.
2016-03-24TestsNick Cameron-1/+6
2016-03-24Include source text in JSON errorsNick Cameron-1/+39
2016-03-23Auto merge of #32455 - TimNN:patch-1, r=alexcrichtonbors-1/+1
add naked function tracking issue # to feature gate definition
2016-03-23add naked function tracking issue # to feature gate definitionTim Neumann-1/+1
2016-03-23Auto merge of #32390 - japaric:untry, r=pnkfelixbors-1531/+1517
convert 99.9% of `try!`s to `?`s The first commit is an automated conversion using the [untry] tool and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [untry]: https://github.com/japaric/untry cc @rust-lang/lang @alexcrichton @brson
2016-03-22fix alignmentJorge Aparicio-138/+133
2016-03-22break long lineJorge Aparicio-1/+2
2016-03-22sprinkle feature gates here and thereJorge Aparicio-0/+1
2016-03-22try! -> ?Jorge Aparicio-1452/+1441
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-23Error recovery in the tokeniserNick Cameron-25/+58
Closes #31994
2016-03-23Don't loop forever on error recovery with EOFNick Cameron-1/+10
closes #31804
2016-03-22Add testsTicki-1/+1
2016-03-21Add support for naked functionsTicki-0/+6
2016-03-19Rollup merge of #32269 - richo:impl-totokens-p-implitem, r=nikomatsakisEduard-Mihai Burtescu-0/+6
syntax: impl ToTokens for P<ast::ImplItem> I'm working on updating zinc for latest rust, and it appears that I need this impl[0]. More generally, I realise that libsyntax is "Whatever the compiler team needs to build a compiler", but should I just open a PR fleshing this out for all types? https://github.com/hackndev/zinc/blob/master/ioreg/src/builder/setter.rs#L194-L197
2016-03-17Add -Z orbit for forcing MIR for everything, unless #[rustc_no_mir] is used.Eduard Burtescu-4/+8
2016-03-16Auto merge of #31746 - erickt:newline, r=sfacklerbors-1/+2
syntax: Always pretty print a newline after doc comments Before this patch, code that had a doc comment as the first line, as in: ```rust /// Foo struct Foo; ``` Was pretty printed into: ```rust ///Foostruct Foo; ``` This makes sure that that there is always a trailing newline after a doc comment. Closes #31722
2016-03-15syntax: impl ToTokens for P<ast::ImplItem>Richo Healey-0/+6
2016-03-14Add pretty printer output for `default`Aaron Turon-0/+3
2016-03-14Fixes after a rebaseAaron Turon-3/+2
2016-03-14Address basic nits from initial reviewAaron Turon-0/+1
2016-03-14Assorted fixed after rebasingAaron Turon-6/+6
2016-03-14Add feature gateAaron Turon-0/+12
2016-03-14Add `default` as contextual keyword, and parse it for impl items.Aaron Turon-54/+93
2016-03-12Removed integer suffixes in libsyntax cratesrinivasreddy-5/+5
2016-03-09Auto merge of #31631 - jonas-schievink:agoraphobia, r=nrcbors-96/+88
[breaking-batch] Move more uses of `panictry!` out of libsyntax
2016-03-09Auto merge of #32071 - jseyfried:parse_pub, r=nikomatsakisbors-34/+10
Make errors for unnecessary visibility qualifiers consistent This PR refactors away `syntax::parse::parser::ParsePub` so that unnecessary visibility qualifiers on variant fields are reported not by the parser but by `privacy::SanePrivacyVisitor` (thanks to @petrochenkov's drive-by improvements in #31919). r? @nikomatsakis
2016-03-08Auto merge of #31954 - japaric:rfc243, r=nikomatsakisbors-2/+27
implement the `?` operator The `?` postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining: `File::open("foo")?.metadata()?.is_dir()`. `?` is accepted on any *expression* that can return a `Result`, e.g. `x()?`, `y!()?`, `{z}?`, `(w)?`, etc. And binds more tightly than unary operators, e.g. `!x?` is parsed as `!(x?)`. cc #31436 --- cc @aturon @eddyb
2016-03-07Auto merge of #29734 - Ryman:whitespace_consistency, r=Aatchbors-61/+72
libsyntax: be more accepting of whitespace in lexer Fixes #29590. Perhaps this may need more thorough testing? r? @Aatch
2016-03-07implement the `?` operatorJorge Aparicio-2/+27
The `?` postfix operator is sugar equivalent to the try! macro, but is more amenable to chaining: `File::open("foo")?.metadata()?.is_dir()`. `?` is accepted on any *expression* that can return a `Result`, e.g. `x()?`, `y!()?`, `{z}?`, `(w)?`, etc. And binds more tightly than unary operators, e.g. `!x?` is parsed as `!(x?)`. cc #31436
2016-03-07syntax: Always pretty print a newline after doc commentsErick Tryzelaar-1/+2
Before this patch, code that had a doc comment as the first line, as in: ```rust /// Foo struct Foo; ``` Was pretty printed into: ```rust ///Foostruct Foo; ``` This makes sure that that there is always a trailing newline after a doc comment. Closes #31722
2016-03-06Auto merge of #30884 - durka:inclusive-ranges, r=aturonbors-50/+92
This PR implements [RFC 1192](https://github.com/rust-lang/rfcs/blob/master/text/1192-inclusive-ranges.md), which is triple-dot syntax for inclusive range expressions. The new stuff is behind two feature gates (one for the syntax and one for the std::ops types). This replaces the deprecated functionality in std::iter. Along the way I simplified the desugaring for all ranges. This is my first contribution to rust which changes more than one character outside of a test or comment, so please review carefully! Some of the individual commit messages have more of my notes. Also thanks for putting up with my dumb questions in #rust-internals. - For implementing `std::ops::RangeInclusive`, I took @Stebalien's suggestion from https://github.com/rust-lang/rfcs/pull/1192#issuecomment-137864421. It seemed to me to make the implementation easier and increase type safety. If that stands, the RFC should be amended to avoid confusion. - I also kind of like @glaebhoerl's [idea](https://github.com/rust-lang/rfcs/pull/1254#issuecomment-147815299), which is unified inclusive/exclusive range syntax something like `x>..=y`. We can experiment with this while everything is behind a feature gate. - There are a couple of FIXMEs left (see the last commit). I didn't know what to do about `RangeArgument` and I haven't added `Index` impls yet. Those should be discussed/finished before merging. cc @Gankro since you [complained](https://www.reddit.com/r/rust/comments/3xkfro/what_happened_to_inclusive_ranges/cy5j0yq) cc #27777 #30877 rust-lang/rust#1192 rust-lang/rfcs#1254 relevant to #28237 (tracking issue)
2016-03-06Refactor away `ParsePub` and make errors for unnecessary visibility ↵Jeffrey Seyfried-34/+10
qualifiers consistent
2016-03-02Fix the search paths for macro-expanded non-inline modulesJeffrey Seyfried-3/+60
2016-03-02Add `filename` to ParserJeffrey Seyfried-1/+6