summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-05-21rustc: improve error messages from wrong --pretty flowgraph use.Huon Wilson-4/+10
This defers to .fatal and .span_fatal for errors (rather than `fail!` which prints the ICE message). It also adds the span lookup when an id doesn't correspond to a block, to show what it is pointing at. It also makes the argument parser slightly looser, so that passing `--pretty flowgraph` recognises the `flowgraph` part and suggests to use an integer.
2014-05-20Change std inject attributes to outer attributesKevin Ballard-2/+16
The #[phase(syntax,link)] attribute on `extern crate std` needs to be an outer attribute so it can pretty-print properly. Also add `#![no_std]` and `#[feature(phase)]` so compiling the pretty-printed source will work.
2014-05-20syntax: Parse global paths in patternsAlex Crichton-1/+1
Closes #6449
2014-05-19Reset the terminal color before the newline for diagnosticsKevin Ballard-2/+21
When printing colored diagnostics, we need to reset the terminal before emitting the newline, not after. Otherwise it gets line-buffered and the color won't reset until the next line is printed or the compiler exits. Normally this isn't a problem, but when running rustc in parallel with other processes (e.g. `make -j4`) this can cause the color to leak to other lines.
2014-05-19auto merge of #14251 : alexcrichton/rust/hierarchy, r=huonwbors-7/+52
This is an implementation of RFC 16. A module can now only be loaded if the module declaring `mod name;` "owns" the current directory. A module is considered as owning its directory if it meets one of the following criteria: * It is the top-level crate file * It is a `mod.rs` file * It was loaded via `#[path]` * It was loaded via `include!` * The module was declared via an inline `mod foo { ... }` statement For example, this directory structure is now invalid // lib.rs mod foo; // foo.rs mod bar; // bar.rs; fn bar() {} With this change `foo.rs` must be renamed to `foo/mod.rs`, and `bar.rs` must be renamed to `foo/bar.rs`. This makes it clear that `bar` is a submodule of `foo`, and can only be accessed through `foo`. RFC: 0016-module-file-system-hierarchy Closes #14180 [breaking-change]
2014-05-18auto merge of #14000 : pnkfelix/rust/fsk-fix-issue13732, r=alexcrichtonbors-0/+3
Fix #13732. This is a revised, much less hacky form of PR #13753 The changes here: * add instrumentation to aid debugging of linkage errors, * fine tune some things in the Makefile where we are telling binaries to use a host-oriented path for finding dynamic libraries, when it should be feeding the binaries a target-oriented path for dynamic libraries. * pass along the current stage number to run-make tests, and * skip certain tests when running atop stage1. Fix #13746 as well.
2014-05-18Output debug info on how `#[phase] extern crate foo;` gets resolved.Felix S. Klock II-0/+3
2014-05-18Make bytes!() return 'staticKevin Ballard-6/+27
Change `bytes!()` to return { static BYTES: &'static [u8] = &[...]; BYTES } This gives it the `'static` lifetime, whereas before it had an rvalue lifetime. Until recently this would have prevented assigning `bytes!()` to a static, as in static FOO: &'static [u8] = bytes!(1,2,3); but #14183 fixed it so blocks are now allowed in constant expressions (with restrictions). Fixes #11641.
2014-05-17syntax: Tighten search paths for inner modulesAlex Crichton-7/+52
This is an implementation of RFC 16. A module can now only be loaded if the module declaring `mod name;` "owns" the current directory. A module is considered as owning its directory if it meets one of the following criteria: * It is the top-level crate file * It is a `mod.rs` file * It was loaded via `#[path]` * It was loaded via `include!` * The module was declared via an inline `mod foo { ... }` statement For example, this directory structure is now invalid // lib.rs mod foo; // foo.rs mod bar; // bar.rs; fn bar() {} With this change `foo.rs` must be renamed to `foo/mod.rs`, and `bar.rs` must be renamed to `foo/bar.rs`. This makes it clear that `bar` is a submodule of `foo`, and can only be accessed through `foo`. RFC: 0016-module-file-system-hierarchy Closes #14180 [breaking-change]
2014-05-16auto merge of #14233 : pcwalton/rust/detildestr-morelibs, r=alexcrichtonbors-3/+6
r? @alexcrichton
2014-05-16libserialize: Remove all uses of `~str` from `libserialize`.Patrick Walton-2/+3
Had to make `struct Tm` in `libtime` not serializable for now.
2014-05-16libfmt_macros: Remove all uses of `~str` from `libfmt_macros`Patrick Walton-1/+3
2014-05-16Update for BoxCorey Richardson-1/+1
2014-05-16syntax: update for libterm falloutCorey Richardson-4/+4
2014-05-15Updates with core::fmt changesAlex Crichton-9/+9
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-15syntax: Add a macro, format_args_method!()Alex Crichton-29/+62
Currently, the format_args!() macro takes as its first argument an expression which is the callee of an ExprCall. This means that if format_args!() is used with calling a method a closure must be used. Consider this code, however: format_args!(|args| { foo.writer.write_fmt(args) }, "{}", foo.field) The closure borrows the entire `foo` structure, disallowing the later borrow of `foo.field`. To preserve the semantics of the `write!` macro, it is also impossible to borrow specifically the `writer` field of the `foo` structure because it must be borrowed mutably, but the `foo` structure is not guaranteed to be mutable itself. This new macro is invoked like: format_args_method!(foo.writer, write_fmt, "{}", foo.field) This macro will generate an ExprMethodCall which allows the borrow checker to understand that `writer` and `field` should be borrowed separately. This macro is not strictly necessary, with DST or possibly UFCS other workarounds could be used. For now, though, it looks like this is required to implement the `write!` macro.
2014-05-15auto merge of #14234 : alexcrichton/rust/rollup, r=alexcrichtonbors-1/+11
Let's try this again!
2014-05-15Add `EntryPat` and `NodePat` variants to ast_map.Felix S. Klock II-1/+11
Add `EntryPat` and `NodePat` variants to ast_map, so that lookups for id 1 in `let S{val: _x /* pat 2 */} /* pat 1 */ = ...` will actually resolve to the pattern `S{ ... }`, rather than "unknown node", in a function like `node_id_to_str`.
2014-05-15auto merge of #14040 : hannobraun/rust/force-color-output, r=alexcrichtonbors-6/+20
This pull request fixes #12881. Two caveats: 1. As explained in the commit message, this doesn't include a regression test. If this is unacceptable, please let me know, I'll see what I can do. 1. I'm getting some test failures on make check, all from debuginfo. I suspect this is due to #13680 and not related to my changes (I have GDB 7.7). This is the list of failed tests: > [debuginfo-gdb] debuginfo/basic-types-globals.rs > [debuginfo-gdb] debuginfo/basic-types-mut-globals.rs > [debuginfo-gdb] debuginfo/basic-types.rs > [debuginfo-gdb] debuginfo/borrowed-basic.rs > [debuginfo-gdb] debuginfo/borrowed-managed-basic.rs > [debuginfo-gdb] debuginfo/borrowed-struct.rs > [debuginfo-gdb] debuginfo/borrowed-unique-basic.rs > [debuginfo-gdb] debuginfo/box.rs > [debuginfo-gdb] debuginfo/by-value-non-immediate-argument.rs > [debuginfo-gdb] debuginfo/by-value-self-argument-in-trait-impl.rs > [debuginfo-gdb] debuginfo/closure-in-generic-function.rs > [debuginfo-gdb] debuginfo/evec-in-struct.rs > [debuginfo-gdb] debuginfo/function-arg-initialization.rs > [debuginfo-gdb] debuginfo/function-prologue-stepping-no-split-stack.rs > [debuginfo-gdb] debuginfo/generic-function.rs > [debuginfo-gdb] debuginfo/generic-functions-nested.rs > [debuginfo-gdb] debuginfo/generic-method-on-generic-struct.rs > [debuginfo-gdb] debuginfo/generic-static-method-on-struct-and-enum.rs > [debuginfo-gdb] debuginfo/generic-struct.rs > [debuginfo-gdb] debuginfo/lexical-scope-in-stack-closure.rs > [debuginfo-gdb] debuginfo/lexical-scope-in-unique-closure.rs > [debuginfo-gdb] debuginfo/method-on-generic-struct.rs > [debuginfo-gdb] debuginfo/method-on-tuple-struct.rs > [debuginfo-gdb] debuginfo/name-shadowing-and-scope-nesting.rs > [debuginfo-gdb] debuginfo/recursive-struct.rs > [debuginfo-gdb] debuginfo/self-in-generic-default-method.rs > [debuginfo-gdb] debuginfo/shadowed-argument.rs > [debuginfo-gdb] debuginfo/shadowed-variable.rs > [debuginfo-gdb] debuginfo/simd.rs > [debuginfo-gdb] debuginfo/simple-lexical-scope.rs > [debuginfo-gdb] debuginfo/simple-struct.rs > [debuginfo-gdb] debuginfo/simple-tuple.rs > [debuginfo-gdb] debuginfo/static-method-on-struct-and-enum.rs > [debuginfo-gdb] debuginfo/tuple-struct.rs > [debuginfo-gdb] debuginfo/var-captured-in-nested-closure.rs > [debuginfo-gdb] debuginfo/var-captured-in-sendable-closure.rs > [debuginfo-gdb] debuginfo/var-captured-in-stack-closure.rs I can provide the full output on request.
2014-05-15Add compiler flag to configure output coloringHanno Braun-6/+20
This adds the flag --color, which allows the user to force coloring or turn it off. The default behavior stays the same as before (colorize, if output goes to tty). Why this is beneficial is explained in issue #12881. Please note that this commit doesn't include any regression tests. I thought about how I'd write a test for this and it doesn't seem to be worth the effort to me for a UI change like this. Fixes #12881.
2014-05-15syntax::visit: pub `walk_explicit_self` so impls can call it as defaults do.Felix S. Klock II-3/+13
drive-by: added some doc.
2014-05-14Removed unnecessary arguments for walk_* functionsMichael Darakananda-12/+7
2014-05-13syntax: Improve --pretty normal slightlyAlex Crichton-2/+8
When printing doc comments, always put a newline after them in a macro invocation to ensure that a line-doc-comment doesn't consume remaining tokens on the line.
2014-05-13syntax: Preserve attributes in #[deriving]Alex Crichton-11/+25
Now that the #[deriving] attribute is removed, the raw_pointers_deriving lint was broken. This commit restores the lint by preserving lint attributes across #[deriving] to the implementations and using #[automatically_derived] as the trigger for activating the lint.
2014-05-13syntax: Print suffixed token literals correctlyAlex Crichton-0/+3
Previously, literals "1i" were printed as "1". This fixes the numeric-method-autoexport test for pretty printing.
2014-05-13syntax: Fix parsing << with closure typesAlex Crichton-6/+54
This uses the trick of replacing the << token with a < token to parse closure types correctly. Closes #13324
2014-05-13syntax: Fix printing INT64_MINAlex Crichton-12/+29
Integers are always parsed as a u64 in libsyntax, but they're stored as i64. The parser and pretty printer both printed an i64 instead of u64, sometimes introducing an extra negative sign.
2014-05-13Touch up and rebase previous commitsAlex Crichton-29/+13
* Added `// no-pretty-expanded` to pretty-print a test, but not run it through the `expanded` variant. * Removed #[deriving] and other expanded attributes after they are expanded * Removed hacks around &str and &&str and friends (from both the parser and the pretty printer). * Un-ignored a bunch of tests
2014-05-13libsyntax: Workaround pprust `for` issueklutzy-1/+1
2014-05-13pprust: Remove unnecessary && of `print_tt`klutzy-4/+4
2014-05-13pprust: Print `&&e` instead of `& &e`klutzy-5/+0
2014-05-13pprust: Fix asm outputklutzy-14/+19
2014-05-13pprust: Add parentheses to some Exprklutzy-3/+45
Some `Expr` needs parentheses when printed. For example, without parentheses, `ExprUnary(UnNeg, ExprBinary(BiAdd, ..))` becomes `-lhs + rhs` which is wrong. Those cases don't appear in ordinary code (since parentheses are explicitly added) but they can appear in manually crafted ast by extensions.
2014-05-12Cleanup some ugly variable names, now that we have `let`-hygiene.Paul Stansifer-14/+14
2014-05-12Add some long-overdue documentation on the INTERPOLATED helper macros.Paul Stansifer-1/+6
2014-05-12Add the patch number to version strings. Closes #13289Brian Anderson-1/+1
2014-05-11core: Remove the cast moduleAlex Crichton-14/+14
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-09Register new snapshotsAlex Crichton-8/+2
2014-05-08auto merge of #13985 : alexcrichton/rust/libfmt, r=brsonbors-16/+7
This code does not belong in libstd, and rather belongs in a dedicated crate. In the future, the syntax::ext::format module should move to the fmt_macros crate (hence the name of the crate), but for now the fmt_macros crate will only contain the format string parser. The entire fmt_macros crate is marked #[experimental] because it is not meant for general consumption, only the format!() interface is officially supported, not the internals. This is a breaking change for anyone using the internals of std::fmt::parse. Some of the flags have moved to std::fmt::rt, while the actual parsing support has all moved to the fmt_macros library. [breaking-change]
2014-05-08std: Extract format string parsing out of libstdAlex Crichton-16/+7
This code does not belong in libstd, and rather belongs in a dedicated crate. In the future, the syntax::ext::format module should move to the fmt_macros crate (hence the name of the crate), but for now the fmt_macros crate will only contain the format string parser. The entire fmt_macros crate is marked #[experimental] because it is not meant for general consumption, only the format!() interface is officially supported, not the internals. This is a breaking change for anyone using the internals of std::fmt::parse. Some of the flags have moved to std::fmt::rt, while the actual parsing support has all moved to the fmt_macros library. [breaking-change]
2014-05-08libsyntax: Remove uses of `~str` from libsyntax, and fix falloutPatrick Walton-555/+670
2014-05-08auto merge of #13835 : alexcrichton/rust/localdata, r=brsonbors-27/+19
This commit brings the local_data api up to modern rust standards with a few key improvements: * All functionality is now exposed as a method on the keys themselves. Instead of importing std::local_data, you now use "key.set()" and "key.get()". * All closures have been removed in favor of RAII functionality. This means that get() and get_mut() no long require closures, but rather return Option<SmartPointer> where the smart pointer takes care of relinquishing the borrow and also implements the necessary Deref traits * The modify() function was removed to cut the local_data interface down to its bare essentials (similarly to how RefCell removed set/get). [breaking-change]
2014-05-07std: Modernize the local_data apiAlex Crichton-27/+19
This commit brings the local_data api up to modern rust standards with a few key improvements: * The `pop` and `set` methods have been combined into one method, `replace` * The `get_mut` method has been removed. All interior mutability should be done through `RefCell`. * All functionality is now exposed as a method on the keys themselves. Instead of importing std::local_data, you now use "key.replace()" and "key.get()". * All closures have been removed in favor of RAII functionality. This means that get() and get_mut() no long require closures, but rather return Option<SmartPointer> where the smart pointer takes care of relinquishing the borrow and also implements the necessary Deref traits * The modify() function was removed to cut the local_data interface down to its bare essentials (similarly to how RefCell removed set/get). [breaking-change]
2014-05-07auto merge of #14005 : alexcrichton/rust/extern-unsafe, r=pcwaltonbors-24/+25
Previously, the parser would not allow you to simultaneously implement a function with a different abi as well as being unsafe at the same time. This extends the parser to allow functions of the form: unsafe extern fn foo() { // ... } The closure type grammar was also changed to reflect this reversal, types previously written as "extern unsafe fn()" must now be written as "unsafe extern fn()". The parser currently has a hack which allows the old style, but this will go away once a snapshot has landed. Closes #10025 [breaking-change]
2014-05-07core: Inherit possible string functionalityAlex Crichton-5/+0
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-07auto merge of #13958 : pcwalton/rust/detilde, r=pcwaltonbors-83/+124
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. r? @brson or @alexcrichton or whoever
2014-05-07auto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brsonbors-6/+2
Lots of assorted things here and there, all the details are in the commits. Closes #11712
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-83/+124
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-06rustc: Enable writing "unsafe extern fn() {}"Alex Crichton-24/+25
Previously, the parser would not allow you to simultaneously implement a function with a different abi as well as being unsafe at the same time. This extends the parser to allow functions of the form: unsafe extern fn foo() { // ... } The closure type grammar was also changed to reflect this reversal, types previously written as "extern unsafe fn()" must now be written as "unsafe extern fn()". The parser currently has a hack which allows the old style, but this will go away once a snapshot has landed. Closes #10025 [breaking-change]
2014-05-05auto merge of #13936 : Armavica/rust/lint_check-range, r=kballardbors-1/+1
Some cases were not correctly handled by this lint, for instance `let a = 42u8; a < 0` and `let a = 42u8; a > 255`. It led to the discovery of two useless comparisons, which I removed.