summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2015-05-17Allow #[derive()] to generate unsafe methodsManish Goregaokar-1/+23
2015-05-17Auto merge of #25387 - eddyb:syn-file-loader, r=nikomatsakisbors-106/+107
This allows compiling entire crates from memory or preprocessing source files before they are tokenized. Minor API refactoring included, which is a [breaking-change] for libsyntax users: * `ParseSess::{next_node_id, reserve_node_ids}` moved to rustc's `Session` * `new_parse_sess` -> `ParseSess::new` * `new_parse_sess_special_handler` -> `ParseSess::with_span_handler` * `mk_span_handler` -> `SpanHandler::new` * `default_handler` -> `Handler::new` * `mk_handler` -> `Handler::with_emitter` * `string_to_filemap(sess source, path)` -> `sess.codemap().new_filemap(path, source)`
2015-05-16Auto merge of #25462 - alexcrichton:favicon-https, r=nrcbors-1/+1
Helps prevent mixed content warnings if accessing docs over HTTPS. Closes #25459
2015-05-16Auto merge of #25444 - nikomatsakis:macro-tt-fix, r=pnkfelixbors-34/+78
Permit token trees, identifiers, and blocks to be following by sequences. Fixes #25436. r? @pnkfelix
2015-05-16Auto merge of #25487 - P1start:extern-crate-unexpected-error, r=huonwbors-5/+1
Closes #25468.
2015-05-16Clarify the error message for malformed `extern crate` statementsP1start-5/+1
Closes #25468.
2015-05-16Fix the spans of `move` closuresP1start-4/+5
Closes #24986.
2015-05-15libs: Move favicon URLs to HTTPSAlex Crichton-1/+1
Helps prevent mixed content warnings if accessing docs over HTTPS. Closes #25459
2015-05-15Permit token trees, identifiers, and blocks to be following byNiko Matsakis-34/+78
sequences. Fixes #25436.
2015-05-15Auto merge of #25219 - Eljay:fix-comment-parsing, r=alexcrichtonbors-24/+39
Fixes #25182, parser didn't account for \r\n in regular comments, only doc-comments.
2015-05-15syntax: Unquoting some statements requires trailing semicolonsErick Tryzelaar-3/+11
2015-05-15syntax: Add unquoting ast::{Generics,WhereClause}Erick Tryzelaar-13/+38
2015-05-15syntax: Allow pretty printing more interpolated itemsErick Tryzelaar-13/+13
2015-05-14Fix stupid mistake from previous commitLee Jeffery-2/+5
2015-05-14Make BytePos calculation same as originalLee Jeffery-1/+2
2015-05-14syntax: abstract over the file loading mechanism.Eduard Burtescu-15/+58
2015-05-14syntax::parse: optimize file_to_filemap to read a string directly.Eduard Burtescu-21/+7
2015-05-14syntax: replace sess.span_diagnostic.cm with sess.codemap().Eduard Burtescu-18/+12
2015-05-14syntax: refactor (Span)Handler and ParseSess constructors to be methods.Eduard Burtescu-44/+41
2015-05-14Move tracking of the next NodeId from syntax's ParseSess to rustc's Session.Eduard Burtescu-20/+1
2015-05-13Added test to check that newlines are stripped from commentsLee Jeffery-0/+9
2015-05-13Fix byte offset and error message inconsistenciesLee Jeffery-3/+3
2015-05-13make diagnostic message clearer when called from cargoMathieu Rochette-1/+1
2015-05-13Auto merge of #25318 - nrc:for-expn, r=sfacklerbors-14/+52
r? @sfackler
2015-05-13address more review commentsManish Goregaokar-1/+6
2015-05-13Merge branch 'master' into mulit-decorNick Cameron-47/+27
2015-05-12Auto merge of #25171 - quantheory:associated_time_long_paths, r=nikomatsakisbors-35/+15
It is currently broken to use syntax such as `<T as Foo>::U::static_method()` where `<T as Foo>::U` is an associated type. I was able to fix this and simplify the parser a bit at the same time. This also fixes the corresponding issue with associated types (#22139), but that's somewhat irrelevant because #22519 is still open, so this syntax still causes an error in type checking. Similarly, although this fix applies to associated consts, #25046 forbids associated constants from using type parameters or `Self`, while #19559 means that associated types have to always have one of those two. Therefore, I think that you can't use an associated const from an associated type anyway.
2015-05-12RebasingNick Cameron-17/+17
2015-05-12Merge branch 'master' intoNick Cameron-65/+110
2015-05-12Proper spans for for loop expansionNick Cameron-14/+52
2015-05-11Auto merge of #25085 - carols10cents:remove-old-tilde, r=steveklabnikbors-12/+12
There were still some mentions of `~[T]` and `~T`, mostly in comments and debugging statements. I tried to do my best to preserve meaning, but I might have gotten some wrong-- I'm happy to fix anything :)
2015-05-09Rollup merge of #25216 - barosl:no-more-task, r=ManishearthManish Goregaokar-9/+9
I've found that there are still huge amounts of occurrences of `task`s in the documentation. This PR tries to eliminate all of them in favor of `thread`.
2015-05-09address fallout in libsyntaxtest.Felix S. Klock II-1/+5
2015-05-08Fix CRLF line-ending parsing for comments.Lee Jeffery-24/+26
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-9/+9
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-05-08Fallout from fixing Issue 25199.Felix S. Klock II-3/+4
There are two interesting kinds of breakage illustrated here: 1. `Box<Trait>` in many contexts is treated as `Box<Trait + 'static>`, due to [RFC 599]. However, in a type like `&'a Box<Trait>`, the `Box<Trait>` type will be expanded to `Box<Trait + 'a>`, again due to [RFC 599]. This, combined with the fix to Issue 25199, leads to a borrowck problem due the combination of this function signature (in src/libstd/net/parser.rs): ```rust fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T>>]) -> Option<T>; ``` with this call site (again in src/libstd/net/parser.rs): ```rust fn read_ip_addr(&mut self) -> Option<IpAddr> { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4)); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6)); self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) } ``` yielding borrowck errors like: ``` parser.rs:265:27: 265:69 error: borrowed value does not live long enough parser.rs:265 self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` (full log at: https://gist.github.com/pnkfelix/e2e80f1a71580f5d3103 ) The issue here is perhaps subtle: the `parsers` argument is inferred to be taking a slice of boxed objects with the implicit lifetime bound attached to the `self` parameter to `read_or`. Meanwhile, the fix to Issue 25199 (added in a forth-coming commit) is forcing us to assume that each boxed object may have a destructor that could refer to state of that lifetime, and *therefore* that inferred lifetime is required to outlive the boxed object itself. In this case, the relevant boxed object here is not going to make any such references; I believe it is just an artifact of how the expression was built that it is not assigned type: `Box<FnMut(&mut Parser) -> Option<T> + 'static>`. (i.e., mucking with the expression is probably one way to fix this problem). But the other way to fix it, adopted here, is to change the `read_or` method type to force make the (presumably-intended) `'static` bound explicit on the boxed `FnMut` object. (Note: this is still just the *first* example of breakage.) 2. In `macro_rules.rs`, the `TTMacroExpander` trait defines a method with signature: ```rust fn expand<'cx>(&self, cx: &'cx mut ExtCtxt, ...) -> Box<MacResult+'cx>; ``` taking a `&'cx mut ExtCtxt` as an argument and returning a `Box<MacResult'cx>`. The fix to Issue 25199 (added in aforementioned forth-coming commit) assumes that a value of type `Box<MacResult+'cx>` may, in its destructor, refer to a reference of lifetime `'cx`; thus the `'cx` lifetime is forced to outlive the returned value. Meanwhile, within `expand.rs`, the old code was doing: ```rust match expander.expand(fld.cx, ...).make_pat() { ... => immutable borrow of fld.cx ... } ``` The problem is that the `'cx` lifetime, inferred for the `expander.expand` call, has now been extended so that it has to outlive the temporary R-value returned by `expanded.expand`. But call is also reborrowing `fld.cx` *mutably*, which means that this reborrow must end before any immutable borrow of `fld.cx`; but there is one of those within the match body. (Note that the temporary R-values for the input expression to `match` all live as long as the whole `match` expression itself (see Issue #3511 and PR #11585). To address this, I moved the construction of the pat value into its own `let`-statement, so that the `Box<MacResult>` will only live for as long as the initializing expression for the `let`-statement, and thus allow the subsequent immutable borrow within the `match`. [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-07Auto merge of #25013 - pnkfelix:span_to_lines-oflo, r=huonwbors-8/+45
Guard against overflow in `codemap::span_to_lines`. (Revised/expanded version of PR #24976) Make `span_to_lines` to return a `Result`. In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is *not* its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up. ---- As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
2015-05-07Add support for registering attributes with rustc in pluginsManish Goregaokar-13/+26
This lets plugin authors opt attributes out of the `custom_attribute` and `unused_attribute` checks.
2015-05-07Fix use of UFCS syntax to call methods on associated types.Sean Patrick Santos-35/+15
2015-05-05Use `empty()` instead of a special constTamir Duberstein-3/+2
2015-05-05Guard against overflow in `codemap::span_to_lines`.Felix S. Klock II-8/+45
Make `span_to_lines` to return a `Result`. (This is better than just asserting internally, since it allows caller to decide if they can recover from the problem.) Added type alias for `FileLinesResult` returned by `span_to_lines`. Update embedded unit test to reflect `span_to_lines` signature change. In diagnostic, catch `Err` from `span_to_lines` and print `"(internal compiler error: unprintable span)"` instead. ---- There a number of recent issues that report the bug here. See e.g. #24761 and #24954. This change *might* fix them. However, that is not its main goal. The main goals are: 1. Make it possible for callers to recover from an error here, and 2. Insert a more conservative check, in that we are also checking that the files match up.
2015-05-05Rollup merge of #25100 - jbcrail:fix-spelling-errors, r=steveklabnikManish Goregaokar-1/+1
I corrected several spelling errors in the external documentation.
2015-05-04Fix spelling errors in documentation.Joseph Crail-1/+1
2015-05-04Correct pretty-printing of `type Foo<T> where T: Bound = ...;`Felix S. Klock II-1/+1
Fix #25031
2015-05-03Update old uses of ~ in comments and debugging statementsCarol Nichols-12/+12
2015-05-02Auto merge of #25027 - Manishearth:deriving_attr, r=huonwbors-31/+38
Adds an `attrs` field to `FieldInfo` which lets one check the attributes on a field whilst expanding. This lets deriving plugins be more robust, for example providing the ability to "ignore" a field for the purpose of deriving, or perhaps handle the field a different way. r? @huonw
2015-05-02Rename AstBuilder::expr_int -> AstBuilder::expr_isizeManish Goregaokar-5/+8
2015-05-02Auto merge of #25028 - bluss:drain-string, r=alexcrichtonbors-8/+5
collections: Implement String::drain(range) according to RFC 574 `.drain(range)` is unstable and under feature(collections_drain). This adds a safe way to remove any range of a String as efficiently as possible. As noted in the code, this drain iterator has none of the memory safety issues of the vector version. RFC tracking issue is #23055
2015-05-01syntax: Avoid reallocating or copying in CodeMap::new_filemapUlrik Sverdrup-8/+5
Avoid creating a new String when there is no BOM to strip, and otherwises use .drain(..3) to strip the BOM using the same allocation.
2015-05-01Rollup merge of #24981 - carols10cents:remove-more-priv, r=alexcrichtonManish Goregaokar-1/+1
Hi! While researching stuff for the reference and the grammar, I came across a few mentions of using the `priv` keyword that was removed in 0.11.0 (#13547, #8122, rust-lang/rfcs#26, [RFC 0026](https://github.com/rust-lang/rfcs/blob/master/text/0026-remove-priv.md)). One occurrence is a mention in the reference, a few are in comments, and a few are marking test functions. I left the test that makes sure you can't name an ident `priv` since it's still a reserved keyword. I did a little grepping around for `priv `, priv in backticks, `Private` etc and I think the remaining instances are fine, but if anyone knows anywhere in particular I should check for any other lingering mentions of `priv`, please let me know and I would be happy to! :fallen_leaf: :ocean: