]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoMove stability pass after privacy pass
Manish Goregaokar [Tue, 3 Feb 2015 15:46:08 +0000 (21:16 +0530)]
Move stability pass after privacy pass

9 years agoUpdate for new snapshot after rebasing.
Niko Matsakis [Tue, 3 Feb 2015 18:14:36 +0000 (13:14 -0500)]
Update for new snapshot after rebasing.

9 years agoCorrect one case where the inference was detecting a looser result than the
Niko Matsakis [Tue, 3 Feb 2015 18:14:29 +0000 (13:14 -0500)]
Correct one case where the inference was detecting a looser result than the
explicit annotation, leading to "extra `mut` declaration" lint errors.

9 years agoRemove the explicit closure kind syntax from the parser and AST;
Niko Matsakis [Tue, 3 Feb 2015 16:34:05 +0000 (11:34 -0500)]
Remove the explicit closure kind syntax from the parser and AST;
upgrade the inference based on expected type so that it is able to
infer the fn kind in isolation even if the full signature is not
available (and we could perhaps do better still in some cases, such as
extracting just the types of the arguments but not the return value).

9 years agoUpdate compile-fail tests to use the expected type to force the
Niko Matsakis [Tue, 3 Feb 2015 16:32:26 +0000 (11:32 -0500)]
Update compile-fail tests to use the expected type to force the
closure kind, thereby detecting what happens if there are
mismatches. Simply removing the `:` annotations caused most of these
tests to pass or produce other errors, because the inference would
convert the closure into a more appropriate kind. (The ability to
override the inference by using the expected type is an important
backdoor partly for this reason.)

9 years agoTeach project to unify the return type even if a precise match is not
Niko Matsakis [Tue, 3 Feb 2015 11:12:43 +0000 (06:12 -0500)]
Teach project to unify the return type even if a precise match is not
possible.  There is some amount of duplication as a result (similar to
select) -- I am not happy about this but not sure how to fix it
without deeper rewrites.

9 years agoAllow closure arguments types to unify even if we can't fully resolve
Niko Matsakis [Mon, 2 Feb 2015 16:52:08 +0000 (11:52 -0500)]
Allow closure arguments types to unify even if we can't fully resolve
a trait obligation. Partial fix for #16440 -- closure return types are
not handled yet.

9 years agoOptimize rposition
Björn Steinbrink [Tue, 3 Feb 2015 15:54:06 +0000 (16:54 +0100)]
Optimize rposition

The extra check caused by the expect() call can, in general, not be
optimized away, because the length of the iterator is unknown at compile
time, causing a noticable slow-down. Since the check only triggers if
the element isn't actually found in the iterator, i.e. it isn't
guaranteed to trigger for ill-behaved ExactSizeIterators, it seems
reasonable to switch to an implementation that doesn't need the check
and just always returns None if the value isn't found.

Benchmark:
````rust
let v: Vec<u8> = (0..1024*65).map(|_| 0).collect();
b.iter(|| {
    v.as_slice().iter().rposition(|&c| c == 1)
});
````

Before:
````
test rposition  ... bench:     49939 ns/iter (+/- 23)
````

After:
````
test rposition  ... bench:     33306 ns/iter (+/- 68)
````

9 years agoAuto merge of #21877 - dotdash:less_auto_deref, r=alexcrichton
bors [Tue, 3 Feb 2015 14:56:32 +0000 (14:56 +0000)]
Auto merge of #21877 - dotdash:less_auto_deref, r=alexcrichton

9 years agoadd naivest entry API to VecMap
Alexis [Tue, 3 Feb 2015 05:47:38 +0000 (00:47 -0500)]
add naivest entry API to VecMap

9 years agoiOS: fixed build
Valerii Hiora [Tue, 3 Feb 2015 13:30:10 +0000 (15:30 +0200)]
iOS: fixed build

9 years agoAuto merge of #21675 - huonw:less-false-positives, r=nikomatsakis
bors [Tue, 3 Feb 2015 12:49:21 +0000 (12:49 +0000)]
Auto merge of #21675 - huonw:less-false-positives, r=nikomatsakis

That is, when offering suggestions for unresolved method calls, avoid
suggesting traits for which implementing the trait for the receiver type
either makes little sense (e.g. type errors, or sugared unboxed
closures), or violates coherence.

The latter is approximated by ensuring that at least one of `{receiver
type, trait}` is local. This isn't precisely correct due to
multidispatch, but the error messages one encounters in such situation
are useless more often than not; it is better to be conservative and
miss some cases, than have overly many false positives (e.g. writing
`some_slice.map(|x| ...)` uselessly suggested that one should implement
`IteratorExt` for `&[T]`, while the correct fix is to call `.iter()`).

Closes #21420.

9 years agoRc: Add assumptions that the pointer is non-null
James Miller [Tue, 20 Jan 2015 20:35:24 +0000 (09:35 +1300)]
Rc: Add assumptions that the pointer is non-null

Since the snapshot compiler is still using an older LLVM version, omit
the call in stage0, because compile times explode otherwise.

9 years agoCompute widths properly when displaying spans in error messages
P1start [Thu, 22 Jan 2015 06:49:40 +0000 (19:49 +1300)]
Compute widths properly when displaying spans in error messages

Closes #8706.

9 years agoTry to only suggest implementable traits for method calls.
Huon Wilson [Tue, 27 Jan 2015 00:29:30 +0000 (11:29 +1100)]
Try to only suggest implementable traits for method calls.

That is, when offering suggestions for unresolved method calls, avoid
suggesting traits for which implementing the trait for the receiver type
either makes little sense (e.g. type errors, or sugared unboxed
closures), or violates coherence.

The latter is approximated by ensuring that at least one of `{receiver
type, trait}` is local. This isn't precisely correct due to
multidispatch, but the error messages one encounters in such situation
are useless more often than not; it is better to be conservative and
miss some cases, than have overly many false positives (e.g. writing
`some_slice.map(|x| ...)` uselessly suggested that one should implement
`IteratorExt` for `&[T]`, while the correct fix is to call `.iter()`).

Closes #21420.

9 years agoAuto merge of #21745 - chris-morgan:add-missing-unstable-attributes, r=huonw
bors [Tue, 3 Feb 2015 10:40:33 +0000 (10:40 +0000)]
Auto merge of #21745 - chris-morgan:add-missing-unstable-attributes, r=huonw

I’d kind of like to be able to use HashState in AnyMap, which I can’t do without a stability attribute on it. While I was at it I looked around and found a few more missing.

9 years agoAuto merge of #21613 - alfie:suffix-small, r=alexcrichton
bors [Tue, 3 Feb 2015 07:59:04 +0000 (07:59 +0000)]
Auto merge of #21613 - alfie:suffix-small, r=alexcrichton

9 years agoEmit !nonnull metadata for loads of region and unique pointers
Björn Steinbrink [Mon, 2 Feb 2015 18:03:23 +0000 (19:03 +0100)]
Emit !nonnull metadata for loads of region and unique pointers

These pointers are never null, let's tell LLVM about it.

9 years agostd: Add some missing stability attributes
Alex Crichton [Mon, 2 Feb 2015 02:33:13 +0000 (18:33 -0800)]
std: Add some missing stability attributes

* Display::fmt is stable
* Debug::fmt is stable
* FromIterator::from_iter is stable
* Peekable::peek is stable

9 years agoAuto merge of #21872 - alexcrichton:rollup, r=alexcrichton
bors [Tue, 3 Feb 2015 03:44:05 +0000 (03:44 +0000)]
Auto merge of #21872 - alexcrichton:rollup, r=alexcrichton

9 years agoTest fixes and rebase conflicts
Alex Crichton [Mon, 2 Feb 2015 19:04:58 +0000 (11:04 -0800)]
Test fixes and rebase conflicts

9 years agoAvoid extra ref/deref cycles when converting &T to *T
Björn Steinbrink [Tue, 3 Feb 2015 00:22:09 +0000 (01:22 +0100)]
Avoid extra ref/deref cycles when converting &T to *T

9 years agoMore deprecating of i/u suffixes
Alfie John [Sat, 24 Jan 2015 14:39:32 +0000 (14:39 +0000)]
More deprecating of i/u suffixes

9 years agorollup merge of #21869: dotdash/bogus_match
Alex Crichton [Mon, 2 Feb 2015 19:01:29 +0000 (11:01 -0800)]
rollup merge of #21869: dotdash/bogus_match

The inner match will always result in `true`, so we can as well replace
it with just that.

9 years agorollup merge of #21865: steveklabnik/gh21501
Alex Crichton [Mon, 2 Feb 2015 19:01:26 +0000 (11:01 -0800)]
rollup merge of #21865: steveklabnik/gh21501

Fixes #21501

r? @huonw

9 years agorollup merge of #21854: alexcrichton/try-borrow
Alex Crichton [Mon, 2 Feb 2015 19:01:23 +0000 (11:01 -0800)]
rollup merge of #21854: alexcrichton/try-borrow

The existence of these two functions is at odds with our current [error
conventions][conventions] which recommend that panicking and `Result`-like
variants should not be provided together.

[conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

This commit adds a new `borrow_state` function returning a `BorrowState` enum to
`RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut`
functions.

9 years agorollup merge of #21852: FreeFull/patch-1
Alex Crichton [Mon, 2 Feb 2015 19:01:21 +0000 (11:01 -0800)]
rollup merge of #21852: FreeFull/patch-1

Misspelling fix.

9 years agorollup merge of #21849: alexcrichton/warn2note
Alex Crichton [Mon, 2 Feb 2015 19:01:19 +0000 (11:01 -0800)]
rollup merge of #21849: alexcrichton/warn2note

There [have been reports][issue] of an unconditional warning causing tooling to
go awry. This isn't actually a warning per se, it's more of a note anyway!

[issue]: https://github.com/rust-lang/cargo/issues/1260

Closes rust-lang/cargo#1260

9 years agorollup merge of #21848: Manishearth/book-link
Alex Crichton [Mon, 2 Feb 2015 19:01:18 +0000 (11:01 -0800)]
rollup merge of #21848: Manishearth/book-link

rollupable

r? @steveklabnik

9 years agorollup merge of #21845: Potpourri/import-syntax
Alex Crichton [Mon, 2 Feb 2015 19:01:17 +0000 (11:01 -0800)]
rollup merge of #21845: Potpourri/import-syntax

syntax like `use foo::bar::;` and `use foo:: as bar;` should be rejected, see issue #21629

9 years agorollup merge of #21842: alexcrichton/issue-21839
Alex Crichton [Mon, 2 Feb 2015 19:01:16 +0000 (11:01 -0800)]
rollup merge of #21842: alexcrichton/issue-21839

Now that associated types are fully implemented the iterator adaptors only need
type parameters which are associated with actual storage. All other type
parameters can either be derived from these (e.g. they are an associated type)
or can be bare on the `impl` block itself.

This is a breaking change due to the removal of type parameters on these
iterator adaptors, but code can fairly easily migrate by just deleting the
relevant type parameters for each adaptor. Other behavior should not be
affected.

Closes #21839
[breaking-change]

9 years agorollup merge of #21832: genbattle/doc-unicode-escapes
Alex Crichton [Mon, 2 Feb 2015 19:01:15 +0000 (11:01 -0800)]
rollup merge of #21832: genbattle/doc-unicode-escapes

Unicode escapes were changed in [this RFC](https://github.com/rust-lang/rfcs/blob/28aeb3c391c9afd344f124d3a69bdc2a420638b2/text/0446-es6-unicode-escapes.md) to use the ES6 \u{00FFFF} syntax with a variable number of digits from 1-6, eliminating the need for two different syntaxes for unicode literals.

I have updated The Reference and grammar.md to reflect these changes.

9 years agorollup merge of #21830: japaric/for-cleanup
Alex Crichton [Mon, 2 Feb 2015 19:01:12 +0000 (11:01 -0800)]
rollup merge of #21830: japaric/for-cleanup

Conflicts:
src/librustc/metadata/filesearch.rs
src/librustc_back/target/mod.rs
src/libstd/os.rs
src/libstd/sys/windows/os.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/print/pprust.rs
src/test/compile-fail/issue-2149.rs

9 years agorollup merge of #21825: kmcallister/ttdelim-span
Alex Crichton [Mon, 2 Feb 2015 18:58:19 +0000 (10:58 -0800)]
rollup merge of #21825: kmcallister/ttdelim-span

9 years agorollup merge of #21819: dsyang/doc_fix
Alex Crichton [Mon, 2 Feb 2015 18:58:17 +0000 (10:58 -0800)]
rollup merge of #21819: dsyang/doc_fix

as titled.  See issue #21770

9 years agorollup merge of #21818: dotdash/llvm_up
Alex Crichton [Mon, 2 Feb 2015 18:58:15 +0000 (10:58 -0800)]
rollup merge of #21818: dotdash/llvm_up

9 years agorollup merge of #21817: edwardw/symmetric-binop
Alex Crichton [Mon, 2 Feb 2015 18:58:10 +0000 (10:58 -0800)]
rollup merge of #21817: edwardw/symmetric-binop

For "symmetric" binary operators, meaning the types of two sides must be
equal, if the type of LHS doesn't know yet but RHS does, use that as an
hint to infer LHS' type.

Closes #21634

9 years agorollup merge of #21815: nagisa/overflowing-lints
Alex Crichton [Mon, 2 Feb 2015 18:58:09 +0000 (10:58 -0800)]
rollup merge of #21815: nagisa/overflowing-lints

9 years agorollup merge of #21808: jfager/r20454
Alex Crichton [Mon, 2 Feb 2015 18:58:07 +0000 (10:58 -0800)]
rollup merge of #21808: jfager/r20454

Closes #20454

9 years agorollup merge of #21803: madmalik/patch-1
Alex Crichton [Mon, 2 Feb 2015 18:58:06 +0000 (10:58 -0800)]
rollup merge of #21803: madmalik/patch-1

http://doc.rust-lang.org/rustdoc.html states that its content was moved to http://doc.rust-lang.org/book/documentation.html

9 years agorollup merge of #21800: brson/unused_features
Alex Crichton [Mon, 2 Feb 2015 18:58:05 +0000 (10:58 -0800)]
rollup merge of #21800: brson/unused_features

When it was un*known*_features it was reasonable to be deny by default.

cc #21798

r? @alexcrichton

9 years agorollup merge of #21794: alexcrichton/stabilize-atomic-usize
Alex Crichton [Mon, 2 Feb 2015 18:58:04 +0000 (10:58 -0800)]
rollup merge of #21794: alexcrichton/stabilize-atomic-usize

These methods were intended to be stable as of #16258 but the tags have since
been lost in various refactorings. This commit re-adds the `#[stable]`
attributes to each of these functions.

9 years agorollup merge of #21787: alexcrichton/std-env
Alex Crichton [Mon, 2 Feb 2015 18:58:01 +0000 (10:58 -0800)]
rollup merge of #21787: alexcrichton/std-env

Conflicts:
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/os.rs

9 years agorollup merge of #21782: alexcrichton/issue-21771
Alex Crichton [Mon, 2 Feb 2015 18:56:59 +0000 (10:56 -0800)]
rollup merge of #21782: alexcrichton/issue-21771

Previously if --extern was specified it would not override crates in the
standard distribution, leading to issues like #21771. This commit alters the
behavior such that if --extern is passed then it will always override any other
choice of crates and no previous match will be used (unless it is the same path
as --extern).

Closes #21771

9 years agorollup merge of #21754: semarie/openbsd-rebased
Alex Crichton [Mon, 2 Feb 2015 18:56:57 +0000 (10:56 -0800)]
rollup merge of #21754: semarie/openbsd-rebased

Hi.

Here a commit in order to add OpenBSD support to rust.

- tests status:
run-pass: test result: ok. 1879 passed; 0 failed; 24 ignored; 0 measured
run-fail: test result: ok. 81 passed; 0 failed; 5 ignored; 0 measured
compile-fail: test result: ok. 1634 passed; 0 failed; 22 ignored; 0 measured
run-pass-fulldeps: test result: ok. 22 passed; 0 failed; 1 ignored; 0 measured
compile-fail-fulldeps: test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured

- The current implementation of load_self function (src/libstd/sys/unix/os.rs) isn't optimal as under OpenBSD I haven't found a reliable method to get the filename of a running process. The current implementation is enought for bootstrapping purpose.

- I have disable `run-pass/tcp-stress.rs` test under openbsd. When run manually, the test pass, but when run under `compiletest`, it timeout and echo continuoulsy `Too many open files`.

- For building with jemalloc, a more recent version of jemalloc would be mandatory. See https://github.com/jemalloc/jemalloc/pull/188 for more details.

9 years agorollup merge of #21710: alfie/libsyntax
Alex Crichton [Mon, 2 Feb 2015 18:56:55 +0000 (10:56 -0800)]
rollup merge of #21710: alfie/libsyntax

Conflicts:
src/libsyntax/parse/parser.rs

9 years agorollup merge of #21567: steveklabnik/doc_char
Alex Crichton [Mon, 2 Feb 2015 18:56:11 +0000 (10:56 -0800)]
rollup merge of #21567: steveklabnik/doc_char

9 years agorollup merge of #21509: lucab/lucab/copyright-update
Alex Crichton [Mon, 2 Feb 2015 18:56:10 +0000 (10:56 -0800)]
rollup merge of #21509: lucab/lucab/copyright-update

valgrind files moved and modpath.iss deleted. Both entries updated in
COPYRIGHT file.

Signed-off-by: Luca Bruno <lucab@debian.org>
9 years agorollup merge of #21362: aochagavia/copy_rawptr
Alex Crichton [Mon, 2 Feb 2015 18:56:07 +0000 (10:56 -0800)]
rollup merge of #21362: aochagavia/copy_rawptr

Fixes #21272 and #21296

r? @cmr

9 years agorollup merge of #21223: P1start/expected-token-improvements
Alex Crichton [Mon, 2 Feb 2015 18:56:05 +0000 (10:56 -0800)]
rollup merge of #21223: P1start/expected-token-improvements

Fixes #21153.

9 years agoremove unused mut qualifiers
Jorge Aparicio [Sat, 31 Jan 2015 14:17:50 +0000 (09:17 -0500)]
remove unused mut qualifiers

9 years ago`for x in xs.into_iter()` -> `for x in xs`
Jorge Aparicio [Sun, 1 Feb 2015 01:03:04 +0000 (20:03 -0500)]
`for x in xs.into_iter()` -> `for x in xs`

Also `for x in option.into_iter()` -> `if let Some(x) = option`

9 years ago`for x in xs.iter_mut()` -> `for x in &mut xs`
Jorge Aparicio [Sun, 1 Feb 2015 01:02:00 +0000 (20:02 -0500)]
`for x in xs.iter_mut()` -> `for x in &mut xs`

Also `for x in option.iter_mut()` -> `if let Some(ref mut x) = option`

9 years ago`for x in xs.iter()` -> `for x in &xs`
Jorge Aparicio [Sat, 31 Jan 2015 17:20:46 +0000 (12:20 -0500)]
`for x in xs.iter()` -> `for x in &xs`

9 years agoimpl IntoIterator for HashSet
Jorge Aparicio [Sat, 31 Jan 2015 17:05:58 +0000 (12:05 -0500)]
impl IntoIterator for HashSet

9 years agoimpl IntoIterator for HashMap
Jorge Aparicio [Sat, 31 Jan 2015 16:41:32 +0000 (11:41 -0500)]
impl IntoIterator for HashMap

9 years agoregister snapshots
Jorge Aparicio [Sat, 31 Jan 2015 14:16:56 +0000 (09:16 -0500)]
register snapshots

9 years agoRemove a bogus match from type_is_unique
Björn Steinbrink [Mon, 2 Feb 2015 17:58:24 +0000 (18:58 +0100)]
Remove a bogus match from type_is_unique

The inner match will always result in `true`, so we can as well replace
it with just that.

9 years agoAdd test for #21296
Adolfo Ochagavía [Sun, 18 Jan 2015 14:57:08 +0000 (15:57 +0100)]
Add test for #21296

9 years agoDo not warn when deriving `Copy` for raw pointers
Adolfo Ochagavía [Sun, 18 Jan 2015 14:44:41 +0000 (15:44 +0100)]
Do not warn when deriving `Copy` for raw pointers

Fixes #21272 and #21296

9 years agoAuto merge of #21864 - sanxiyn:no-chain, r=nikomatsakis
bors [Mon, 2 Feb 2015 15:04:54 +0000 (15:04 +0000)]
Auto merge of #21864 - sanxiyn:no-chain, r=nikomatsakis

This avoids triggering #21694. It probably is a better way to do it anyway.

9 years agoDocumenting libcore/char.rs
Steve Klabnik [Fri, 23 Jan 2015 21:43:16 +0000 (16:43 -0500)]
Documenting libcore/char.rs

9 years agoAuto merge of #21647 - alfie:suffix-medium, r=alexcrichton
bors [Mon, 2 Feb 2015 11:52:34 +0000 (11:52 +0000)]
Auto merge of #21647 - alfie:suffix-medium, r=alexcrichton

9 years agoFix discrepencies in the testing chapter
Steve Klabnik [Mon, 2 Feb 2015 09:40:57 +0000 (04:40 -0500)]
Fix discrepencies in the testing chapter

Fixes #21501

9 years agoAvoid an excessive use of iterator chain
Seo Sanghyeon [Mon, 2 Feb 2015 09:33:24 +0000 (18:33 +0900)]
Avoid an excessive use of iterator chain

9 years agoOmit integer suffix when unnecessary
Alfie John [Wed, 28 Jan 2015 01:01:48 +0000 (01:01 +0000)]
Omit integer suffix when unnecessary

See PR # 21378 for context

9 years agostd: Deprecate RefCell::{try_borrow, try_borrow_mut}
Alex Crichton [Mon, 2 Feb 2015 02:53:47 +0000 (18:53 -0800)]
std: Deprecate RefCell::{try_borrow, try_borrow_mut}

The existence of these two functions is at odds with our current [error
conventions][conventions] which recommend that panicking and `Result`-like
variants should not be provided together.

[conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

This commit adds a new `borrow_state` function returning a `BorrowState` enum to
`RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut`
functions.

9 years agoTweak some ‘expected…’ error messages
P1start [Fri, 16 Jan 2015 03:04:28 +0000 (16:04 +1300)]
Tweak some ‘expected…’ error messages

Fixes #21153.

9 years agoAdd test, closes #20454
Jason Fager [Sat, 31 Jan 2015 14:45:00 +0000 (09:45 -0500)]
Add test, closes #20454

9 years agoCloses issue #21850
Filip Szczepański [Mon, 2 Feb 2015 00:46:34 +0000 (00:46 +0000)]
Closes issue #21850

9 years agorustc: Change an unconditional `warn` to a `note`
Alex Crichton [Sun, 1 Feb 2015 22:25:55 +0000 (14:25 -0800)]
rustc: Change an unconditional `warn` to a `note`

There [have been reports][issue] of an unconditional warning causing tooling to
go awry. This isn't actually a warning per se, it's more of a note anyway!

[issue]: https://github.com/rust-lang/cargo/issues/1260

Closes rust-lang/cargo#1260

9 years agoFix stale doc link (guide -> book)
Manish Goregaokar [Sun, 1 Feb 2015 22:15:52 +0000 (03:45 +0530)]
Fix stale doc link (guide -> book)

9 years agoAuto merge of #21318 - stepancheg:box-fns, r=alexcrichton
bors [Sun, 1 Feb 2015 21:53:53 +0000 (21:53 +0000)]
Auto merge of #21318 - stepancheg:box-fns, r=alexcrichton

Functions are needed for safety and convenience.

It is a common pattern to use `mem::transmute` to convert between
`Box` and raw pointer, like this:

```
let b = Box::new(3);
let p = mem::transmute(b);
// pass `p` to some C library
```

After this commit, conversion can be written as:

```
let p = b.into_raw();
```

`into_raw` and `from_raw` functions are still unsafe, but they are
much safer than `mem::transmute`, because *raw functions do not
convert between incompatible pointers. For example, this likely
incorrect code can be successfully compiled:

```
let p: *mut u64 = ...
let b: Box<u32> = mem::transmute(p);
```

Using `from_raw` results in compile-time error:

```
let p: *mut u64 = ...
let b: Box<u32> = Box::from_raw(p); // compile-time error
```

`into_raw` and `from_raw` functions are similar to C++ `std::unique_ptr`
`release` function [1] and constructor from pointer [2].

[1] http://en.cppreference.com/w/cpp/memory/unique_ptr/release
[2] http://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr

9 years agostd: Remove extra type params on iter adaptors
Alex Crichton [Sun, 1 Feb 2015 20:15:36 +0000 (12:15 -0800)]
std: Remove extra type params on iter adaptors

Now that associated types are fully implemented the iterator adaptors only need
type parameters which are associated with actual storage. All other type
parameters can either be derived from these (e.g. they are an associated type)
or can be bare on the `impl` block itself.

This is a breaking change due to the removal of type parameters on these
iterator adaptors, but code can fairly easily migrate by just deleting the
relevant type parameters for each adaptor. Other behavior should not be
affected.

Closes #21839
[breaking-change]

9 years agoReject syntax like `use foo::bar::;` and `use foo:: as bar;` and keywords in view...
Potpourri [Sat, 31 Jan 2015 21:59:58 +0000 (00:59 +0300)]
Reject syntax like `use foo::bar::;` and `use foo:: as bar;` and keywords in view path idents

9 years agostd: Add a new `env` module
Alex Crichton [Tue, 27 Jan 2015 20:20:58 +0000 (12:20 -0800)]
std: Add a new `env` module

This is an implementation of [RFC 578][rfc] which adds a new `std::env` module
to replace most of the functionality in the current `std::os` module. More
details can be found in the RFC itself, but as a summary the following methods
have all been deprecated:

[rfc]: https://github.com/rust-lang/rfcs/pull/578

* `os::args_as_bytes`   => `env::args`
* `os::args`            => `env::args`
* `os::consts`          => `env::consts`
* `os::dll_filename`    => no replacement, use `env::consts` directly
* `os::page_size`       => `env::page_size`
* `os::make_absolute`   => use `env::current_dir` + `join` instead
* `os::getcwd`          => `env::current_dir`
* `os::change_dir`      => `env::set_current_dir`
* `os::homedir`         => `env::home_dir`
* `os::tmpdir`          => `env::temp_dir`
* `os::join_paths`      => `env::join_paths`
* `os::split_paths`     => `env::split_paths`
* `os::self_exe_name`   => `env::current_exe`
* `os::self_exe_path`   => use `env::current_exe` + `pop`
* `os::set_exit_status` => `env::set_exit_status`
* `os::get_exit_status` => `env::get_exit_status`
* `os::env`             => `env::vars`
* `os::env_as_bytes`    => `env::vars`
* `os::getenv`          => `env::var` or `env::var_string`
* `os::getenv_as_bytes` => `env::var`
* `os::setenv`          => `env::set_var`
* `os::unsetenv`        => `env::remove_var`

Many function signatures have also been tweaked for various purposes, but the
main changes were:

* `Vec`-returning APIs now all return iterators instead
* All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`.
  There is currently on convenience API, `env::var_string`, which can be used to
  get the value of an environment variable as a unicode `String`.

All old APIs are `#[deprecated]` in-place and will remain for some time to allow
for migrations. The semantics of the APIs have been tweaked slightly with regard
to dealing with invalid unicode (panic instead of replacement).

The new `std::env` module is all contained within the `env` feature, so crates
must add the following to access the new APIs:

    #![feature(env)]

[breaking-change]

9 years agoAuto merge of #21806 - edwardw:new-range-impl, r=alexcrichton
bors [Sun, 1 Feb 2015 19:07:11 +0000 (19:07 +0000)]
Auto merge of #21806 - edwardw:new-range-impl, r=alexcrichton

The new `::ops::Range` has separated implementations for each of the
numeric types, while the old `::iter::Range` has one for type `Int`.
However, we do not take output bindings into account when selecting
traits. So it confuses `typeck` and makes the new range does not work as
good as the old one when it comes to type inference.

This patch implements `Iterator` for the new range for one type `Int`.
This limitation could be lifted, however, if we ever reconsider the
output types' role in type inference.

Closes #21595
Closes #21649
Closes #21672

9 years agoUpdate LLVM to rust-llvm-2015-01-30
Björn Steinbrink [Fri, 30 Jan 2015 18:25:07 +0000 (19:25 +0100)]
Update LLVM to rust-llvm-2015-01-30

9 years agobox: into_raw, from_raw functions
Stepan Koltsov [Sun, 1 Feb 2015 17:15:44 +0000 (20:15 +0300)]
box: into_raw, from_raw functions

Functions are needed for safety and convenience.

It is a common pattern to use `mem::transmute` to convert between
`Box` and raw pointer, like this:

```
let b = Box::new(3);
let p = mem::transmute(b);
// pass `p` to some C library
```

After this commit, conversion can be written as:

```
let p = boxed::into_raw(b);
```

`into_raw` and `from_raw` functions are still unsafe, but they are
much safer than `mem::transmute`, because *raw functions do not
convert between incompatible pointers. For example, this likely
incorrect code can be successfully compiled:

```
let p: *mut u64 = ...
let b: Box<u32> = mem::transmute(p);
```

Using `from_raw` results in compile-time error:

```
let p: *mut u64 = ...
let b: Box<u32> = Box::from_raw(p); // compile-time error
```

`into_raw` and `from_raw` functions are similar to C++ `std::unique_ptr`
`release` function [1] and constructor from pointer [2].

[1] http://en.cppreference.com/w/cpp/memory/unique_ptr/release
[2] http://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr

9 years agoAuto merge of #21811 - tbu-:pr_more_isize, r=alexcrichton
bors [Sun, 1 Feb 2015 15:49:20 +0000 (15:49 +0000)]
Auto merge of #21811 - tbu-:pr_more_isize, r=alexcrichton

Remove more `isize` stuff. Also fix the manual a bit about integer inference.

9 years agoopenbsd: rebase to master
Sébastien Marie [Sun, 1 Feb 2015 13:58:57 +0000 (14:58 +0100)]
openbsd: rebase to master

- incoporate changes introduced by #21678

9 years agoopenbsd: remove specific block and cleanup linkage
Sébastien Marie [Fri, 30 Jan 2015 13:28:13 +0000 (14:28 +0100)]
openbsd: remove specific block and cleanup linkage

- the specific block for dl* function isn't need for openbsd if libdl
  isn't marked to be linked here. remove them.

- remove the linkage for libdl: it should already specified in `rtdeps.rs`.

the code of `dynamic_lib.rs` include libdl for:
 - linux (already defined in rtdeps.rs)
 - android (already defined in rtdeps.rs)
 - macos (not needed for macos)
 - ios (probably the same as macos)
 - freebsd (libdl is a stub)
 - dragonfly (libdl is a stub)

9 years agoopenbsd: remove unused openbsd code
Sébastien Marie [Fri, 30 Jan 2015 10:46:30 +0000 (11:46 +0100)]
openbsd: remove unused openbsd code

This code is in a block (libc::consts::os) that openbsd don't include
This one is for freebsd and dragonfly. There is another block for openbsd below.

Remove the unneed declaration.

9 years agoopenbsd: incoporate remarks
Sébastien Marie [Fri, 30 Jan 2015 07:15:28 +0000 (08:15 +0100)]
openbsd: incoporate remarks

- consolidate target_record_sp_limit and target_get_sp_limit functions
  for aarch64, powerpc, arm-ios and openbsd as there are all without
  segmented stacks (no need to duplicate functions).

- rename __load_self function to rust_load_self

- use a mutex inner load_self() as underline implementation is not thread-safe

9 years agoopenbsd: break lines too long
Sébastien Marie [Thu, 29 Jan 2015 17:02:32 +0000 (18:02 +0100)]
openbsd: break lines too long

9 years agoopenbsd support
Sébastien Marie [Thu, 29 Jan 2015 07:19:28 +0000 (08:19 +0100)]
openbsd support

9 years agoAuto merge of #21805 - nikomatsakis:closure-inference-refactor-1, r=eddyb
bors [Sun, 1 Feb 2015 13:01:57 +0000 (13:01 +0000)]
Auto merge of #21805 - nikomatsakis:closure-inference-refactor-1, r=eddyb

Currently, we only infer the kind of a closure based on the expected type or explicit annotation. If neither applies, we currently report an error. This pull request changes that case to defer the decision until we are able to analyze the actions of the closure: closures which mutate their environment require `FnMut`, closures which move out of their environment require `FnOnce`.

This PR is not the end of the story:

- It does not remove the explicit annotations nor disregard them. The latter is the logical next step to removing them (we'll need a snapshot before we can do anything anyhow). Disregarding explicit annotations might expose more bugs since right now all closures in libstd/rustc use explicit annotations or the expected type, so this inference never kicks in.
- The interaction with instantiating type parameter fallbacks leaves something to be desired. This is mostly just saying that the algorithm from https://github.com/rust-lang/rfcs/pull/213 needs to be implemented, which is a separate bug. There are some semi-subtle interactions though because not knowing whether a closure is `Fn` vs `FnMut` prevents us from resolving obligations like `F : FnMut(...)`, which can in turn prevent unification of some type parameters, which might (in turn) lead to undesired fallback. We can improve this situation however -- even if we don't know whether (or just how) `F : FnMut(..)` holds or not for some closure type `F`, we can still perform unification since we *do* know the argument and return types. Once kind inference is done, we can complete the `F : FnMut(..)` analysis -- which might yield an error if (e.g.) the `F` moves out of its environment.

r? @nick29581

9 years agoDo not ICE when e.g. `call_mut()` is called on a closure whose kind is not yet known.
Niko Matsakis [Sun, 1 Feb 2015 11:07:52 +0000 (06:07 -0500)]
Do not ICE when e.g. `call_mut()` is called on a closure whose kind is not yet known.

9 years agoFix handling of `move` closures -- since they have one fewer deref, we weren't proper...
Niko Matsakis [Sun, 1 Feb 2015 01:58:26 +0000 (20:58 -0500)]
Fix handling of `move` closures -- since they have one fewer deref, we weren't properly adjusting the closure kind in that case.

9 years agoTweak comments per eddyb's suggestion.
Niko Matsakis [Sun, 1 Feb 2015 01:16:17 +0000 (20:16 -0500)]
Tweak comments per eddyb's suggestion.

9 years agoTo handle more complex cases, modify the deferred call handler to be
Niko Matsakis [Sat, 31 Jan 2015 11:29:04 +0000 (06:29 -0500)]
To handle more complex cases, modify the deferred call handler to be
specialized to closures, and invoke them as soon as we know the
closure kind. I thought initially we would need a fixed-point
inference algorithm but it appears I was mistaken, so we can do this.

9 years agoImplement basic inference for closure kinds and some simple tests.
Niko Matsakis [Sat, 31 Jan 2015 01:23:17 +0000 (20:23 -0500)]
Implement basic inference for closure kinds and some simple tests.
Trickier cases not yet handled.

9 years agoSeparate out the unboxed closure table into two tables, so that we can
Niko Matsakis [Fri, 30 Jan 2015 16:37:23 +0000 (11:37 -0500)]
Separate out the unboxed closure table into two tables, so that we can
generate the closure type and closure kind separately.

9 years agoAdjust the handling of trait obligations and defaults to account for
Niko Matsakis [Sat, 31 Jan 2015 11:33:41 +0000 (06:33 -0500)]
Adjust the handling of trait obligations and defaults to account for
upvar inference.  Upvar inference can cause some obligations to be
deferred, notably things like `F : Sized` where `F` is a closure type,
or `F : FnMut`. Adjust the ordering therefore so that we process all
traits and apply fallback, do upvar inference, and only then start
reporting errors for outstanding obligations.

9 years agoDo not make fake types for upvars if we haven't yet inferred whether they are borrowed
Niko Matsakis [Tue, 27 Jan 2015 18:45:42 +0000 (13:45 -0500)]
Do not make fake types for upvars if we haven't yet inferred whether they are borrowed
or by value.

9 years agoMake `unboxed_closure_kind` return `Option` to allow for the possibility that its...
Niko Matsakis [Mon, 26 Jan 2015 11:22:06 +0000 (06:22 -0500)]
Make `unboxed_closure_kind` return `Option` to allow for the possibility that its value is not yet known.

9 years agoIntroduce the notion of deferred resolutions and use it to hold off on
Niko Matsakis [Sat, 24 Jan 2015 22:32:10 +0000 (17:32 -0500)]
Introduce the notion of deferred resolutions and use it to hold off on
doing the final checking for closure calls until after trait inference
is performed. This isn't important now, but it's essential if we are to
delay inferring the closure kind.

9 years agoMore deprecating of i/u suffixes in libraries
Alfie John [Sun, 25 Jan 2015 10:58:43 +0000 (10:58 +0000)]
More deprecating of i/u suffixes in libraries

9 years agoAuto merge of #21809 - japaric:no-copy, r=alexcrichton
bors [Sun, 1 Feb 2015 10:14:51 +0000 (10:14 +0000)]
Auto merge of #21809 - japaric:no-copy, r=alexcrichton

Removes `Copy` from `ops::Range` (`a..b`) and `ops::RangeFrom` (`a..`)

[breaking-change]

---

I forgot about these two in #20790, this PR also adds `Clone` to the `Peekable` adapter which used to be `Copy`able.

r? @nikomatsakis or anyone

9 years agoAuto merge of #21788 - carllerche:master, r=alexcrichton
bors [Sun, 1 Feb 2015 07:21:14 +0000 (07:21 +0000)]
Auto merge of #21788 - carllerche:master, r=alexcrichton

The implementation is similar to `Thread::park`