about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2016-09-23Fix indents.Jeffrey Seyfried-141/+131
2016-09-23Cleanup.Jeffrey Seyfried-40/+17
2016-09-23Parse paths in item, trait item, and impl item macro invocations.Jeffrey Seyfried-21/+6
2016-09-23Parse paths in statement and pattern macro invocations.Jeffrey Seyfried-31/+46
2016-09-23reviewer comments and rebasingNick Cameron-7/+20
2016-09-22Refactor out `parse_struct_expr`.Jeffrey Seyfried-45/+48
2016-09-18Auto merge of #36527 - nnethercote:last_token_kind, r=jseyfriedbors-43/+39
Optimize the parser's last token handling. The parser currently makes a heap copy of the last token in four cases: identifiers, paths, doc comments, and commas. The identifier and interpolation cases are unused, and for doc comments and commas we only need to record their presence, not their value. This commit consolidates the last token handling and avoids the unnecessary copies by replacing `last_token`, `last_token_eof`, and `last_token_interpolated` with a new field `last_token_kind`. This simplifies the parser slightly and speeds up parsing on some files by 3--4%.
2016-09-17Auto merge of #36502 - TimNN:correct-cancel, r=jseyfriedbors-5/+11
correctly cancel some errors Fixes #36499. I also (proactively) changed all other calls in `parser.rs` to use `Handler::cancel`.
2016-09-16Auto merge of #36482 - jseyfried:dont_load_unconfigured_noninline_modules, r=nrcbors-9/+18
Avoid loading and parsing unconfigured non-inline modules. For example, `#[cfg(any())] mod foo;` will always compile after this PR, even if `foo.rs` and `foo/mod.rs` do not exist or do not contain valid Rust. Fixes #36478 and fixes #27873. r? @nrc
2016-09-16Optimize the parser's last token handling.Nicholas Nethercote-43/+39
The parser currently makes a heap copy of the last token in four cases: identifiers, paths, doc comments, and commas. The identifier and interpolation cases are unused, and for doc comments and commas we only need to record their presence, not their value. This commit consolidates the last token handling and avoids the unnecessary copies by replacing `last_token`, `last_token_eof`, and `last_token_interpolated` with a new field `last_token_kind`. This simplifies the parser slightly and speeds up parsing on some files by 3--4%.
2016-09-15correctly cancel some errorsTim Neumann-5/+11
2016-09-15Avoid loading and parsing unconfigured non-inline modules.Jeffrey Seyfried-9/+18
2016-09-13Remove parsing of obsolete pre-1.0 syntaxesVadim Petrochenkov-32/+1
2016-09-05In `Parser` and `ExtCtxt`, replace fields `filename` and `mod_path_stack`Jeffrey Seyfried-26/+16
with a single field `directory: PathBuf`.
2016-09-03Check fields in union patters/expressionsVadim Petrochenkov-1/+3
Make parsing of union items backward compatible Add some tests
2016-09-03Lower unions from AST to HIR and from HIR to typesVadim Petrochenkov-0/+31
Parse union items and add a feature for them
2016-08-28Rollup merge of #35480 - KiChjang:e0379-bonus, r=nikomatsakisJeffrey Seyfried-9/+24
Move E0379 check from typeck to ast validation Part of #35233. Extension of #35338, #35364. Fixes #35404.
2016-08-28Rollup merge of #35618 - jseyfried:ast_view_path_refactor, r=eddybJeffrey Seyfried-6/+9
Refactor `PathListItem`s This refactors away variant `Mod` of `ast::PathListItemKind` and refactors the remaining variant `Ident` to a struct `ast::PathListItem_`.
2016-08-28Rollup merge of #35591 - GuillaumeGomez:generics_span, r=jntrmrJeffrey Seyfried-3/+5
Add Span field for Generics structs
2016-08-27Change Constness to Spanned<Constness>Keith Yeung-9/+24
2016-08-23Improve error message when failing to parse a blockJames Miller-3/+24
We want to catch this error: ``` if (foo) bar; ``` as it's valid syntax in other languages, and say how to fix it. Unfortunately it didn't care if the suggestion made sense and just highlighted the unexpected token. Now it attempts to parse a statement, and if it succeeds, it shows the help message. Fixes #35907
2016-08-21Refactor away variant `ast::PathListItemKind::Mod`Jeffrey Seyfried-6/+9
and refactor `ast::PathListItemKind::Ident` -> `ast::PathListItem_`.
2016-08-19Auto merge of #33922 - estebank:doc-comment, r=alexcrichtonbors-16/+36
Specific error message for missplaced doc comments Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-08-18Add Span field for Generics structsGuillaume Gomez-3/+5
2016-08-16Auto merge of #35162 - canndrew:bang_type_coerced, r=nikomatsakisbors-5/+3
Implement the `!` type This implements the never type (`!`) and hides it behind the feature gate `#[feature(never_type)]`. With the feature gate off, things should build as normal (although some error messages may be different). With the gate on, `!` is usable as a type and diverging type variables (ie. types that are unconstrained by anything in the code) will default to `!` instead of `()`.
2016-08-14Rollup merge of #35491 - sanxiyn:pub-restricted-span, r=nikomatsakisEduard-Mihai Burtescu-9/+10
Correct span for pub_restricted field Fix #35435.
2016-08-13Rename empty/bang to neverAndrew Cann-1/+1
Split Ty::is_empty method into is_never and is_uninhabited
2016-08-13Switch on TyEmptyAndrew Cann-5/+1
Parse -> ! as FnConverging(!) Add AdjustEmptyToAny coercion to all ! expressions Some fixes
2016-08-13Parse `!` as TyEmpty (except in fn return type)Andrew Cann-0/+2
2016-08-13Parse numeric fields in struct expressions and patternsVadim Petrochenkov-2/+11
2016-08-12Correct span for pub_restricted fieldSeo Sanghyeon-9/+10
2016-08-12syntax: add anonymized type syntax, i.e. impl TraitA+TraitB.Eduard Burtescu-1/+20
2016-07-23Auto merge of #34925 - jseyfried:nested_macros, r=eddybbors-1/+5
Support nested `macro_rules!` Fixes #6994. r? @eddyb
2016-07-19Support nested `macro_rules!`.Jeffrey Seyfried-1/+5
2016-07-17macros: Fix bug in statement matchersJeffrey Seyfried-49/+31
2016-07-13Auto merge of #34772 - jseyfried:cleanup_interner, r=eddybbors-2/+0
Start cleaning up the string interner r? @eddyb
2016-07-13Start a best-effort warning cycle.Jeffrey Seyfried-5/+36
2016-07-13cleanup: Refactor parser method `finish_parsing_statement` -> `parse_full_stmt`.Jeffrey Seyfried-6/+12
2016-07-13Allow macro-expanded macros in trailing expression positions to expand into ↵Jeffrey Seyfried-1/+2
statements: ```rust macro_rules! m { () => { let x = 1; x } } macro_rules! n { () => { m!() //< This can now expand into statements }} fn main() { n!(); } ``` and revert needless fallout fixes.
2016-07-12Parse macro-expanded statements like ordinary statements.Jeffrey Seyfried-2/+2
2016-07-12Clean up statement parsing without changing the semantics of `parse_stmt`.Jeffrey Seyfried-104/+45
2016-07-11Remove unused field `interner` from the parser.Jeffrey Seyfried-2/+0
2016-07-08Rollup merge of #34691 - jseyfried:remove_erroneous_unit_struct_checks, r=nrcManish Goregaokar-72/+11
parser: Remove outdated checks for empty braced struct expressions (`S {}`) This is a pure refactoring. r? @nrc
2016-07-06Auto merge of #34652 - jseyfried:fix_expansion_perf, r=nrcbors-8/+9
Fix expansion performance regression **syntax-[breaking-change] cc #31645** This fixes #34630 by reverting commit 5bf7970 of PR #33943, which landed in #34424. By removing the `Rc<_>` wrapping around `Delimited` and `SequenceRepetition` in `TokenTree`, 5bf7970 made cloning `TokenTree`s more expensive. While this had no measurable performance impact on the compiler's crates, it caused an order of magnitude performance regression on some macro-heavy code in the wild. I believe this is due to clones of `TokenTree`s in `macro_parser.rs` and/or `macro_rules.rs`. r? @nrc
2016-07-06Remove outdated checks for empty braced struct expressions (i.e. `UnitStruct ↵Jeffrey Seyfried-72/+11
{}`).
2016-07-06Auto merge of #34546 - jseyfried:cfg_attr_path, r=nrcbors-2/+9
Support `cfg_attr` on `path` attributes Fixes #25544. This is technically a [breaking-change]. For example, the following would break: ```rust mod foo; // Suppose `foo.rs` existed in the appropriate location ```
2016-07-05Specific error message for missplaced doc commentsEsteban Küber-16/+36
Identify when documetation comments have been missplaced in the following places: * After a struct element: ```rust // file.rs: struct X { a: u8 /** document a */, } ``` ```bash $ rustc file.rs file.rs:2:11: 2:28 error: found documentation comment that doesn't document anything file.rs:2 a: u8 /** document a */, ^~~~~~~~~~~~~~~~~ file.rs:2:11: 2:28 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a struct: ```rust // file.rs: struct X { a: u8, /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` * As the last line of a `fn`: ```rust // file.rs: fn main() { let x = 1; /// incorrect documentation } ``` ```bash $ rustc file.rs file.rs:3:5: 3:27 error: found a documentation comment that doesn't document anything file.rs:3 /// incorrect documentation ^~~~~~~~~~~~~~~~~~~~~~ file.rs:3:5: 3:27 help: doc comments must come before what they document, maybe a comment was intended with `//`? ``` Fix #27429, #30322
2016-07-04Revert "Change `fold_tt` and `fold_tts` to take token trees by value ↵Jeffrey Seyfried-8/+9
(instead of by reference)" This reverts commit 5bf7970ac70b4e7781e7b2f3816720aa62fac6fd.
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-12/+8
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-29Support `cfg_attr` on `path` attributesJeffrey Seyfried-2/+9