Commit Graph

8178 Commits

Author SHA1 Message Date
kennytm
396dda0a6a
Rollup merge of #53062 - ljedrz:redundant_field_names, r=Mark-Simulacrum
Remove redundant field names in structs
2018-08-04 23:09:12 +08:00
ljedrz
d46dca66c9 Remove redundant field names in structs 2018-08-04 14:58:20 +02:00
kennytm
52db0ed161
Rollup merge of #51919 - tbu-:pr_num_to_from_bytes2, r=SimonSapin
Provide `{to,from}_{ne,le,be}_bytes` functions on integers

If one doesn't view integers as containers of bytes, converting them to
bytes necessarily needs the specfication of encoding.

I think Rust is a language that wants to be explicit. The `to_bytes`
function is basically the opposite of that – it converts an integer into
the native byte representation, but there's no mention (in the function
name) of it being very much platform dependent. Therefore, I think it
would be better to replace that method by three methods, the explicit
`to_ne_bytes` ("native endian") which does the same thing and
`to_{le,be}_bytes` which return the little- resp. big-endian encoding.
2018-08-04 17:19:38 +08:00
Tobias Bucher
0ddfae5ba2 Change tracking issue from #49792 to #51919
The old issue has already been in FCP, a new issue was opened for the
new API.
2018-08-04 08:36:54 +02:00
Ralf Jung
71460d4d11 volatile operations docs: clarify that this does not help wrt. concurrency 2018-08-03 12:15:00 +02:00
Tobias Bucher
a04b2cda0b Provide {to,from}_{ne,le,be}_bytes functions on integers
If one doesn't view integers as containers of bytes, converting them to
bytes necessarily needs the specfication of encoding.

I think Rust is a language that wants to be explicit. The `to_bytes`
function is basically the opposite of that – it converts an integer into
the native byte representation, but there's no mention (in the function
name) of it being very much platform dependent. Therefore, I think it
would be better to replace that method by three methods, the explicit
`to_ne_bytes` ("native endian") which does the same thing and
`to_{le,be}_bytes` which return the little- resp. big-endian encoding.
2018-08-03 07:55:10 +02:00
bors
03da14ba8c Auto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichton
Switch to bootstrapping from 1.29 beta

r? @alexcrichton
2018-08-02 15:34:21 +00:00
bors
1d9405fb6c Auto merge of #52206 - RalfJung:zst-slices, r=alexcrichton
slices: fix ZST slice iterators making up pointers; debug_assert alignment in from_raw_parts

This fixes the problem that we are fabricating pointers out of thin air. I also managed to share more code between the mutable and shared iterators, while reducing the amount of macros.

I am not sure how useful it really is to add a `debug_assert!` in libcore. Everybody gets a release version of that anyway, right? Is there at least a CI job that runs the test suite with a debug version?

Fixes #42789
2018-08-02 00:14:21 +00:00
Ralf Jung
9fcf2c9726 use the same length computation everywhere 2018-08-02 00:33:04 +02:00
Ralf Jung
e1471cf41f Introduce another way to compute the length, to fix position codegen regression 2018-08-02 00:33:04 +02:00
Ralf Jung
b0a82d9314 simplify len macro: No longer require the type
Also use ident, not expr, to avoid accidental side-effects
2018-08-02 00:33:04 +02:00
Ralf Jung
3e3ff4b652 macro-inline len() and is_empty() to fix performance regressions
This also changes the IR for nth(), but the new IR actually looks nicer that the old
(and it is one instruction shorter).
2018-08-02 00:33:03 +02:00
Ralf Jung
1b3c6bac8b make the code for nth closer to what it used to be 2018-08-02 00:33:03 +02:00
Ralf Jung
60b06369ee test nth better 2018-08-02 00:33:03 +02:00
Ralf Jung
cbdba2b4c2 use wrapping_offset; fix logic error in nth 2018-08-02 00:33:03 +02:00
Ralf Jung
c7d90d1a50 comments 2018-08-02 00:33:03 +02:00
Ralf Jung
86369c3ad4 slice iterators: ZST iterators no longer just "make up" addresses 2018-08-02 00:29:12 +02:00
bors
97085f9fb0 Auto merge of #52958 - pietroalbini:rollup, r=pietroalbini
Rollup of 15 pull requests

Successful merges:

 - #52793 (Add test for NLL: unexpected "free region `` does not outlive" error )
 - #52799 (Use BitVector for global sets of AttrId)
 - #52809 (Add test for unexpected region for local data ReStatic)
 - #52834 ([NLL] Allow conflicting borrows of promoted length zero arrays)
 - #52835 (Fix Alias intra doc ICE)
 - #52854 (fix memrchr in miri)
 - #52899 (tests/ui: Add missing mips{64} ignores)
 - #52908 (Use SetLenOnDrop in Vec::truncate())
 - #52915 (Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator)
 - #52926 (rustc: Trim down the `rust_2018_idioms` lint group)
 - #52930 (rustc_resolve: record single-segment extern crate import resolutions.)
 - #52939 (Make io::Read::read_to_end consider io::Take::limit)
 - #52942 (Another SmallVec.extend optimization)
 - #52947 (1.27 actually added the `armv5te-unknown-linux-musleabi` target)
 - #52954 (async can begin expressions)

Failed merges:

r? @ghost
2018-08-01 19:54:06 +00:00
Pietro Albini
e3928ccb2f
Rollup merge of #52854 - RalfJung:memrchr, r=Kimundi
fix memrchr in miri

The previous PR https://github.com/rust-lang/rust/pull/52744 was not enough because it assumed that the split between the `mid` and `end` parts returned by `align_to` was aligned. But really the only guarantee we have is that the `mid` part is aligned, so make use of that.
2018-08-01 21:46:28 +02:00
Mark Rousskov
683a3db01f Switch to bootstrapping from 1.29 beta 2018-08-01 11:59:08 -06:00
bors
c4156768aa Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichton
Treat gc=No characters as numeric

[`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.
2018-08-01 17:44:25 +00:00
Pietro Albini
ac2b3c3712
Rollup merge of #52905 - pravic:unsize-typo, r=alexcrichton
Fix a typo in unsize.rs

RfC -> RFC
2018-08-01 10:13:05 +02:00
Pietro Albini
341f882462
Rollup merge of #52870 - cramertj:unpin-futureobj, r=aturon
Implement Unpin for FutureObj and LocalFutureObj

cc @MajorBreakfast

r? @aturon
2018-08-01 10:12:57 +02:00
Pietro Albini
9e43ebda53
Rollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj
Fix From<LocalWaker>

This is a follow-up to https://github.com/rust-lang/rust/pull/52640

Fixes `From<LocalWaker>` which is affected by the same accidental drop bug (unless I'm totally mistaken)

r? @cramertj
2018-08-01 10:12:44 +02:00
Pietro Albini
acff794b68
Rollup merge of #52732 - SimonSapin:spring, r=Mark-Simulacrum
Remove unstable and deprecated APIs
2018-08-01 10:12:36 +02:00
pravic
830ac8c87f
Fix a typo in unsize.rs
RfC -> RFC
2018-07-31 16:28:50 +03:00
bors
ed8d14db99 Auto merge of #50267 - humanenginuity:master, r=alexcrichton
Implement inner deref for Option and Result

tracking issue: #50264
2018-07-31 11:20:16 +00:00
Taylor Cramer
cbbcecbee0 Implement Unpin for FutureObj and LocalFutureObj 2018-07-30 09:42:34 -07:00
Simon Sapin
4ca77f702f Remove unstable and deprecated APIs 2018-07-30 18:18:23 +02:00
Ralf Jung
6d5694a021 fix memrchr in miri 2018-07-30 14:00:12 +02:00
Simon Sapin
f162438fb3 Revert "Stabilize to_bytes and from_bytes for integers."
This reverts commit c8f9b84b39.
2018-07-30 11:55:20 +02:00
Brad Gibson
56016cb1e0 resolved upstream merge conflicts 2018-07-29 22:13:12 -07:00
bors
023fd7e74a Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkov
Prefer to_string() to format!()

Simple benchmarks suggest in some cases it can be faster by even 37%:
```
test converting_f64_long  ... bench:         339 ns/iter (+/- 199)
test converting_f64_short ... bench:         136 ns/iter (+/- 34)
test converting_i32_long  ... bench:          87 ns/iter (+/- 16)
test converting_i32_short ... bench:          87 ns/iter (+/- 49)
test converting_str       ... bench:          54 ns/iter (+/- 15)
test formatting_f64_long  ... bench:         349 ns/iter (+/- 176)
test formatting_f64_short ... bench:         145 ns/iter (+/- 14)
test formatting_i32_long  ... bench:          98 ns/iter (+/- 14)
test formatting_i32_short ... bench:          93 ns/iter (+/- 15)
test formatting_str       ... bench:          86 ns/iter (+/- 23)
```
2018-07-29 09:33:37 +00:00
Josef Reinhard Brandl
ea25cf1cc6 Fix From<LocalWaker> 2018-07-29 10:45:17 +02:00
bors
a5c2d0fffa Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakis
Misc cleanups
2018-07-29 06:32:24 +00:00
bors
d754582005 Auto merge of #52744 - RalfJung:align_offset, r=Kimundi
make memrchr use align_offset

I hope I did not screw that up...

Cc @oli-obk who authored the original https://github.com/rust-lang/rust/pull/44537

Fixes #50567 (thanks @bjorn3)
2018-07-28 16:44:21 +00:00
bors
26e73dabeb Auto merge of #52711 - eddyb:unsized-manuallydrop, r=nikomatsakis
Change ManuallyDrop<T> to a lang item.

This PR implements the approach @RalfJung proposes in https://internals.rust-lang.org/t/pre-rfc-unions-drop-types-and-manuallydrop/8025 (lang item `struct` instead of `union`).

A followup PR can easily solve #47034 as well, by just adding a few `?Sized` to `libcore/mem.rs`.

r? @nikomatsakis
2018-07-28 14:26:16 +00:00
kennytm
f22c03fb57
Rollup merge of #52777 - omni-viral:master, r=TimNN
Fix doc comment for 'ptr::copy_to' method

Fix error in doc comment for `ptr::copy_to` method.
2018-07-28 16:25:05 +08:00
bors
4f1e235744 Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrum
Rollup of bare_trait_objects PRs

All deny attributes were moved into bootstrap so they can be disabled with a line of config.

Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free.

r? @Mark-Simulacrum
cc @ljedrz @kennytm
2018-07-27 20:27:40 +00:00
Shotaro Yamada
3525368a56 Use str::repeat 2018-07-27 23:26:36 +09:00
Zakarum
e25c3e2f16 Fix doc comment for 'ptr::copy_to' method 2018-07-27 15:26:57 +03:00
Ralf Jung
5feedbd9f8 add smoke test for ManuallyDrop 2018-07-27 12:22:26 +02:00
Ralf Jung
3bc59b5205 use slice::align_to 2018-07-27 11:54:38 +02:00
ljedrz
57a5a9b054 Prefer to_string() to format!() 2018-07-27 11:11:18 +02:00
Ralf Jung
70cb75c31e make memrchr use align_offset 2018-07-26 18:29:38 +02:00
Mark Rousskov
858adfe21d
Rollup merge of #52721 - cramertj:try-poll, r=aturon
std::ops::Try impl for std::task::Poll

I originally left out the `Try` impl for `Poll` because I was curious if we needed it, and @MajorBreakfast and I had discussed the potential for it to introduce confusion about exactly what control-flow was happening at different points. However, after porting a pretty significant chunk of Fuchsia over to futures 0.3, I discovered that I was *constantly* having to do repetitive matching on `Poll<Result<...>>` or `Poll<Option<Result<...>>>` in order to propagate errors correctly. `try_poll` (propagate `Poll::Ready(Err(..))`s) helped in some places, but it was far more common to need some form of conversion between `Result`, `Poll<Result<...>>`, and `Poll<Option<Result<...>>>`. The `Try` trait conveniently provides all of these conversions in addition to a more concise syntax (`?`), so I'd like to experiment with using these instead.

cc @seanmonstar

r? @aturon

Note: this change means that far more futures 0.1 code can work without significant changes since it papers over the fact that `Result` is no longer at the top-level when using `Stream` and `Future` (since it's now `Poll<Result<...>>` or `Poll<Option<Result<...>>>` instead of `Result<Poll<..>>` and `Result<Poll<Option<...>>>`).
2018-07-26 09:18:40 -06:00
Mark Rousskov
0127704c98
Rollup merge of #52610 - MajorBreakfast:task-terminology, r=cramertj
Clarify what a task is

Currently we call two distinct concepts "task":
1. The top-level future that is polled until completion
2. The lightweight "thread" that is responsible for polling the top-level future. What additional data beside the future is stored in this type varies between different `Executor` implementations.

I'd prefer to return to the old formulation by @alexcrichton:
```rust
/// A handle to a "task", which represents a single lightweight "thread" of
/// execution driving a future to completion.
pub struct Task {
```
Source: [`task_impl/mod.rs` in futures-rs 0.1](1328fc9e8a/src/task_impl/mod.rs (L49-L50))

I think that this change will make it much easier to explain everything.

r? @aturon
@cramertj
2018-07-26 09:18:25 -06:00
Taylor Cramer
bce8a91f34 std::ops::Try impl for std::task::Poll 2018-07-25 17:26:12 -07:00
Eduard-Mihai Burtescu
591eeff22a Change ManuallyDrop from an union to a struct and make it a lang item. 2018-07-25 21:01:02 +03:00
Josef Reinhard Brandl
eacfd72522 Clarify what a task is 2018-07-25 13:39:14 +02:00