about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2016-08-19Auto merge of #33922 - estebank:doc-comment, r=alexcrichtonbors-17/+45
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-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-08-07Fix old call in lexer testsJonathan Turner-3/+1
2016-08-07Turn on new errors, json mode. Remove duplicate unicode testJonathan Turner-1/+0
2016-08-01Reimplemented tokenstreams as ropes and reduced the exposed TokenStream API.cgswords-1/+1
2016-07-23Auto merge of #34925 - jseyfried:nested_macros, r=eddybbors-1/+5
Support nested `macro_rules!` Fixes #6994. r? @eddyb
2016-07-19Introduced `NoDelim` and modified the compiler to support it.cgswords-0/+2
2016-07-19Support nested `macro_rules!`.Jeffrey Seyfried-1/+5
2016-07-18Auto merge of #34886 - jseyfried:improve_stmt_matchers, r=eddybbors-49/+31
macros: fix bug in `stmt` matchers Today, `stmt` matchers stop too early when parsing expression statements that begin with non-braced macro invocations. For example, ```rust fn main() { macro_rules! m { ($s:stmt;) => { $s } } id!(vec![].push(0);); //^ Before this PR, the `stmt` matcher only consumes "vec![]", so this is an error. //| After this PR, the `stmt` matcher consumes "vec![].push(0)", so this compiles. } ``` This change is backwards compatible due to the follow set for `stmt`. r? @eddyb
2016-07-17Auto merge of #34860 - jseyfried:encapsulate_hygiene, r=nrcbors-5/+0
Clean up and encapsulate `syntax::ext::mtwt`, rename `mtwt` to `hygiene` r? @nrc
2016-07-17Clean up and encapsulate `syntax::ext::mtwt`Jeffrey Seyfried-5/+0
2016-07-17macros: Fix bug in statement matchersJeffrey Seyfried-49/+31
2016-07-17Auto merge of #34829 - cgswords:tstream, r=nrcbors-1/+9
Added tokenstream parser procedure A tiny PR that simply adds a procedure for parsing `TokenStream`s to the parser in `src/libsyntax`. This is to ease using `TokenStream`s with the current (old) procedural macro system.
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>`.