about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2017-09-16Auto merge of #43017 - durka:stabilize-const-invocation, r=eddybbors-14/+74
Individualize feature gates for const fn invocation This PR changes the meaning of `#![feature(const_fn)]` so it is only required to declare a const fn but not to call one. Based on discussion at #24111. I was hoping we could have an FCP here in order to move that conversation forward. This sets the stage for future stabilization of the constness of several functions in the standard library (listed below), so could someone please tag the lang team for review. - `std::cell` - `Cell::new` - `RefCell::new` - `UnsafeCell::new` - `std::mem` - `size_of` - `align_of` - `std::ptr` - `null` - `null_mut` - `std::sync` - `atomic` - `Atomic{Bool,Ptr,Isize,Usize}::new` - `once` - `Once::new` - primitives - `{integer}::min_value` - `{integer}::max_value` Some other functions are const but they are also unstable or hidden, e.g. `Unique::new` so they don't have to be considered at this time. After this stabilization, the following `*_INIT` constants in the standard library can be deprecated. I wasn't sure whether to include those deprecations in the current PR. - `std::sync` - `atomic` - `ATOMIC_{BOOL,ISIZE,USIZE}_INIT` - `once` - `ONCE_INIT`
2017-09-14Auto merge of #44484 - tirr-c:issue-44332, r=petrochenkovbors-6/+38
Parse nested closure with two consecutive parameter lists properly This is a followup of #44332. --- Currently, in nightly, this does not compile: ```rust fn main() { let f = |_||x, y| x+y; println!("{}", f(())(1, 2)); // should print 3 } ``` `|_||x, y| x+y` should be parsed as `|_| (|x, y| x+y)`, but the parser didn't accept `||` between `_` and `x`. This patch fixes the problem. r? @petrochenkov
2017-09-13honor #[rustc_const_unstable] attributesAlex Burka-14/+74
2017-09-13Auto merge of #44456 - eddyb:stable-drop-const, r=nikomatsakisbors-3/+2
Stabilize drop_types_in_const. Closes #33156, stabilizing the new, revised, rules, and improving the error message. r? @nikomatsakis cc @SergioBenitez
2017-09-12Auto merge of #43716 - MaloJaffre:_-in-literals, r=petrochenkovbors-47/+65
Accept underscores in unicode escapes Fixes #43692. I don't know if this need an RFC, but at least the impl is here!
2017-09-11Auto merge of #44375 - topecongiro:macrodef-span, r=petrochenkovbors-5/+5
Add visibility to span for macros 2.0 cc https://github.com/rust-lang-nursery/rustfmt/issues/1949. r? @nrc
2017-09-11Parse nested closure with two consecutive parameter lists properlyWonwoo Choi-6/+38
2017-09-10Rollup merge of #44332 - tirr-c:issue-44021, r=petrochenkovGuillaume Gomez-1/+1
Expect pipe symbol after closure parameter list Fixes #44021. --- Originally, the parser just called `bump` to discard following token after parsing closure parameter list, because it assumes `|` is following. However, the following code breaks the assumption: ```rust struct MyStruct; impl MyStruct { fn f() {|x, y} } ``` Here, the parameter list is `x, y` and the following token is `}`. The parser discards `}`, and then we have a curly bracket mismatch. Indeed, this code has a syntax error. On current nightly, the compiler emits an syntax error, but with incorrect message and span, followed by an ICE. ``` error: expected expression, found `}` --> 44021.rs:4:1 | 4 | } | ^ error: internal compiler error: unexpected panic ``` Even worse, on current stable(1.20.0), the compiler falls into an infinite loop. This pull request fixes this problem. Now the compiler emits correct error message and span, and does not ICE. ``` error: expected one of `:`, `@`, or `|`, found `}` --> 44021.rs:3:20 | 3 | fn foo() {|x, y} | ^ expected one of `:`, `@`, or `|` here ```
2017-09-10Rollup merge of #44262 - alexcrichton:repr-128-gate, r=nikomatsakisGuillaume Gomez-0/+3
rustc: Separately feature gate repr(i128) Brought up during the discussion of #35118, the support for this is still somewhat buggy and so stabilization likely wants to be considered independently of the type itself.
2017-09-09Stabilize drop_types_in_const.Eduard-Mihai Burtescu-3/+2
2017-09-08Auto merge of #43742 - epdtry:pprust-expr-fix, r=petrochenkovbors-66/+185
pprust: fix parenthesization of exprs The pretty printer in `syntax::print::pprust` currently relies on the presence of `ExprKind::Paren` hints in order to correctly parenthesize expressions in its output. If `Paren` nodes are missing, it sometimes produces wrong output, such as printing `1 - (2 - 3)` as `1 - 2 - 3`. This PR fixes `pprust` to correctly print expressions regardless of the presence or absence of `Paren` nodes. This should make `pprust` easier to use with programmatically constructed ASTs. A few notes: * I added a function for assigning precedence values to exprs in `syntax::util::parser`, since there is already code there for assigning precedence values to binops. Let me know if I should move this somewhere more `pprust`-specific. * I also moved the `contains_exterior_struct_lit` function from `rustc_lint::unused::UnusedParens` into `syntax::util::parser`, since it's needed for determining the correct parenthesization of `if`/`while` conditional expressions. * I couldn't find a good way to compare two exprs for equivalence while ignoring semantically-irrelevant details like spans. So the test for the new behavior relies on a slight hack: it adds `Paren` nodes everywhere, so that the pretty-printed version exactly reflects the structure of the AST, and then compares the printed strings. This works, but let me know if there's a better way.
2017-09-07pprust: increase precedence of block-like exprsStuart Pernsteiner-11/+9
2017-09-07Add visibility to span for macros 2.0topecongiro-5/+5
2017-09-06pprust: fix parenthesization of exprsStuart Pernsteiner-66/+187
2017-09-05Remove trailing white spaceZaki Manian-1/+1
2017-09-05Expect pipe symbol after closure parameter listsWonwoo Choi-1/+1
2017-09-03Minor documentation improvements for StmtKindZaki Manian-2/+2
2017-09-03implement improved on_unimplemented directivesAriel Ben-Yehuda-7/+18
2017-09-01rustc: Separately feature gate repr(i128)Alex Crichton-0/+3
Brought up during the discussion of #35118, the support for this is still somewhat buggy and so stabilization likely wants to be considered independently of the type itself.
2017-09-01Fix arm visitorMatt Ickstadt-0/+1
2017-09-01Implement RFC 1925Matt Ickstadt-2/+24
2017-08-31Auto merge of #43425 - matklad:lambda-restrictions, r=eddybbors-1/+4
Lambda expressions honor no struct literal restriction This is a fix for #43412 if we decide that it is indeed a bug :) closes #43412
2017-08-30Make fields of `Span` privateVadim Petrochenkov-164/+135
2017-08-29Auto merge of #44111 - zackmdavis:feature_attr_error_span, r=nikomatsakisbors-23/+23
feature error span on attribute for fn_must_use, SIMD/align reprs, macro reëxport There were several feature-gated attributes for which the feature-not-available error spans would point to the item annotated with the gated attribute, when it would make more sense for the span to point to the attribute itself: if the attribute is removed, the function/struct/_&c._ likely still makes sense and the program will compile. (Note that we decline to make the analogous change for the `main`, `start`, and `plugin_registrar` features, for in those cases it makes sense for the span to implicate the entire function, of which there is little hope of using without the gated attribute.) ![feature_attr_error_span](https://user-images.githubusercontent.com/1076988/29746531-fd700bfe-8a91-11e7-9c5b-6f5324083887.png)
2017-08-28feature error span on attr. for fn_must_use, SIMD/align, macro reëxportZack M. Davis-23/+23
There were several feature-gated attributes for which the feature-not-available error spans would point to the item annotated with the gated attribute, when it would make more sense for the span to point to the attribute itself: if the attribute is removed, the function/struct/&c. likely still makes sense and the program will compile. (Note that we decline to make the analogous change for the `main`, `start`, and `plugin_registrar` features, for in those cases it makes sense for the span to implicate the entire function, of which there is little hope of using without the gated attribute.)
2017-08-28Merge branch 'master' of https://github.com/rust-lang/rust into genJohn Kåre Alsaker-28/+75
2017-08-26Rollup merge of #43776 - zackmdavis:feature_gate_fn_must_use, r=alexcrichtonCorey Farwell-13/+70
feature-gate #[must_use] for functions as `fn_must_use` @eddyb I [was](https://github.com/rust-lang/rust/pull/43728#issuecomment-320854120) [dithering](https://github.com/rust-lang/rust/pull/43728#issuecomment-320856407) on this, but [your comment](https://github.com/rust-lang/rust/issues/43302#issuecomment-321174989) makes it sound like we do want a feature gate for this? Please advise. r? @eddyb
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-3/+0
Fixes #41701.
2017-08-25syntax: clarify field nameTamir Duberstein-10/+5
The value of this field is meant to indicate whether or not the crate is rustc's libtest itself - not whether or not it is a test crate generally.
2017-08-25syntax: remove unused fieldTamir Duberstein-2/+0
2017-08-25Merge remote-tracking branch 'origin/master' into genAlex Crichton-1/+45
2017-08-22fn_must_use soft feature-gate warning on methods too, not only functionsZack M. Davis-1/+11
This continues to be in the matter of #43302.
2017-08-22"soft" (warn instead of error) feature-gate for #[must_use] on functionsZack M. Davis-10/+50
Before `#[must_use]` for functions was implemented, a `#[must_use]` attribute on a function was a no-op. To avoid a breaking change in this behavior, we add an option for "this-and-such feature is experimental" feature-gate messages to be a mere warning rather than a compilation-halting failure (so old code that used to have a useless no-op `#[must_use]` attribute now warns rather than breaking). When we're on stable, we add a help note to clarify that the feature isn't "on." This is in support of #43302.
2017-08-22correct comment re feature-checking toolingZack M. Davis-2/+2
The featureck.py that this comment referred to was removed in 9dd3c54a (March 2016).
2017-08-22hard feature-gate for #[must_use] on functionsZack M. Davis-1/+8
We'll actually want a new "soft" warning-only gate to maintain backwards-compatibility, but it's cleaner to start out with the established, well-understood gate before implementing the alternative warn-only behavior in a later commit. This is in the matter of #43302.
2017-08-22Ensure that generic arguments don't end up in attribute paths.Jeffrey Seyfried-1/+7
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-24/+19
2017-08-22Auto merge of #43854 - estebank:missing-cond, r=nikomatsakisbors-0/+38
Point out missing if conditional On a case where an else conditional is missing, point this out instead of the token immediately after the (incorrect) else block: ``` error: missing condition for `if` statemementt push fork -f --> $DIR/issue-13483.rs:16:5 | 13 | } else if { | ^ expected if condition here ``` instead of ``` error: expected `{`, found `else` --> ../../src/test/ui/issue-13483.rs:14:7 | 14 | } else { | ^^^^ ``` Fix #13483.
2017-08-21Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakisbors-24/+19
syntax: Relax path grammar TLDR: Accept the disambiguator `::` in "type" paths (`Type::<Args>`), accept the disambiguator `::` before parenthesized generic arguments (`Fn::(Args)`). The "turbofish" disambiguator `::<>` in expression paths is a necessary evil required for path parsing to be both simple and to give reasonable results. Since paths in expressions usually refer to values (but not necessarily, e.g. `Struct::<u8> { field: 0 }` is disambiguated, but refers to a type), people often consider `::<>` to be inherent to *values*, and not *expressions* and want to write disambiguated paths for values even in contexts where disambiguation is not strictly necessary, for example when a path is passed to a macro `m!(Vec::<i32>::new)`. The problem is that currently, if the disambiguator is not *required*, then it's *prohibited*. This results in confusion - see https://github.com/rust-lang/rust/issues/41740, https://internals.rust-lang.org/t/macro-path-uses-novel-syntax/5561. This PR makes the disambiguator *optional* instead of prohibited in contexts where it's not strictly required, so people can pass paths to macros in whatever form they consider natural (e.g. disambiguated form for value paths). This PR also accepts the disambiguator in paths with parenthesized arguments (`Fn::(Args)`) for consistency and to simplify testing of stuff like https://github.com/rust-lang/rust/pull/41856#issuecomment-301219194. Closes https://github.com/rust-lang/rust/issues/41740 cc @rust-lang/lang r? @nikomatsakis
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-20/+13
2017-08-19Auto merge of #43933 - topecongiro:bad-span-for-attributes, r=petrochenkovbors-14/+9
Fix bad span for attributes Closes #42641.
2017-08-18Auto merge of #43904 - topecongiro:libsyntax/parse-attr, r=petrochenkovbors-6/+4
Eat open paren when parsing list in libsyntax/parse/attr.rs This PR adds a small refactoring: ```diff pub fn parse_meta_item_kind(&mut self) -> PResult<'a, ast::MetaItemKind> { Ok(if self.eat(&token::Eq) { ast::MetaItemKind::NameValue(self.parse_unsuffixed_lit()?) - } else if self.token == token::OpenDelim(token::Paren) { + } else if self.eat(&token::OpenDelim(token::Paren)) { ast::MetaItemKind::List(self.parse_meta_seq()?) } else { - self.eat(&token::OpenDelim(token::Paren)); ast::MetaItemKind::Word }) } ``` in `parse_meta_item_kind()`, the parser calls `self.eat(&token::OpenDelim(token::Paren));` before returning `ast::MetaItemKind::Word` just to add `(` to expected token. It seems more natural to eat the paren when parsing `ast::MetaItemKind::List`.
2017-08-17Verify that an `if` condition block returns a valueEsteban Küber-1/+32
2017-08-17Check for `else` keyword on missing `if` conditionEsteban Küber-16/+11
2017-08-17Merge remote-tracking branch 'origin/master' into genAlex Crichton-4/+3
2017-08-17Accept underscores in unicode escapesMalo Jaffré-47/+65
Fixes #43692.
2017-08-17Point out missing if conditionalEsteban Küber-4/+16
On a case where an else conditional is missing, point this out instead of the token immediately after the (incorrect) else block: ``` error: missing condition for `if` statemementt push fork -f --> $DIR/issue-13483.rs:16:5 | 13 | } else if { | ^ expected if condition here ``` instead of ``` error: expected `{`, found `else` --> ../../src/test/ui/issue-13483.rs:14:7 | 14 | } else { | ^^^^ ```
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-1/+1
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-17Include the closing paren to the span of ast::NestedMetaItemSeiichi Uchida-11/+6
2017-08-17Use respan()Seiichi Uchida-3/+3