about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-05-01auto merge of #13877 : thestinger/rust/de-tilde-str-vec, r=alexcrichtonbors-46/+29
2014-05-01auto merge of #13724 : nikomatsakis/rust/expr-use-visitor, r=pnkfelixbors-1/+24
Pre-step towards issue #12624 and others: Introduce ExprUseVisitor, remove the moves computation. ExprUseVisitor is a visitor that walks the AST for a function and calls a delegate to inform it where borrows, copies, and moves occur. In this patch, I rewrite the gather_loans visitor to use ExprUseVisitor, but in future patches, I think we could rewrite regionck, check_loans, and possibly other passes to use it as well. This would refactor the repeated code between those places that tries to determine where copies/moves/etc occur. r? @alexcrichton
2014-04-30librustc: Remove `~"string"` and `&"string"` from the languagePatrick Walton-46/+29
2014-04-28Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is ↵Jonathan S-2/+3
provided (everywhere but treemap) This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also deprecates related functions like rsplit, rev_components, and rev_str_components. In every case, these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this more concrete, a translation table for all functional changes necessary follows: * container.rev_iter() -> container.iter().rev() * container.mut_rev_iter() -> container.mut_iter().rev() * container.move_rev_iter() -> container.move_iter().rev() * sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev() * path.rev_components() -> path.components().rev() * path.rev_str_components() -> path.str_components().rev() In terms of the type system, this change also deprecates any specialized reversed iterator types (except in treemap), opting instead to use Rev directly if any type annotations are needed. However, since methods directly returning reversed iterators are now discouraged, the need for such annotations should be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in the original reversed name and surround it with Rev<>: * RevComponents<'a> -> Rev<Components<'a>> * RevStrComponents<'a> -> Rev<StrComponents<'a>> * RevItems<'a, T> -> Rev<Items<'a, T>> * etc. The reasoning behind this change is that it makes the standard API much simpler without reducing readability, performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries (all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft goes away. [breaking-change]
2014-04-28auto merge of #13812 : alxgnon/rust/master, r=alexcrichtonbors-8/+5
This is a quick fix for repeated documentation descriptions in certain modules. Following is a list of the faulty modules I found. I ran `pcregrep -r -M "<p>(.+)\n\1" doc` on the html documentation to help identify them. - [rustuv::uvio](http://static.rust-lang.org/doc/master/rustuv/uvio/index.html) - [rustuv::uvll](http://static.rust-lang.org/doc/master/rustuv/uvll/index.html) - [std::rt::backtrace](http://static.rust-lang.org/doc/master/std/rt/backtrace/index.html) - [std::rt::env](http://static.rust-lang.org/doc/master/std/rt/env/index.html) - [std::rt::global_heap](http://static.rust-lang.org/doc/master/std/rt/global_heap/index.html) - [std::rt::local_heap](http://static.rust-lang.org/doc/master/std/rt/local_heap/index.html) - [std::rt::rtio](http://static.rust-lang.org/doc/master/std/rt/rtio/index.html) - [std::rt::task](http://static.rust-lang.org/doc/master/std/rt/task/index.html) - [std::rt::thread](http://static.rust-lang.org/doc/master/std/rt/thread/index.html) - [std::rt::unwind](http://static.rust-lang.org/doc/master/std/rt/unwind/index.html) - [syntax::parse::classify](http://static.rust-lang.org/doc/master/syntax/parse/classify/index.html) - [syntax::parse::common](http://static.rust-lang.org/doc/master/syntax/parse/common/index.html) After a little testing, I discovered that moving the documentation inside (`//!`) instead of outside (`///`) modules fixed the immediate problem. I went through the trouble of moving the documentation, and with this commit there are no more repeated descriptions within those faulty modules. This does not fix the underlying problem though. We should look into why having the documentation outside instead of inside caused the descriptions to be repeated. I will create a separate issue with my findings on the subject if necessary. In the meantime, this simple fix should be enough.
2014-04-28auto merge of #13791 : lifthrasiir/rust/mod-inner-span, r=huonwbors-10/+31
This PR is primarily motivated by (and fixes) #12926. We currently only have a span for the individual item itself and not for the referred contents. This normally does not cause a problem since both are located in the same file; it *is* possible that the contained statement or item is located in the other file (the syntax extension can do that), but even in that case the syntax extension should be located in the same file as the item. The module item (i.e. `mod foo;`) is the only exception here, and thus warrants a special treatment. Rustdoc would now distinguish `mod foo;` from `mod foo {...}` by checking if the span for the module item and module contents is in different files. If it's the case, we'd prefer module contents over module item. There are alternative strategies, but as noted above we will have some corner cases if we don't record the contents span explicitly.
2014-04-27Fix repeated module documentationAlexandre Gagnon-8/+5
2014-04-27syntax: `Mod` records the span for inner contents.Kang Seonghoon-10/+31
this is useful when the module item and module contents are defined from different files (like rustdoc). in most cases the original span for the module item would be used; in other cases, the span for module contents is available separately at the `inner` field.
2014-04-26syntax: ViewItemUse no longer contains multiple view paths.Kang Seonghoon-89/+78
it reflected the obsolete syntax `use a, b, c;` and did not make past the parser (though it was a non-fatal error so we can continue). this legacy affected many portions of rustc and rustdoc as well, so this commit cleans them up altogether.
2014-04-24auto merge of #13671 : dcrewi/rust/lint-directives-on-use-items, r=alexcrichtonbors-2/+10
Fixes #10534
2014-04-24Pre-step towards issue #12624 and others: Introduce ExprUseVisitor, remove theNiko Matsakis-1/+24
moves computation. ExprUseVisitor is a visitor that walks the AST for a function and calls a delegate to inform it where borrows, copies, and moves occur. In this patch, I rewrite the gather_loans visitor to use ExprUseVisitor, but in future patches, I think we could rewrite regionck, check_loans, and possibly other passes to use it as well. This would refactor the repeated code between those places that tries to determine where copies/moves/etc occur.
2014-04-24auto merge of #13713 : edwardw/rust/methodcall-span, r=alexcrichtonbors-7/+14
Specifically, the method parameter cardinality mismatch or missing method error message span now gets method itself exactly. It was the whole expression. Closes #9390 Closes #13684 Closes #13709
2014-04-24auto merge of #13559 : FlaPer87/rust/remove-special-root, r=nikomatsakisbors-18/+18
This patch removes the special auto-rooting for `@` from the borrow checker. With `@` moving into a library, it doesn't make sense to keep this code around anymore. It also simplifies `trans` by removing root checking from there @nikomatsakis Closes: #11586
2014-04-23auto merge of #12812 : sfackler/rust/attr-arm, r=alexcrichtonbors-2/+18
This is really only useful for #[cfg()]. For example: ```rust enum Foo { Bar, Baz, #[cfg(blob)] Blob } fn match_foos(f: &Foo) { match *f { Bar => {} Baz => {} #[cfg(blob)] Blob => {} } } ``` This is a kind of weird place to allow attributes, so it should probably be discussed before merging.
2014-04-23Allow attributes on match armsSteven Fackler-2/+18
RFC: 0008-match-arm-attributes
2014-04-23auto merge of #13704 : edwardw/rust/doc-hidden, r=alexcrichtonbors-37/+52
Closes #13698
2014-04-24Calibrate span for method call error messagesEdward Wang-7/+14
Specifically, the method parameter cardinality mismatch or missing method error message span now gets method itself exactly. It was the whole expression. Closes #9390 Closes #13684 Closes #13709
2014-04-23auto merge of #13686 : alexcrichton/rust/issue-12224, r=nikomatsakisbors-19/+55
This alters the borrow checker's requirements on invoking closures from requiring an immutable borrow to requiring a unique immutable borrow. This means that it is illegal to invoke a closure through a `&` pointer because there is no guarantee that is not aliased. This does not mean that a closure is required to be in a mutable location, but rather a location which can be proven to be unique (often through a mutable pointer). For example, the following code is unsound and is no longer allowed: type Fn<'a> = ||:'a; fn call(f: |Fn|) { f(|| { f(|| {}) }); } fn main() { call(|a| { a(); }); } There is no replacement for this pattern. For all closures which are stored in structures, it was previously allowed to invoke the closure through `&self` but it now requires invocation through `&mut self`. The standard library has a good number of violations of this new rule, but the fixes will be separated into multiple breaking change commits. Closes #12224
2014-04-23Fix other bugs with new closure borrowingAlex Crichton-19/+55
This fixes various issues throughout the standard distribution and tests.
2014-04-23syntax: fix de-@rooting falloutFlavio Percoco-18/+18
2014-04-23Honor hidden doc attribute of derivable trait methodsEdward Wang-37/+52
Closes #13698
2014-04-22auto merge of #13398 : nick29581/rust/unsized-enum, r=nikomatsakisbors-22/+103
Now with proper checking of enums and allows unsized fields as the last field in a struct or variant. This PR only checks passing of unsized types and distinguishing them from sized ones. To be safe we also need to control storage. Closes issues #12969 and #13121, supersedes #13375 (all the discussion there is valid here too).
2014-04-23Review changesNick Cameron-1/+2
2014-04-22Apply lint attrs to individual "use" declarationsDavid Creswick-2/+10
Fixes #10534
2014-04-22add support for quadruple precision floating pointDaniel Micay-5/+12
This currently requires linking against a library like libquadmath (or libgcc), because compiler-rt barely has any support for this and most hardware does not yet have 128-bit precision floating point. For this reason, it's currently hidden behind a feature gate. When compiler-rt is updated to trunk, some tests can be added for constant evaluation since there will be support for the comparison operators. Closes #13381
2014-04-23Check for unsized types in enums.Nick Cameron-0/+7
And allow the last field of a struct or variant to be unsized.
2014-04-23Support unsized types with the `type` keywordNick Cameron-19/+85
2014-04-23Add a span to ast::TyParamNick Cameron-6/+13
2014-04-22rustc: de-@ middle::ty.Eduard Burtescu-0/+9
2014-04-21auto merge of #13435 : edwardw/rust/span, r=brsonbors-14/+23
When reporting "consider removing this semicolon" hint message, the offending semicolon may come from macro call site instead of macro itself. Using the more appropriate span makes the hint more helpful. Closes #13428.
2014-04-20Allow inheritance between structs.Nick Cameron-21/+73
No subtyping, no interaction with traits. Partially addresses #9912.
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-219/+220
2014-04-18Update the rest of the compiler with ~[T] changesAlex Crichton-3/+2
2014-04-18Use more precise span when reporting semicolon hintEdward Wang-14/+23
When reporting "consider removing this semicolon" hint message, the offending semicolon may come from macro call site instead of macro itself. Using the more appropriate span makes the hint more helpful. Closes #13428.
2014-04-17auto merge of #13576 : lifthrasiir/rust/double-ref, r=alexcrichtonbors-38/+54
Uses the same strategy as `||` and `>>`. Closes #11227.
2014-04-17Drive-by: `pprust::*_to_str` for TypeMethod, Method, and FnDecl.Felix S. Klock II-0/+12
2014-04-17Extended `syntax::{fold, ast_map}` to include lifetimes.Felix S. Klock II-33/+85
Part of this required added an override of `fold_type_method` in the Folder for Ctx impl; it follows the same pattern as `fold_method`. Also, as a drive-by fix, I moved all of the calls to `folder.new_id` in syntax::fold's no-op default traversal to really be the first statement in each function. * This is to uphold the invariant that `folder.new_id` is always called first (an unfortunate requirement of the current `ast_map` code), an invariant that we seemingly were breaking in e.g. the previous `noop_fold_block`. * Now it should be easier to see when adding new code that this invariant must be upheld. * (note that the breakage in `noop_fold_block` may not have mattered so much previously, since the only thing that blocks can bind are lifetimes, which I am only adding support for now.)
2014-04-17syntax: Parses `&&` as `& &` whenever appropriate.Kang Seonghoon-38/+54
Closes #11227.
2014-04-16auto merge of #13547 : alexcrichton/rust/remove-priv, r=huonwbors-53/+54
See [RFC 6](https://github.com/rust-lang/rfcs/blob/e0c741f1c6e372d0fd31c5978fcf8c7bd7c3e973/active/0006-remove-priv.md)
2014-04-16syntax: Demote `priv` to a reserved keywordAlex Crichton-18/+18
It is no longer used in rust anywhere. RFC: 0006-remove-priv
2014-04-16rustc: Remove private enum variantsAlex Crichton-10/+2
This removes the `priv` keyword from the language and removes private enum variants as a result. The remaining use cases of private enum variants were all updated to be a struct with one private field that is a private enum. RFC: 0006-remove-priv Closes #13535
2014-04-16auto merge of #13544 : klutzy/rust/pprust, r=alexcrichtonbors-11/+14
Fixes #12685
2014-04-16syntax: unify all MacResult's into a single trait.Huon Wilson-161/+232
There's now one unified way to return things from a macro, instead of being able to choose the `AnyMacro` trait or the `MRItem`/`MRExpr` variants of the `MacResult` enum. This does simplify the logic handling the expansions, but the biggest value of this is it makes macros in (for example) type position easier to implement, as there's this single thing to modify. By my measurements (using `-Z time-passes` on libstd and librustc etc.), this appears to have little-to-no impact on expansion speed. There are presumably larger costs than the small number of extra allocations and virtual calls this adds (notably, all `macro_rules!`-defined macros have not changed in behaviour, since they had to use the `AnyMacro` trait anyway).
2014-04-16pprust: Handle multi-stmt/no-expr `ExprFnBlock`klutzy-11/+14
Fixes #12685
2014-04-15Remove usage of private enum variantsAlex Crichton-25/+34
This replaces all uses of private enum variants with a struct that has one private field pointing at a private enum. RFC: 0006-remove-priv
2014-04-14auto merge of #13496 : alexcrichton/rust/issue-13495, r=sfacklerbors-5/+2
This bug was introduced in #13384 by accident, and this commit continues the work of #13384 by finishing support for loading a syntax extension crate without registering it with the local cstore. Closes #13495
2014-04-13rustc: Don't link in syntax extensionsAlex Crichton-5/+2
This bug was introduced in #13384 by accident, and this commit continues the work of #13384 by finishing support for loading a syntax extension crate without registering it with the local cstore. Closes #13495
2014-04-13auto merge of #13452 : Ryman/rust/fix_uint_as_u, r=alexcrichtonbors-24/+36
Fixes #13359.
2014-04-13libsyntax: update helper to stringify TyU* and TyI* to take into account ↵Kevin Butler-24/+36
having a value. Fixes #13359.
2014-04-11syntax: remove ast::Sigil.Eduard Burtescu-78/+52