]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoAuto merge of #21962 - vrinek:printable-book, r=steveklabnik
bors [Fri, 6 Feb 2015 13:57:11 +0000 (13:57 +0000)]
Auto merge of #21962 - vrinek:printable-book, r=steveklabnik

Tested on:

* Safari on OSX
* Firefox on OSX

9 years agoAuto merge of #21609 - GarrettHeel:master, r=steveklabnik
bors [Fri, 6 Feb 2015 05:52:20 +0000 (05:52 +0000)]
Auto merge of #21609 - GarrettHeel:master, r=steveklabnik

Now that it's no longer feature gated, add docs for wildcard syntax.

9 years agoAuto merge of #21947 - bluss:full-range-syntax, r=brson
bors [Fri, 6 Feb 2015 03:11:34 +0000 (03:11 +0000)]
Auto merge of #21947 - bluss:full-range-syntax, r=brson

Implement step 1 of rust-lang/rfcs#702

Allows the expression `..` (without either endpoint) in general, can be
used in slicing syntax `&expr[..]` where we previously wrote `&expr[]`.

The old syntax &expr[] is not yet removed or warned for.

9 years agoAuto merge of #21619 - brson:featureck-tidy, r=alexcrichton
bors [Thu, 5 Feb 2015 23:14:28 +0000 (23:14 +0000)]
Auto merge of #21619 - brson:featureck-tidy, r=alexcrichton

Builds on my [feature staging PR](https://github.com/rust-lang/rust/pull/21248) to clean up the tidy scripts a bit, and make them much faster (6s vs ~40s).

Adds make rules 'tidy-basic', 'tidy-binaries', 'tidy-errors' and 'tidy-features'.

This is the output of `make tidy` here:

```
cfg: version 1.0.0-dev (a8c878d41 2015-01-25 01:49:14 -0800)
cfg: build triple x86_64-unknown-linux-gnu
cfg: host triples x86_64-unknown-linux-gnu
cfg: target triples x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: os for x86_64-unknown-linux-gnu is unknown-linux-gnu
cfg: good valgrind for x86_64-unknown-linux-gnu is 1
cfg: using CC=gcc (CFG_CC)
cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)
cfg: valgrind-rpass command set to "/usr/bin/valgrind" --error-exitcode=100 --soname-synonyms=somalloc=NONE --quiet --suppressions=/home/brian/dev/rust3/src/etc/x86.supp  --tool=memcheck --leak-check=full
cfg: no lualatex found, deferring to xelatex
cfg: no xelatex found, deferring to pdflatex
cfg: no pdflatex found, disabling LaTeX docs
cfg: no pandoc found, omitting PDF and EPUB docs
cfg: including test rules
cfg: javac not available, skipping lexer test...
check: formatting

* linted .rs files: 4948
* linted .py files: 27
* linted .js files: 2
* linted .sh files: 5
* linted .pl files: 0
* linted .c files: 28
* linted .h files: 3
* other linted files: 0
* total lines of code: 481217
* total non-blank lines of code: 423682

check: binaries
check: extended errors

* 249 error codes
* highest error code: E0315

check: feature sanity

* advanced_slice_patterns         lang    unstable    None
* alloc                           lib     unstable    None
* asm                             lang    unstable    None
* associated_types                lang    stable      1.0.0
* box_syntax                      lang    unstable    None
* collections                     lib     unstable    None
* concat_idents                   lang    unstable    None
* core                            lib     unstable    None
* default_type_params             lang    stable      1.0.0
* globs                           lang    stable      1.0.0
* hash                            lib     unstable    None
* if_let                          lang    stable      1.0.0
* import_shadowing                lang    unstable    None
* int_uint                        lang    unstable    None
* intrinsics                      lang    unstable    None
* io                              lib     unstable    None
* issue_5723_bootstrap            lang    stable      1.0.0
* lang_items                      lang    unstable    None
* link_args                       lang    unstable    None
* link_llvm_intrinsics            lang    unstable    None
* linkage                         lang    unstable    None
* log_syntax                      lang    unstable    None
* macro_rules                     lang    stable      1.0.0
* main                            lang    unstable    None
* managed_boxes                   lang    unstable    None
* non_ascii_idents                lang    unstable    None
* old_impl_check                  lang    unstable    None
* old_orphan_check                lang    unstable    None
* on_unimplemented                lang    unstable    None
* opt_out_copy                    lang    unstable    None
* optin_builtin_traits            lang    unstable    None
* os                              lib     unstable    None
* path                            lib     unstable    None
* phase                           lang    unstable    None
* plugin                          lang    unstable    None
* plugin_registrar                lang    unstable    None
* quad_precision_float            lang    unstable    None
* quote                           lang    unstable    None
* rand                            lib     unstable    None
* rust1                           lib     stable      1.0.0
* rustc_diagnostic_macros         lang    unstable    None
* rustc_private                   lib     unstable    None
* rustdoc                         lib     unstable    None
* simd                            lang    unstable    None
* simd_ffi                        lang    unstable    None
* slicing_syntax                  lang    unstable    None
* staged_api                      lang    unstable    None
* start                           lang    unstable    None
* std_misc                        lib     unstable    None
* struct_inherit                  lang    unstable    None
* struct_variant                  lang    stable      1.0.0
* test                            lib     unstable    None
* test_accepted_feature           lang    stable      1.0.0
* test_removed_feature            lang    unstable    None
* thread_local                    lang    unstable    None
* trace_macros                    lang    unstable    None
* tuple_indexing                  lang    stable      1.0.0
* unboxed_closures                lang    unstable    None
* unicode                         lib     unstable    None
* unsafe_destructor               lang    unstable    None
* visible_private_types           lang    unstable    None
* while_let                       lang    stable      1.0.0
```

There's a lot of informational output now, which comes after things like 'NOTE's.

9 years agoTidy fixes
Brian Anderson [Thu, 5 Feb 2015 22:38:56 +0000 (14:38 -0800)]
Tidy fixes

9 years agoAddress review feedback
Brian Anderson [Fri, 30 Jan 2015 23:08:46 +0000 (15:08 -0800)]
Address review feedback

9 years agomk: Print test summary after tidy when running 'make check'
Brian Anderson [Fri, 30 Jan 2015 22:58:02 +0000 (14:58 -0800)]
mk: Print test summary after tidy when running 'make check'

9 years agotestparser has long lines
Brian Anderson [Fri, 30 Jan 2015 22:57:21 +0000 (14:57 -0800)]
testparser has long lines

9 years agomk: Add version number to output. Useful for logs
Brian Anderson [Sun, 25 Jan 2015 09:48:38 +0000 (01:48 -0800)]
mk: Add version number to output. Useful for logs

9 years agomk: Add tidy commands to 'make tips'
Brian Anderson [Sun, 25 Jan 2015 09:42:02 +0000 (01:42 -0800)]
mk: Add tidy commands to 'make tips'

9 years agomk: Remove redundant valgrind notices in build
Brian Anderson [Sat, 24 Jan 2015 23:53:11 +0000 (15:53 -0800)]
mk: Remove redundant valgrind notices in build

9 years agoClean up tidy scripts, coverage, performance
Brian Anderson [Sat, 24 Jan 2015 23:18:19 +0000 (15:18 -0800)]
Clean up tidy scripts, coverage, performance

This restructures tidy.py to walk the tree itself,
and improves performance considerably by not loading entire
files into buffers for licenseck.

Splits build rules into 'tidy', 'tidy-basic', 'tidy-binaries',
'tidy-errors', 'tidy-features'.

9 years agoPolish errorck and featureck UI
Brian Anderson [Sat, 24 Jan 2015 20:23:06 +0000 (12:23 -0800)]
Polish errorck and featureck UI

9 years agomk: Split tidy into multiple tidy rules
Brian Anderson [Sat, 24 Jan 2015 20:16:06 +0000 (12:16 -0800)]
mk: Split tidy into multiple tidy rules

* tidy - runs all tidy scripts
* tidy-basic - tidy.rs
* tidy-binaries - check-binaries.py
* tidy-errors - errorck.py
* tidy-features - featureck.py

9 years agoAuto merge of #21894 - dotdash:assume_rc, r=alexcrichton
bors [Thu, 5 Feb 2015 21:08:03 +0000 (21:08 +0000)]
Auto merge of #21894 - dotdash:assume_rc, r=alexcrichton

This is half of what @Aatch implemented in #21418. The non-null assumption is later canonicalized to !nonnull metadata and doesn't cause any slowdowns (in fact the build is slightly faster with this change). I left out the other half of #21418 because that still causes a ~16% increase in compile times (30m -> 35m).

9 years agoAuto merge of #21916 - japaric:no-as-slice, r=alexcrichton
bors [Thu, 5 Feb 2015 19:00:13 +0000 (19:00 +0000)]
Auto merge of #21916 - japaric:no-as-slice, r=alexcrichton

r? @alexcrichton
cc @eddyb

9 years agocleanup: replace `as[_mut]_slice()` calls with deref coercions
Jorge Aparicio [Mon, 2 Feb 2015 02:53:25 +0000 (21:53 -0500)]
cleanup: replace `as[_mut]_slice()` calls with deref coercions

9 years agoImplement pretty-printing of `..` and update tests.
Ulrik Sverdrup [Thu, 5 Feb 2015 16:58:30 +0000 (17:58 +0100)]
Implement pretty-printing of `..` and update tests.

Update tests to change all `&expr[]` to `&expr[..]` to make sure pretty printing
passes.

9 years agoAuto merge of #21843 - japaric:kindless, r=alexcrichton
bors [Thu, 5 Feb 2015 15:22:48 +0000 (15:22 +0000)]
Auto merge of #21843 - japaric:kindless, r=alexcrichton

This needs a snapshot that includes #21805 before it can be merged.

There are some places where type inference regressed after I removed the annotations (see `FIXME`s). cc @nikomatsakis.

r? @eddyb or anyone
(I'll remove the `FIXME`s before merging, as they are only intended to point out regressions)

9 years agoRemove unused src/doc/trpl/rust-book.css
Kostas Karachalios [Thu, 5 Feb 2015 10:57:06 +0000 (11:57 +0100)]
Remove unused src/doc/trpl/rust-book.css

9 years agoMake the book chapters printable
Kostas Karachalios [Thu, 5 Feb 2015 09:21:06 +0000 (10:21 +0100)]
Make the book chapters printable

Tested on:
* Safari on OSX
* Firefox on OSX

9 years agoAuto merge of #21944 - alexcrichton:lframework, r=eddyb
bors [Thu, 5 Feb 2015 08:47:48 +0000 (08:47 +0000)]
Auto merge of #21944 - alexcrichton:lframework, r=eddyb

On OSX the linker has a separate framework lookup path which is specified via
the `-F` flag. This adds a new kind of `-L` path recognized by the compiler for
frameworks to be passed through to the linker.

Closes #20259

9 years agoAuto merge of #21152 - steveklabnik:tasks, r=huonw
bors [Thu, 5 Feb 2015 03:11:57 +0000 (03:11 +0000)]
Auto merge of #21152 - steveklabnik:tasks, r=huonw

This moves the "Tasks" chapter to a "Concurrency" one, as it's about threads, but also about how to deal with concurrency issues.

r? @aturon

9 years agoA concurrency chapter to replace the tasks chapter.
Steve Klabnik [Wed, 14 Jan 2015 03:06:52 +0000 (22:06 -0500)]
A concurrency chapter to replace the tasks chapter.

Fixes #18936
Fixes #18938
Fixes #20038
Fixes #8395
Fixes #2080
Fixes #21194

9 years agoregister snapshots
Jorge Aparicio [Wed, 4 Feb 2015 23:22:19 +0000 (18:22 -0500)]
register snapshots

9 years agoremove all kind annotations from closures
Jorge Aparicio [Sun, 1 Feb 2015 17:44:15 +0000 (12:44 -0500)]
remove all kind annotations from closures

9 years agoImplement `..` syntax for RangeFull as expression
Ulrik Sverdrup [Wed, 4 Feb 2015 22:23:12 +0000 (23:23 +0100)]
Implement `..` syntax for RangeFull as expression

Allows the expression `..` (without either endpoint) in general, can be
used in slicing syntax `&expr[..]` where we previously wrote `&expr[]`.

The old syntax &expr[] is not yet removed or warned for.

9 years agorustc: Recognize `-L framework=foo`
Alex Crichton [Wed, 4 Feb 2015 21:47:06 +0000 (13:47 -0800)]
rustc: Recognize `-L framework=foo`

On OSX the linker has a separate framework lookup path which is specified via
the `-F` flag. This adds a new kind of `-L` path recognized by the compiler for
frameworks to be passed through to the linker.

Closes #20259

9 years agoAuto merge of #21885 - dotdash:nonnull_load, r=alexcrichton
bors [Wed, 4 Feb 2015 20:03:55 +0000 (20:03 +0000)]
Auto merge of #21885 - dotdash:nonnull_load, r=alexcrichton

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

9 years agoAuto merge of #21544 - P1start:mangle-unicode, r=alexcrichton
bors [Wed, 4 Feb 2015 15:49:43 +0000 (15:49 +0000)]
Auto merge of #21544 - P1start:mangle-unicode, r=alexcrichton

`{` and `}` aren’t valid characters on ARM, so this makes Unicode characters render as, e.g., `$u38d$` instead of `$u{38d}`.

This also fixes a small bug where `)` (**r**ight **p**arenthesis) and `*` (**r**aw **p**ointer) would both mangle to `$RP$`, making `)` show up as `*` in backtraces.

9 years agoAuto merge of #21499 - P1start:issue-8706, r=huonw
bors [Wed, 4 Feb 2015 12:42:40 +0000 (12:42 +0000)]
Auto merge of #21499 - P1start:issue-8706, r=huonw

Closes #8706.

9 years agoAuto merge of #21892 - huonw:deprecate-rand, r=alexcrichton
bors [Wed, 4 Feb 2015 08:47:27 +0000 (08:47 +0000)]
Auto merge of #21892 - huonw:deprecate-rand, r=alexcrichton

Use [`rand`](https://crates.io/crates/rand) and [`derive_rand`](https://crates.io/crates/derive_rand) from crates.io.

[breaking-change]

9 years agoAuto merge of #21919 - alexcrichton:rollup, r=alexcrichton
bors [Wed, 4 Feb 2015 06:40:12 +0000 (06:40 +0000)]
Auto merge of #21919 - alexcrichton:rollup, r=alexcrichton

9 years agoTest fixes and rebase conflicts
Alex Crichton [Wed, 4 Feb 2015 00:39:27 +0000 (16:39 -0800)]
Test fixes and rebase conflicts

9 years agorollup merge of #21910: Manishearth/missing_stability
Alex Crichton [Tue, 3 Feb 2015 23:36:11 +0000 (15:36 -0800)]
rollup merge of #21910: Manishearth/missing_stability

Currently, if a `#![staged_api]` crate contains an exported item without a stability marker (or inherited stability),
the item is useless.

This change introduces a check to ensure that all exported items have a defined stability.

it also introduces the `unmarked_api` feature, which lets users import unmarked features. While this PR should in theory forbid these from existing,
in practice we can't be so sure; so this lets users bypass this check instead of having to wait for the library and/or compiler to be fixed (since otherwise this is a hard error).

r? @aturon

9 years agorollup merge of #21907: alexcrichton/iter-by-ref
Alex Crichton [Tue, 3 Feb 2015 23:36:09 +0000 (15:36 -0800)]
rollup merge of #21907: alexcrichton/iter-by-ref

This removes the `ByRef` iterator adaptor to stay in line with the changes to
`std::io`. The `by_ref` method instead just returns `&mut Self`.

This also removes the implementation of `Iterator for &mut Iterator` and instead
generalizes it to `Iterator for &mut I` where `I: Iterator + ?Sized`. The
`Box<I>` implementations were also updated.

9 years agorollup merge of #21899: nikomatsakis/closure-unify-anyhow
Alex Crichton [Tue, 3 Feb 2015 23:36:07 +0000 (15:36 -0800)]
rollup merge of #21899: nikomatsakis/closure-unify-anyhow

This *almost* completes the job for #16440. The idea is that even if we do not know whether some closure type `C` implements `Fn` or `FnMut` (etc), we still know its argument and return types. So if we see an obligation `C : Fn(_0)`, we can unify `_0` with those argument types while still considering the obligation ambiguous and unsatisfied. This helps to make a lot of progress with type inference even before closure kind inference is done.

As part of this PR, the explicit `:` syntax is removed from the AST and completely ignored. We still infer the closure kind based on the expected type if that is available. There are several reasons for this. First, deciding the closure kind earlier is always better, as it allows us to make more progress. Second, this retains a (admittedly obscure) way for users to manually specify the closure kind, which is useful for writing tests if nothing else. Finally, there are still some cases where inference can fail, so it may be useful to have this manual override. (The expectation is that we will eventually revisit an explicit syntax for specifying the closure kind, but it will not be `:` and may be some sort of generalization of the `||` syntax to handle other traits as well.)

This commit does not *quite* fix #16640 because a snapshot is still needed to enable the obsolete syntax errors for explicit `&mut:` and friends.

r? @eddyb as he reviewed the prior patch in this direction

9 years agorollup merge of #21897: dotdash/rposition
Alex Crichton [Tue, 3 Feb 2015 23:36:04 +0000 (15:36 -0800)]
rollup merge of #21897: dotdash/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 agorollup merge of #21893: vhbit/ios-build-fix
Alex Crichton [Tue, 3 Feb 2015 23:36:01 +0000 (15:36 -0800)]
rollup merge of #21893: vhbit/ios-build-fix

9 years agoFix Unicode name mangling
P1start [Thu, 22 Jan 2015 07:12:57 +0000 (20:12 +1300)]
Fix Unicode name mangling

`{` and `}` aren’t valid characters on ARM.

This also fixes a small bug where `)` (**r**ight **p**arenthesis) and `*`
(**r**aw **p**ointer) would both mangle to `$RP$`, making `)` show up as `*` in
backtraces.

9 years agorollup merge of #21882: Gankro/vec_entry
Alex Crichton [Tue, 3 Feb 2015 23:35:57 +0000 (15:35 -0800)]
rollup merge of #21882: Gankro/vec_entry

Building over night, posting for review now. Presumably not much should need change.

I consider this necessary to move forward with a proper stabilization of the API.

r? @huonw

9 years agorollup merge of #21870: alexcrichton/missing-stability
Alex Crichton [Tue, 3 Feb 2015 23:35:55 +0000 (15:35 -0800)]
rollup merge of #21870: alexcrichton/missing-stability

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

9 years agorollup merge of #21835: alexcrichton/iov2
Alex Crichton [Tue, 3 Feb 2015 23:35:54 +0000 (15:35 -0800)]
rollup merge of #21835: alexcrichton/iov2

This commit is an implementation of [RFC 576][rfc] which adds back the `std::io`
module to the standard library. No functionality in `std::old_io` has been
deprecated just yet, and the new `std::io` module is behind the same `io`
feature gate.

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

A good bit of functionality was copied over from `std::old_io`, but many tweaks
were required for the new method signatures. Behavior such as precisely when
buffered objects call to the underlying object may have been tweaked slightly in
the transition. All implementations were audited to use composition wherever
possible. For example the custom `pos` and `cap` cursors in `BufReader` were
removed in favor of just using `Cursor<Vec<u8>>`.

A few liberties were taken during this implementation which were not explicitly
spelled out in the RFC:

* The old `LineBufferedWriter` is now named `LineWriter`
* The internal representation of `Error` now favors OS error codes (a
  0-allocation path) and contains a `Box` for extra semantic data.
* The io prelude currently reexports `Seek` as `NewSeek` to prevent conflicts
  with the real prelude reexport of `old_io::Seek`
* The `chars` method was moved from `BufReadExt` to `ReadExt`.
* The `chars` iterator returns a custom error with a variant that explains that
  the data was not valid UTF-8.

9 years agorollup merge of #21759: aturon/new-path
Alex Crichton [Tue, 3 Feb 2015 23:35:53 +0000 (15:35 -0800)]
rollup merge of #21759: aturon/new-path

This PR implements [path reform](https://github.com/rust-lang/rfcs/pull/474), and motivation and details for the change can be found there.

For convenience, the old path API is being kept as `old_path` for the time being. Updating after this PR is just a matter of changing imports to `old_path` (which is likely not needed, since the prelude entries still export the old path API).

This initial PR does not include additional normalization or platform-specific path extensions. These will be done in follow up commits or PRs.

[breaking-change]

Closes #20034
Closes #12056
Closes #11594
Closes #14028
Closes #14049
Closes #10035

9 years agoAdd new path module
Aaron Turon [Thu, 29 Jan 2015 22:33:11 +0000 (14:33 -0800)]
Add new path module

Implements [RFC 474](https://github.com/rust-lang/rfcs/pull/474); see
that RFC for details/motivation for this change.

This initial commit does not include additional normalization or
platform-specific path extensions. These will be done in follow up
commits or PRs.

9 years agoDeprecate in-tree `rand`, `std::rand` and `#[derive(Rand)]`.
Huon Wilson [Tue, 3 Feb 2015 09:11:38 +0000 (20:11 +1100)]
Deprecate in-tree `rand`, `std::rand` and `#[derive(Rand)]`.

Use the crates.io crate `rand` (version 0.1 should be a drop in
replacement for `std::rand`) and `rand_macros` (`#[derive_Rand]` should
be a drop-in replacement).

[breaking-change]

9 years agoRename std::path to std::old_path
Aaron Turon [Thu, 29 Jan 2015 22:03:36 +0000 (14:03 -0800)]
Rename std::path to std::old_path

As part of [RFC 474](https://github.com/rust-lang/rfcs/pull/474), this
commit renames `std::path` to `std::old_path`, leaving the existing path
API in place to ease migration to the new one. Updating should be as
simple as adjusting imports, and the prelude still maps to the old path
APIs for now.

[breaking-change]

9 years agoMore test fixes
Manish Goregaokar [Tue, 3 Feb 2015 22:16:36 +0000 (03:46 +0530)]
More test fixes

9 years agoDon't check stability for tests
Manish Goregaokar [Tue, 3 Feb 2015 21:51:10 +0000 (03:21 +0530)]
Don't check stability for tests

9 years agoFix test
Manish Goregaokar [Tue, 3 Feb 2015 21:50:12 +0000 (03:20 +0530)]
Fix test

9 years agoAdd staged_api and unmarked_api features to reference.md
Manish Goregaokar [Tue, 3 Feb 2015 19:56:15 +0000 (01:26 +0530)]
Add staged_api and unmarked_api features to reference.md

9 years agoAdd unmarked_api feature (fixes #21884)
Manish Goregaokar [Tue, 3 Feb 2015 19:51:26 +0000 (01:21 +0530)]
Add unmarked_api feature (fixes #21884)

9 years agoAdd test for missing stability checker
Manish Goregaokar [Tue, 3 Feb 2015 19:00:54 +0000 (00:30 +0530)]
Add test for missing stability checker

9 years agoFix some missing stability attrs
Manish Goregaokar [Tue, 3 Feb 2015 18:45:28 +0000 (00:15 +0530)]
Fix some missing stability attrs

9 years agoError when #![staged_api] crates are missing stability markers
Manish Goregaokar [Tue, 3 Feb 2015 16:34:13 +0000 (22:04 +0530)]
Error when #![staged_api] crates are missing stability markers

9 years agostd: Add `io` module again
Alex Crichton [Sun, 1 Feb 2015 04:24:36 +0000 (20:24 -0800)]
std: Add `io` module again

This commit is an implementation of [RFC 576][rfc] which adds back the `std::io`
module to the standard library. No functionality in `std::old_io` has been
deprecated just yet, and the new `std::io` module is behind the same `io`
feature gate.

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

A good bit of functionality was copied over from `std::old_io`, but many tweaks
were required for the new method signatures. Behavior such as precisely when
buffered objects call to the underlying object may have been tweaked slightly in
the transition. All implementations were audited to use composition wherever
possible. For example the custom `pos` and `cap` cursors in `BufReader` were
removed in favor of just using `Cursor<Vec<u8>>`.

A few liberties were taken during this implementation which were not explicitly
spelled out in the RFC:

* The old `LineBufferedWriter` is now named `LineWriter`
* The internal representation of `Error` now favors OS error codes (a
  0-allocation path) and contains a `Box` for extra semantic data.
* The io prelude currently reexports `Seek` as `NewSeek` to prevent conflicts
  with the real prelude reexport of `old_io::Seek`
* The `chars` method was moved from `BufReadExt` to `ReadExt`.
* The `chars` iterator returns a custom error with a variant that explains that
  the data was not valid UTF-8.

9 years agostd: Remove `iter::ByRef` and generalize impls
Alex Crichton [Tue, 3 Feb 2015 20:32:56 +0000 (12:32 -0800)]
std: Remove `iter::ByRef` and generalize impls

This removes the `ByRef` iterator adaptor to stay in line with the changes to
`std::io`. The `by_ref` method instead just returns `&mut Self`.

This also removes the implementation of `Iterator for &mut Iterator` and instead
generalizes it to `Iterator for &mut I` where `I: Iterator + ?Sized`. The
`Box<I>` implementations were also updated.

This is a breaking change due to the removal of the `std::iter::ByRef` type. All
mentions of `ByRef<'a, T>` should be replaced with `&mut T` to migrate forward.

[breaking-change]

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