about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2016-07-17Auto merge of #34789 - jonathandturner:simplify_liberror, r=alexcrichtonbors-2/+6
Simplify librustc_errors This is part 2 of the error crate refactor, starting with #34403. In this refactor, I focused on slimming down the error crate to fewer moving parts. As such, I've removed quite a few parts and replaced the with simpler, straight-line code. Specifically, this PR: * Removes BasicEmitter * Remove emit from emitter, leaving emit_struct * Renames emit_struct to emit * Removes CoreEmitter and focuses on a single Emitter * Implements the latest changes to error format RFC (#1644) * Removes (now-unused) code in emitter.rs and snippet.rs * Moves more tests to the UI tester, removing some duplicate tests in the process There is probably more that could be done with some additional refactoring, but this felt like it was getting to a good state. r? @alexcrichton cc: @Manishearth (as there may be breaking changes in stuff I removed/changed)
2016-07-15Auto merge of #34676 - aravind-pg:inner-attr, r=brsonbors-14/+56
Better error message for inner attribute following doc comment Before it was always just "an inner attribute is not permitted in this context", whereas now we add a special case for when an inner attr follows an outer attr. If the outer attr is a doc comment, then the error is "an inner attr is not permitted following a doc comment", and otherwise it's "an inner attr is not permitted following an outer attribute". In all other cases it's still "an inner attribute is not permitted in this context". Note that the public API and behaviour of `parse_attribute` is unchanged. Also, all new names are very open to bikeshedding -- they're arguably clunky. Fixes #34516. cc @brson
2016-07-15syntax: Better error message for inner attr following doc commentAravind Gollakota-14/+56
2016-07-15Added tokenstream parser procedurecgswords-1/+9
2016-07-15Auto merge of #34570 - jseyfried:no_rename, r=nrcbors-30/+0
Simplify the macro hygiene algorithm This PR removes renaming from the hygiene algorithm and treats differently marked identifiers as unequal. This change makes the scope of identifiers in `macro_rules!` items empty. That is, identifiers in `macro_rules!` definitions do not inherit any semantics from the `macro_rules!`'s scope. Since `macro_rules!` macros are items, the scope of their identifiers "should" be the same as that of other items; in particular, the scope should contain only items. Since all items are unhygienic today, this would mean the scope should be empty. However, the scope of an identifier in a `macro_rules!` statement today is the scope that the identifier would have if it replaced the `macro_rules!` (excluding anything unhygienic, i.e. locals only). To continue to support this, this PR tracks the scope of each `macro_rules!` and uses it in `resolve` to ensure that an identifier expanded from a `macro_rules!` gets a chance to resolve to the locals in the `macro_rules!`'s scope. This PR is a pure refactoring. After this PR, - `syntax::ext::expand` is much simpler. - We can expand macros in any order without causing problems for hygiene (needed for macro modularization). - We can deprecate or remove today's `macro_rules!` scope easily. - Expansion performance improves by 25%, post-expansion memory usage decreases by ~5%. - Expanding a block is no longer quadratic in the number of `let` statements (fixes #10607). r? @nrc
2016-07-14Remove BasicEmitterJonathan Turner-2/+6
2016-07-14Remove irrelevant testsJeffrey Seyfried-18/+0
2016-07-14Instead of renaming, treat differently marked identifiers as unequalJeffrey Seyfried-12/+0
2016-07-13Auto merge of #34772 - jseyfried:cleanup_interner, r=eddybbors-21/+20
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-11Factor the `RefCell` out of the `Interner`.Jeffrey Seyfried-6/+7
2016-07-11Refactor `get_ident_interner` -> `with_ident_interner`.Jeffrey Seyfried-12/+13
2016-07-11Remove `Interner<T>` and rename `StrInterner` to `Interner`.Jeffrey Seyfried-3/+3
2016-07-11Encapsulate `RcStr` in `syntax::util::interner`.Jeffrey Seyfried-6/+5
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-15/+17
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-17/+45
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-15/+17
(instead of by reference)" This reverts commit 5bf7970ac70b4e7781e7b2f3816720aa62fac6fd.
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-26/+16
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
2016-06-29Refactor away `parser.commit_stmt_expecting()`Jeffrey Seyfried-5/+1
2016-06-26Rollup merge of #34436 - jseyfried:no_block_expr, r=eddybJeffrey Seyfried-18/+10
To allow these braced macro invocation, this PR removes the optional expression from `ast::Block` and instead uses a `StmtKind::Expr` at the end of the statement list. Currently, braced macro invocations in blocks can expand into statements (and items) except when they are last in a block, in which case they can only expand into expressions. For example, ```rust macro_rules! make_stmt { () => { let x = 0; } } fn f() { make_stmt! {} //< This is OK... let x = 0; //< ... unless this line is commented out. } ``` Fixes #34418.
2016-06-26Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,ManishearthJeffrey Seyfried-88/+82
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-103/+110
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #33943 - jseyfried:libsyntax_cleanup, r=nrcJeffrey Seyfried-28/+26
Miscellaneous low priority cleanup in `libsyntax`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-14/+19
syntax-[breaking-change] cc #31645 (Only breaking because ast::TokenTree is now tokenstream::TokenTree.) This pull request refactors TokenTrees into their own file as src/libsyntax/tokenstream.rs, moving them out of src/libsyntax/ast.rs, in order to prepare for an accompanying TokenStream implementation (per RFC 1566).
2016-06-25Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichtonJeffrey Seyfried-45/+54
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
2016-06-25Rollup merge of #34368 - petrochenkov:astqpath, r=ManishearthJeffrey Seyfried-6/+1
The AST part of https://github.com/rust-lang/rust/pull/34365 plugin-[breaking-change] cc https://github.com/rust-lang/rust/issues/31645
2016-06-25Rollup merge of #34213 - josephDunne:trait_item_macros, r=jseyfriedJeffrey Seyfried-67/+91
**syntax-[breaking-change]** cc #31645 New `TraitItemKind::Macro` variant This change adds support for macro expansion inside trait items by adding the new `TraitItemKind::Macro` and associated parsing code.
2016-06-24Add `ecx.stmt_semi()` and fix issues with the pretty-printerJeffrey Seyfried-1/+0
2016-06-23make old school mode a bit more configurableJonathan Turner-1/+4
2016-06-23Remove field `expr` of `ast::Block`Jeffrey Seyfried-22/+8
2016-06-23Address more travis errorsJonathan Turner-2/+3
2016-06-23Address comments and fix travis warningJonathan Turner-2/+2
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-44/+49
2016-06-21Refactored tokentrees into their own files in preparation for tokenstreams. ↵cgswords-14/+19
Modified tests to point to the new file now.
2016-06-20Merge PatKind::QPath into PatKind::Path in ASTVadim Petrochenkov-6/+1
2016-06-19Generalize and abstract `ThinAttributes`Jeffrey Seyfried-88/+82
2016-06-17Rename `ast::ExprKind::Again` -> `ast::ExprKind::Continue`Jeffrey Seyfried-2/+2
2016-06-17Fix falloutJeffrey Seyfried-99/+106
2016-06-16Add an abs_path member to FileMap, use it when writing debug info.Ted Mielczarek-3/+3
When items are inlined from extern crates, the filename in the debug info is taken from the FileMap that's serialized in the rlib metadata. Currently this is just FileMap.name, which is whatever path is passed to rustc. Since libcore and libstd are built by invoking rustc with relative paths, they wind up with relative paths in the rlib, and when linked into a binary the debug info uses relative paths for the names, but since the compilation directory for the final binary, tools trying to read source filenames will wind up with bad paths. We noticed this in Firefox with source filenames from libcore/libstd having bad paths. This change stores an absolute path in FileMap.abs_path, and uses that if available for writing debug info. This is not going to magically make debuggers able to find the source, but it will at least provide sensible paths.
2016-06-15prefer `if let` to match with `None => ()` arm in some placesZack M. Davis-12/+9
Casual grepping revealed some places in the codebase (some of which antedated `if let`'s December 2014 stabilization in c200ae5a) where we were using a match with a `None => ()` arm where (in the present author's opinion) an `if let` conditional would be more readable. (Other places where matching to the unit value did seem to better express the intent were left alone.) It's likely that we don't care about making such trivial, non-functional, sheerly æsthetic changes. But if we do, this is a patch.
2016-06-14Remove the type parameter from `syntax::visit::Visitor`Jeffrey Seyfried-2/+2