Commit Graph

31778 Commits

Author SHA1 Message Date
Brian Anderson
4f5b6927e8 std: Rename various slice traits for consistency
ImmutableVector -> ImmutableSlice
ImmutableEqVector -> ImmutableEqSlice
ImmutableOrdVector -> ImmutableOrdSlice
MutableVector -> MutableSlice
MutableVectorAllocating -> MutableSliceAllocating
MutableCloneableVector -> MutableCloneableSlice
MutableOrdVector -> MutableOrdSlice

These are all in the prelude so most code will not break.

[breaking-change]
2014-08-13 11:30:14 -07:00
Felix S. Klock II
9434920b24 rustc lexer: regression tests for embedded Idents.
I chose to make two of them because I wanted something close to an
"end-to-end" test (*), but at the same time I wanted a test that
would run on Windows (**).

(*) The run-make test serves as the end-to-end: It constructs an input
that is trying to subvert the hack and we are going to check that it
fails in the attempt).

(**) The compile-fail-fulldeps test serves as a more narrow test that
will be tested on all platforms.  It also attempts to subvert the
hack, testing that when you use `new_parser_from_tts`, the resulting
parser does not support reading embedded Idents.
2014-08-13 17:41:35 +02:00
Felix S. Klock II
c3ce245ba6 quote_expr macro: embed Ident using special encoding that preserves hygiene.
This adds support to `quote_expr!` and friends for round-trip hygienic
preservation of Ident.

Here are the pieces of the puzzle:

* adding a method for encoding Ident for re-reading into token tree.

* Support for reading such encoded Idents in the lexer.  Note that one
  must peek ahead for MOD_SEP after scan_embedded_hygienic_ident.

* To ensure that encoded Idents are only read when we are in the midst
  of expanding a `quote_expr` or similar, added a
  `read_embedded_ident` flag on `StringReader`.

* pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-13 17:40:15 +02:00
Andreas Tolfsen
0edc55dc21 Guide: Add missing integer type to section on if expressions 2014-08-13 15:58:12 +01:00
bors
d917770792 auto merge of #16381 : pnkfelix/rust/fsk-rust.md-fixes, r=alexcrichton
rust.md: Explicitly point out how special `'static` is.

Drive-by: fix description of `&content` to point out that `&'f type` is (as of today) only for type expressions.
2014-08-13 14:16:27 +00:00
bors
9d554212de auto merge of #16421 : ipetkov/rust/cmd-fd-fix-retry, r=alexcrichton
Retry pull requesting of https://github.com/rust-lang/rust/pull/16407 after accidentally messing up rebasing of branches and making bors think the PR was merged
2014-08-13 05:56:20 +00:00
bors
6291781592 auto merge of #16460 : pcwalton/rust/borrowck-closure-issue, r=nikomatsakis
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]

r? @nikomatsakis
2014-08-13 04:11:22 +00:00
Liigo Zhuang
0186246afe libcore: rename private cmp macros
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-13 11:41:29 +08:00
bors
ee87234eed auto merge of #16458 : pcwalton/rust/borrowck-for-moves, r=nikomatsakis
`for` loop heads.

This breaks code like:

    let x = Some(box 1i);
    for &a in x.iter() {
    }

Change this code to obey the borrow checking rules. For example:

    let x = Some(box 1i);
    for &ref a in x.iter() {
    }

Closes #16205.

[breaking-change]

r? @nikomatsakis
2014-08-13 02:26:23 +00:00
Ivan Petkov
3fe0ba9afc libnative: process spawning should not close inherited file descriptors
* The caller should be responsible for cleaning up file descriptors
* If a caller safely creates a file descriptor (via
  native::io::file::open) the returned structure (FileDesc) will try to
  clean up the file, failing in the process and writing error messages
  to the screen.
* This should not happen as the caller has no public interface for
  telling the FileDesc structure to NOT free the underlying fd.
* Alternatively, if another file is opened under the same fd held by
  the FileDesc structure returned by native::io::file::open, it will
  close the wrong file upon destruction.
2014-08-12 19:09:18 -07:00
bors
e189122e9a auto merge of #16452 : epdtry/rust/unreachable-item-ice, r=pcwalton
This code produces an ICE:

```rust
#![crate_type = "rlib"]
fn main() {
    if true { return }
    // remaining code is unreachable
    match () {
        () => { static MAGIC: uint = 0; }
    }
}
```
([playpen](http://is.gd/iwOISB))

The error is "encode_symbol: id not found 18", where 18 is the `NodeId` of the declaration of `MAGIC`.  The problem is that `rustc` tries to emit metadata for `MAGIC`, but some of the information is missing because `MAGIC` never gets translated by `trans_item` - the entire body of the `match` gets skipped because the `match` itself is unreachable.

This branch simplifies the handling of inner items by always processing them using the `trans_item` visitor, instead of sometimes using the visitor and sometimes waiting until `trans_stmt` encounters the item.  This fixes the ICE by making the translation of the item no longer depend on the declaration being reachable code.  This branch also reverts #16059 and #16359, since the new change to item translation fixes the same problems as those but is simpler.
2014-08-13 00:41:22 +00:00
Stuart Pernsteiner
0f847ba74d more consistent handling of inner items 2014-08-12 16:14:27 -07:00
Stuart Pernsteiner
428d5ac5b9 Revert "avoid redundant translation of items during monomorphization"
This reverts commit f97f65f7b7.

Conflicts:
	src/librustc/middle/trans/base.rs
	src/librustc/middle/trans/foreign.rs
	src/librustc/middle/trans/monomorphize.rs
2014-08-12 16:14:27 -07:00
Stuart Pernsteiner
d5a94c4a88 Revert "don't translate items when monomorphizing foreign-ABI functions"
This reverts commit 0c158b4fbf.
2014-08-12 16:13:11 -07:00
Patrick Walton
7579185b4c librustc: Use the correct categorized mutable type for the pattern in
`for` loop heads.

This breaks code like:

    let x = Some(box 1i);
        for &a in x.iter() {
    }

Change this code to obey the borrow checking rules. For example:

    let x = Some(box 1i);
        for &ref a in x.iter() {
    }

Closes #16205.

[breaking-change]
2014-08-12 15:02:51 -07:00
bors
51c7e20d53 auto merge of #16433 : aturon/rust/deprecated-in-crate, r=alexcrichton
Previously the stability lint considered cross-crate items only. That's appropriate for unstable and experimental levels, but not for deprecation.

In addition to changing the lint, this PR takes care of the fallout: a number of deprecated items that were being used throughout libstd.

Closes #16409

Due to deny(deprecated), this is a:

[breaking-change]
2014-08-12 22:01:25 +00:00
Patrick Walton
f1799fdfca librustc: Record unique immutable borrows in the restrictions table.
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]
2014-08-12 14:30:05 -07:00
Aaron Turon
d7484b86fc Allow deprecation in deprecated libraries 2014-08-12 13:35:56 -07:00
Aaron Turon
ffd87daeed Deprecation fallout in libsync 2014-08-12 13:35:56 -07:00
Aaron Turon
f77cabecbb Deprecation fallout in libcollections 2014-08-12 13:35:56 -07:00
Aaron Turon
0b5204f55e Enable deprecation lint on crate-local items
Previously the lint considered cross-crate items only. That's
appropriate for unstable and experimental levels, but not for
deprecation.

Closes #16409

Due to deny(deprecation), this is a:

[breaking-change]
2014-08-12 13:07:12 -07:00
bors
4bb4a43917 auto merge of #16454 : pcwalton/rust/types-in-path-patterns, r=brson
patterns.

This breaks code like:

    fn main() {
        match Some("foo") {
            None::<int> => {}
            Some(_) => {}
        }
    }

Change this code to not contain a type error. For example:

    fn main() {
        match Some("foo") {
            None::<&str> => {}
            Some(_) => {}
        }
    }

Closes #16353.

[breaking-change]

r? @huonw
2014-08-12 20:06:30 +00:00
Steve Klabnik
ee3f07481f Guide: patterns.
Fixes #4417.
2014-08-12 15:33:01 -04:00
Philipp Gesang
061cdec5df
guide-unsafe.md: fix wording
Following a suggestion by Huon Wilson.
2014-08-12 21:30:02 +02:00
bors
e2273d9456 auto merge of #16081 : luqmana/rust/nr, r=pcwalton
Fixes #15763
2014-08-12 18:16:33 +00:00
Patrick Walton
857ba988f1 libsyntax: Don't strip types and lifetimes from single-segment paths in
patterns.

This breaks code like:

    fn main() {
        match Some("foo") {
            None::<int> => {}
            Some(_) => {}
        }
    }

Change this code to not contain a type error. For example:

    fn main() {
        match Some("foo") {
            None::<&str> => {}
            Some(_) => {}
        }
    }

Closes #16353.

[breaking-change]
2014-08-12 10:33:16 -07:00
Steve Klabnik
5eb4e1a659 ~ -> Box in the manual
Fixes #16439
2014-08-12 07:58:36 -04:00
bors
c7d0b5259d auto merge of #16434 : vadimcn/rust/many-crates-but-no-match, r=alexcrichton 2014-08-12 09:31:17 +00:00
bors
c1eaafe8ab auto merge of #16425 : nham/rust/fix_nan_format, r=alexcrichton
Currently, this:

    println!("{}", std::f64::NAN);

prints "-NaN". This commit is an attempt to change that to "NaN" instead.
2014-08-12 07:31:17 +00:00
Vadim Chugunov
1b2dc760af Replace "ignore-win32" in tests with "ignore-windows" 2014-08-12 00:14:00 -07:00
Bheesham Persaud
a43dadb204 Minor changes to rust.md, and guide-ffi.md.
* `rust.md`: whanges for consistency

  * `guide-ffi.md`: wrapped inline code
2014-08-12 03:13:50 -04:00
Vadim Chugunov
3dfd12967a Replace #[cfg(target_os = "win32")] with #[cfg(target_os = "windows")] 2014-08-12 00:13:43 -07:00
Vadim Chugunov
98332b1a06 Replace all references to "Win32" with "Windows".
For historical reasons, "Win32" has been used in Rust codebase to mean "Windows OS in general".
This is confusing, especially now, that Rust supports Win64 builds.

[breaking-change]
2014-08-12 00:10:26 -07:00
Philipp Gesang
2c7ef330fc
guide-unsafe.md: fix noun 2014-08-12 07:39:57 +02:00
Philipp Gesang
c2bf0ed4dd
guide-testing.md: add auxiliary verb 2014-08-12 07:39:56 +02:00
Philipp Gesang
b8f512d220
guide-runtime.md: remove redundant verb 2014-08-12 07:39:53 +02:00
bors
e8204a84c7 auto merge of #16195 : P1start/rust/more-index, r=aturon
Implement `Index` for `RingBuf`, `HashMap`, `TreeMap`, `SmallIntMap`, and `TrieMap`.

If there’s anything that I missed or should be removed, let me know.
2014-08-12 05:11:18 +00:00
Luqman Aden
71e19d5286 librustc: Don't use an alloca per return if the function doesn't have nested returns. 2014-08-11 21:53:54 -07:00
P1start
8f71cb06bc Implement Index for TrieMap 2014-08-12 15:33:05 +12:00
P1start
11b8f9c3f6 Implement Index for SmallIntMap
This also deprecates SmallIntMap::get. Use indexing instead.
2014-08-12 15:33:05 +12:00
P1start
2dd6bc6887 Implement Index for TreeMap 2014-08-12 15:33:05 +12:00
P1start
32f5898bea Implement Index for HashMap
This also deprecates HashMap::get. Use indexing instead.
2014-08-12 15:33:05 +12:00
P1start
fd10d209cd Implement Index for RingBuf
This also deprecates RingBuf::get. Use indexing instead.
2014-08-12 15:32:56 +12:00
bors
49a970f244 auto merge of #16284 : alexcrichton/rust/issue-16272, r=aturon
There was a bug in both libnative and libuv which prevented child processes from
being spawned correctly on windows when one of the arguments was an empty
string. The libuv bug has since been fixed upstream, and the libnative bug was
fixed as part of this commit.

When updating libuv, this also includes a fix for #15149.

Closes #15149
Closes #16272
2014-08-12 03:31:20 +00:00
nham
04233a1675 Change std::fmt::{Float,LowerExp,UpperExp} to not print '-NaN' for f32::NAN and f64::NAN 2014-08-11 22:24:01 -04:00
Luqman Aden
0ad97c042a librustc: Don't use Load/Store for structural values. 2014-08-11 19:20:11 -07:00
Luqman Aden
5aedcb1e91 librustc: Don't allow return_address intrinsic in functions that don't use an out pointer. 2014-08-11 19:20:10 -07:00
Patrick Walton
9dac85f92d librustc: Add an intrinsic to retrieve the return pointer of a function.
This is needed for some GC stuff in Servo.
2014-08-11 19:20:10 -07:00
Luqman Aden
d302813888 Reenable ignored test and add run-pass test. 2014-08-11 19:20:10 -07:00
Luqman Aden
68cbd6c929 librustc: Use separate stack slot for each return. 2014-08-11 19:20:10 -07:00