about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2013-10-16path2: Update based on more review feedbackKevin Ballard-2/+2
Standardize the is_sep() functions to be the same in both posix and windows, and re-export from path. Update extra::glob to use this. Remove the usage of either, as it's going away. Move the WindowsPath-specific methods out of WindowsPath and make them top-level functions of path::windows instead. This way you cannot accidentally write code that will fail to compile on non-windows architectures without typing ::windows anywhere. Remove GenericPath::from_c_str() and just impl BytesContainer for CString instead. Remove .join_path() and .push_path() and just implement BytesContainer for Path instead. Remove FilenameDisplay and add a boolean flag to Display instead. Remove .each_parent(). It only had one caller, so just inline its definition there.
2013-10-15path2: Remove .with_display_str and friendsKevin Ballard-2/+2
Rewrite these methods as methods on Display and FilenameDisplay. This turns do path.with_display_str |s| { ... } into do path.display().with_str |s| { ... }
2013-10-15path2: Adjust the API to remove all the _str mutation methodsKevin Ballard-9/+9
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
2013-10-15path2: Replace the path module outrightKevin Ballard-29/+27
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.
2013-10-14Remove unused abi attributes.Steve Klabnik-1/+0
They've been replaced by putting the name on the extern block. #[abi = "foo"] goes to extern "foo" { } Closes #9483.
2013-10-10Remove named extern blocks from the ASTAlex Crichton-31/+6
There's currently a fair amount of code which is being ignored on unnamed blocks (which are the default now), and I opted to leave it commented out for now. I intend on very soon revisiting on how we perform linking with extern crates in an effort to support static linking.
2013-10-09auto merge of #9783 : huonw/rust/macro-items, r=bstriebors-2/+5
Fixes #4471.
2013-10-10syntax: allow macros to expand to items with attributes.Huon Wilson-2/+5
Fixes #4471.
2013-10-09option: rewrite the API to use compositionDaniel Micay-34/+34
2013-10-08auto merge of #9753 : alexcrichton/rust/macro-attrs, r=brsonbors-3/+0
It's unclear to me why these currently aren't allowed, and my best guess is that a long time ago we didn't strip the ast of cfg nodes before syntax expansion. Now that this is done, I'm not certain that we should continue to prohibit this functionality. This is a step in the right direction towards #5605, because now we can add an empty `std::macros` module to the documentation with a bunch of empty macros explaining how they're supposed to be used.
2013-10-08Allow attributes on macrosAlex Crichton-3/+0
It's unclear to me why these currently aren't allowed, and my best guess is that a long time ago we didn't strip the ast of cfg nodes before syntax expansion. Now that this is done, I'm not certain that we should continue to prohibit this functionality. This is a step in the right direction towards #5605, because now we can add an empty `std::macros` module to the documentation with a bunch of empty macros explaining how they're supposed to be used.
2013-10-08auto merge of #9771 : alexcrichton/rust/snapshots, r=thestingerbors-19/+0
Still building locally, we'll see if anything dies...
2013-10-08Register new snapshotsAlex Crichton-19/+0
2013-10-08auto merge of #9756 : catamorphism/rust/issue-2354, r=alexcrichtonbors-1/+11
r? anybody It's more helpful to list the span of each open delimiter seen so far than to print out an error with the span of the last position in the file. Closes #2354
2013-10-08Add bindings for start and ends of keyword ranges; use bindings in match arms.Felix S. Klock II-11/+40
2013-10-07auto merge of #9674 : ben0x539/rust/raw-str, r=alexcrichtonbors-57/+160
This branch parses raw string literals as in #9411.
2013-10-08add new enum ast::StrStyle as field to ast::lit_strBenjamin Herr-55/+74
For the benefit of the pretty printer we want to keep track of how string literals in the ast were originally represented in the source code. This commit changes parser functions so they don't extract strings from the token stream without at least also returning what style of string literal it was. This is stored in the resulting ast node for string literals, obviously, for the package id in `extern mod = r"package id"` view items, for the inline asm in `asm!()` invocations. For `asm!()`'s other arguments or for `extern "Rust" fn()` items, I just the style of string, because it seemed disproportionally cumbersome to thread that information through the string processing that happens with those string literals, given the limited advantage raw string literals would provide in these positions. The other syntax extensions don't seem to store passed string literals in the ast, so they also discard the style of strings they parse.
2013-10-07syntax: Remove unnecessary @Tim Chevalier-3/+3
2013-10-07syntax: Display spans for open delimiters when a file ends prematurelyTim Chevalier-1/+11
It's more helpful to list the span of each open delimiter seen so far than to print out an error with the span of the last position in the file. Closes #2354
2013-10-08add token::LIT_STR_RAW(ident, num of # symbols)Benjamin Herr-5/+23
Treat it as a synonym for LIT_STR for now.
2013-10-08lex raw string literals, like r#"blah"#Benjamin Herr-2/+66
Raw string literals are lexed into regular string literals. This is okay for them to "work" and be usable/testable, but the pretty-printer does not know about them yet and will just emit regular string literals.
2013-10-08pp: print spaces around '=' in 'extern mod blah = "blah"'Benjamin Herr-0/+2
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-3/+5
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-10-07Extract privacy checking from name resolutionAlex Crichton-26/+0
This commit is the culmination of my recent effort to refine Rust's notion of privacy and visibility among crates. The major goals of this commit were to remove privacy checking from resolve for the sake of sane error messages, and to attempt a much more rigid and well-tested implementation of visibility throughout rust. The implemented rules for name visibility are: 1. Everything pub from the root namespace is visible to anyone 2. You may access any private item of your ancestors. "Accessing a private item" depends on what the item is, so for a function this means that you can call it, but for a module it means that you can look inside of it. Once you look inside a private module, any accessed item must be "pub from the root" where the new root is the private module that you looked into. These rules required some more analysis results to get propagated from trans to privacy in the form of a few hash tables. I added a new test in which my goal was to showcase all of the privacy nuances of the language, and I hope to place any new bugs into this file to prevent regressions. Overall, I was unable to completely remove the notion of privacy from resolve. One use of privacy is for dealing with glob imports. Essentially a glob import can only import *public* items from the destination, and because this must be done at namespace resolution time, resolve must maintain the notion of "what items are public in a module". There are some sad approximations of privacy, but I unfortunately can't see clear methods to extract them outside. The other use case of privacy in resolve now is one that must stick around regardless of glob imports. When dealing with privacy, checking a private path needs to know "what the last private thing was" when looking at a path. Resolve is the only compiler pass which knows the answer to this question, so it maintains the answer on a per-path resolution basis (works similarly to the def_map generated). Closes #8215
2013-10-05Implement feature-gating for the compilerAlex Crichton-0/+2
A few features are now hidden behind various #[feature(...)] directives. These include struct-like enum variants, glob imports, and macro_rules! invocations. Closes #9304 Closes #9305 Closes #9306 Closes #9331
2013-10-05auto merge of #9250 : erickt/rust/num, r=ericktbors-2/+166
This PR solves one of the pain points with c-style enums. Simplifies writing a fn to convert from an int/uint to an enum. It does this through a `#[deriving(FromPrimitive)]` syntax extension. Before this is committed though, we need to discuss if `ToPrimitive`/`FromPrimitive` has the right design (cc #4819). I've changed all the `.to_int()` and `from_int()` style functions to return `Option<int>` so we can handle partial functions. For this PR though only enums and `extra::num::bigint::*` take advantage of returning None for unrepresentable values. In the long run it'd be better if `i64.to_i8()` returned `None` if the value was too large, but I'll save this for a future PR. Closes #3868.
2013-10-04Remove specific errors for very old obsolete syntaxBenjamin Herr-455/+59
Replaces existing tests for removed obsolete-syntax errors with tests for the resulting regular errors, adds a test for each of the removed parser errors to make sure that obsolete forms don't start working again, removes some obsolete/superfluous tests that were now failing. Deletes some amount of dead code in the parser, also includes some small changes to parser error messages to accomodate new tests.
2013-10-03Rewrite lint passes with less visitor cruftAlex Crichton-23/+17
This purges about 500 lines of visitor cruft from lint passes. All lints are handled in a much more sane way at this point. The other huge bonus of this commit is that there are no more @-boxes in the lint passes, fixing the 500MB memory regression seen when the lint passes were refactored. Closes #8589
2013-10-02std: Swap {To,From}Primitive to use the 64bit as the unimplemented versionErick Tryzelaar-6/+6
One downside with this current implementation is that since BigInt's default is now 64 bit, we can convert larger BigInt's to a primitive, however the current implementation on 32 bit architectures does not take advantage of this fact.
2013-10-02syntax: swap from .span_fatal to .span_err in #[deriving(FromPrimitive)]Erick Tryzelaar-9/+21
2013-10-02syntax: Add #[deriving(FromPrimitive)] syntax extensionErick Tryzelaar-0/+152
Right now this only works for c-style enums.
2013-10-02auto merge of #9673 : huonw/rust/macros, r=catamorphismbors-78/+30
That is, only a single expression or item gets parsed, so if there are any extra tokens (e.g. the start of another item/expression) the user should be told, rather than silently dropping them. An example: macro_rules! foo { () => { println("hi"); println("bye); } } would expand to just `println("hi")`, which is almost certainly not what the programmer wanted. Fixes #8012.
2013-10-02auto merge of #9665 : alexcrichton/rust/snapshot, r=brsonbors-9/+16
Uses the new snapshots to kill the old `loop` and introduce the new `continue`.
2013-10-02syntax: indicate an error when a macro ignores trailing tokens.Huon Wilson-5/+30
That is, only a single expression or item gets parsed, so if there are any extra tokens (e.g. the start of another item/expression) the user should be told, rather than silently dropping them. An example: macro_rules! foo { () => { println("hi"); println("bye); } } would expand to just `println("hi")`, which is almost certainly not what the programmer wanted. Fixes #8012.
2013-10-02syntax: remove some dead code.Huon Wilson-73/+0
2013-10-01Migrate users of 'loop' to 'continue'Alex Crichton-9/+9
Closes #9467
2013-10-01Obsolete parsing 'loop' as 'continue'Alex Crichton-0/+7
2013-10-01auto merge of #9560 : pcwalton/rust/xc-tuple-structs, r=pcwaltonbors-2/+13
r? @thestinger
2013-10-01librustc: Inline cross-crate tuple struct constructorsPatrick Walton-2/+13
2013-10-01auto merge of #9519 : thestinger/rust/float, r=catamorphismbors-9/+2
It is simply defined as `f64` across every platform right now. A use case hasn't been presented for a `float` type defined as the highest precision floating point type implemented in hardware on the platform. Performance-wise, using the smallest precision correct for the use case greatly saves on cache space and allows for fitting more numbers into SSE/AVX registers. If there was a use case, this could be implemented as simply a type alias or a struct thanks to `#[cfg(...)]`. Closes #6592 The mailing list thread, for reference: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01remove the `float` typeDaniel Micay-9/+2
It is simply defined as `f64` across every platform right now. A use case hasn't been presented for a `float` type defined as the highest precision floating point type implemented in hardware on the platform. Performance-wise, using the smallest precision correct for the use case greatly saves on cache space and allows for fitting more numbers into SSE/AVX registers. If there was a use case, this could be implemented as simply a type alias or a struct thanks to `#[cfg(...)]`. Closes #6592 The mailing list thread, for reference: https://mail.mozilla.org/pipermail/rust-dev/2013-July/004632.html
2013-10-01auto merge of #9633 : alexcrichton/rust/issue-9631, r=huonwbors-12/+16
Closes #9631
2013-10-01Fix usage of the old debug! macrosAlex Crichton-1/+1
2013-10-01Change the format! statics to be all-capsAlex Crichton-12/+16
This lets them get past the non_uppercase_statics lint mode (if it's turned on) Closes #9631
2013-10-01Fix typo with format migration: s/oldformat/oldfmt/.Huon Wilson-4/+4
2013-09-30syntax: Remove usage of fmt!Alex Crichton-340/+340
2013-09-30Prevent leakage of fmt! into the compilerAlex Crichton-49/+62
We're not outright removing fmt! just yet, but this prevents it from leaking into the compiler further (it's still turned on by default for all other code).
2013-09-30Expand tidy to prevent binaries from being checkedAlex Crichton-0/+0
Closes #9621
2013-09-29Remove all usage of @ast::CrateAlex Crichton-20/+20
2013-09-27auto merge of #9552 : brson/rust/0.9-pre, r=alexcrichtonbors-1/+1