Commit Graph

76143 Commits

Author SHA1 Message Date
Felix S. Klock II
347cf21290 Remove adjacent all-const match arm hack.
An old fix for moves-in-guards had a hack for adjacent all-const match arms.

The hack was explained in a comment, which you can see here:
https://github.com/rust-lang/rust/pull/22580/files#diff-402a0fa4b3c6755c5650027c6d4cf1efR497

But hack was incomplete (and thus unsound), as pointed out here:
https://github.com/rust-lang/rust/issues/47295#issuecomment-357108458

Plus, it is likely to be at least tricky to reimplement this hack in
the new NLL borrowck.

So rather than try to preserve the hack, we want to try to just remove
it outright. (At least to see the results of a crater run.)

[breaking-change]

This is a breaking-change, but our hope is that no one is actually
relying on such an extreme special case. (We hypothesize the hack was
originally added to accommodate a file in our own test suite, not code
in the wild.)
2018-03-28 12:03:28 +02:00
bors
3efe61c825 Auto merge of #49305 - SimonSapin:fallible, r=sfackler
Stabilize TryFrom / TryInto, and tweak impls for integers

Fixes https://github.com/rust-lang/rust/issues/33417 (tracking issue)

----

This adds:

* `impl From<u16> for usize`
* `impl From<i16> for isize`
* `impl From<u8> for isize`

… replacing corresponding `TryFrom<Error=!>` impls. (`TryFrom` still applies through the generic `impl<T, U> TryFrom<U> for T where T: From<U>`.) Their infallibility is supported by the C99 standard which (indirectly) requires pointers to be at least 16 bits.

The remaining `TryFrom` impls that define `type Error = !` all involve `usize` or `isize`. This PR changes them to use `TryFromIntError` instead, since having a return type change based on the target is a portability hazard.

Note: if we make similar assumptions about the *maximum* bit size of pointers (for all targets Rust will ever run on in the future), we could have similar `From` impls converting pointer-sized integers to large fixed-size integers. RISC-V considers the possibility of a 128-bit address space (RV128), which would leave only `impl From<usize> for u128` and `impl From<isize> for u128`. I [found](https://www.cl.cam.ac.uk/research/security/ctsrd/pdfs/20171017a-cheri-poster.pdf) some [things](http://www.csl.sri.com/users/neumann/2012resolve-cheri.pdf) about 256-bit “capabilities”, but I don’t know how relevant that would be to Rust’s `usize` and `isize` types.

I chose conservatively to make no assumption about the future there. Users making their portability decisions and using something like `.try_into().unwrap()`.

----

Since this feature already went through FCP in the tracking issue https://github.com/rust-lang/rust/issues/33417, this PR also proposes **stabilize** the following items:

* The `convert::TryFrom` trait
* The `convert::TryFrom` trait
* `impl<T> TryFrom<&[T]> for &[T; $N]` (for `$N` up to 32)
* `impl<T> TryFrom<&mut [T]> for &mut [T; $N]` (for `$N` up to 32)
* The `array::TryFromSliceError` struct, with impls of `Debug`, `Copy`, `Clone`, and `Error`
* `impl TryFrom<u32> for char`
* The `char::CharTryFromError` struct, with impls of `Copy`, `Clone`, `Debug`, `PartialEq`, `Eq`, `Display`, and `Error`
* Impls of `TryFrom` for all (?) combinations of primitive integer types where `From` isn’t implemented.
* The `num::TryFromIntError` struct, with impls of `Debug`, `Copy`, `Clone`, `Display`, `From<!>`, and `Error`

Some minor remaining questions that I hope can be resolved in this PR:

* Should the impls for error types be unified?
* ~Should `TryFrom` and `TryInto` be in the prelude? `From` and `Into` are.~ (Yes.)
2018-03-27 11:50:10 +00:00
Simon Sapin
837d6c7023 Remove TryFrom impls that might become conditionally-infallible with a portability lint
https://github.com/rust-lang/rust/pull/49305#issuecomment-376293243
2018-03-27 09:48:42 +02:00
bors
14ac1b5faa Auto merge of #49279 - varkor:generated-closure-return-type, r=alexcrichton
Fix implicit closure return type generation for libsyntax

The `lambda` function for constructing closures in libsyntax was explicitly setting the return type to `_`, which resulted in incorrect corresponding syntax (as `|| -> _ x` is not valid, without the enclosing brackets). This meant the generated code, when printed, was invalid.

I also took the opportunity to slightly improve the generated code for the `RustcEncodable::encode` method for unit structs.

Fixes #42213.
2018-03-27 07:16:29 +00:00
bors
31ae4f9fde Auto merge of #49249 - gnzlbg:simd_minmax, r=alexcrichton
implement minmax intrinsics

This adds the `simd_{fmin,fmax}` intrinsics, which do a vertical (lane-wise) `min`/`max` for floating point vectors that's equivalent to Rust's `min`/`max` for `f32`/`f64`.

It might make sense to make `{f32,f64}::{min,max}` use the `minnum` and `minmax` intrinsics as well.

---

~~HELP: I need some help with these. Either I should go to sleep or there must be something that I must be missing. AFAICT I am calling the `maxnum` builder correctly, yet rustc/LLVM seem to insert a call to `llvm.minnum` there instead...~~ EDIT: Rust's LLVM version is too old :/
2018-03-27 04:46:32 +00:00
Simon Sapin
09008cc23f Add TryFrom and TryInto to the prelude 2018-03-26 23:36:04 +02:00
Simon Sapin
e53a2a7274 Stabilize the TryFrom and TryInto traits
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-26 23:36:02 +02:00
Simon Sapin
9fd399feb1 Don’t use type Error = ! for target-dependant TryFrom impls.
Instead, expose apparently-fallible conversions in cases where
the implementation happens to be infallible for a given target.

Having an associated type / return type in a public API change
based on the target is a portability hazard.
2018-03-26 23:34:22 +02:00
Simon Sapin
2178ef8b22 TryFrom for integers: use From instead for truely-infallible impls
There is precendent in C for having a minimum pointer size, but I don’t feel confident enough about the future to mandate a maximum.
2018-03-26 23:34:22 +02:00
bors
989b25718b Auto merge of #49053 - alexcrichton:fail-if-build-cargo-twice, r=Mark-Simulacrum
rustbuild: Fail the build if we build Cargo twice

This commit updates the `ToolBuild` step to stream Cargo's JSON messages, parse
them, and record all libraries built. If we build anything twice (aka Cargo)
it'll most likely happen due to dependencies being recompiled which is caught by
this check.
2018-03-26 21:21:33 +00:00
Alex Crichton
faebcc1087 rustbuild: Fail the build if we build Cargo twice
This commit updates the `ToolBuild` step to stream Cargo's JSON messages, parse
them, and record all libraries built. If we build anything twice (aka Cargo)
it'll most likely happen due to dependencies being recompiled which is caught by
this check.
2018-03-26 13:07:12 -07:00
bors
188e693b39 Auto merge of #49101 - mark-i-m:stabilize_i128, r=nagisa
Stabilize 128-bit integers 🎉

cc #35118

EDIT: This should be merged only after the following have been merged:
- [x] https://github.com/rust-lang-nursery/compiler-builtins/pull/236
- [x] https://github.com/rust-lang/book/pull/1230
2018-03-26 18:41:38 +00:00
bors
ab8b961677 Auto merge of #49379 - TimNN:rollup, r=TimNN
Rollup of 7 pull requests

- Successful merges: #48693, #48932, #49103, #49170, #49187, #49346, #49353
- Failed merges:
2018-03-26 15:48:06 +00:00
Mark Mansi
140bf949bf fix last two tidy 2018-03-26 08:37:56 -05:00
Mark Mansi
6b625b3341 did i get it right now? 2018-03-26 08:37:56 -05:00
Mark Mansi
66c8cdbab4 Update to master of libcompiler_builtins 2018-03-26 08:37:56 -05:00
Mark Mansi
ec9871818b Remove library feature test 2018-03-26 08:37:56 -05:00
Mark Mansi
afc9890309 Fix e0658 ui test 2018-03-26 08:37:56 -05:00
Mark Mansi
1fd964b5cb update test 2018-03-26 08:37:56 -05:00
Mark Mansi
463865e695 Fix a few more unstables that I missed 2018-03-26 08:37:56 -05:00
Mark Mansi
a7f21f1c0a Fix a few more 2018-03-26 08:37:56 -05:00
Mark Mansi
07104692d5 Fix missed i128 feature gates 2018-03-26 08:37:56 -05:00
Mark Mansi
ea89b507b3 remove unneeded import 2018-03-26 08:37:56 -05:00
Mark Mansi
a249d25625 Rename unstable book correctly 2018-03-26 08:37:56 -05:00
Mark Mansi
a89d1d0b02 Rename unstable-book chapter 2018-03-26 08:37:56 -05:00
Mark Mansi
db7d9ea480 Stabilize i128 feature too 2018-03-26 08:37:56 -05:00
Mark Mansi
33d9d8e0c6 Update nightly book 2018-03-26 08:36:50 -05:00
Mark Mansi
7ce8191775 Stabilize i128_type 2018-03-26 08:36:50 -05:00
Tim Neumann
1233aa29de
Rollup merge of #49353 - chisophugis:patch-1, r=Mark-Simulacrum
Fix confusing doc for `scan`

The comment "the value passed on to the next iteration" confused me since it sounded more like what Haskell's [scanl](http://hackage.haskell.org/package/base-4.11.0.0/docs/Prelude.html#v:scanl) does where the closure's return value serves as both the "yielded value" *and* the new value of the "state".

I tried changing the example to make it clear that the closure's return value is decoupled from the state argument.
2018-03-26 15:15:01 +02:00
Tim Neumann
d601e74675
Rollup merge of #49346 - Diggsey:hashmap-get-pair, r=Mark-Simulacrum
Implement get_key_value for HashMap, BTreeMap

Fixes #43143

Follow up from #46992
2018-03-26 15:14:59 +02:00
Tim Neumann
bd3db2bf2c
Rollup merge of #49187 - alexcrichton:no-cross-docs, r=kennytm
rustbuild: Disable docs on cross-compiled builds

This commit disables building documentation on cross-compiled compilers, for
example ARM/MIPS/PowerPC/etc. Currently I believe we're not getting much use out
of these documentation artifacts and they often take 10-15 minutes total to
build as it requires building rustdoc/rustbook and then also generating all the
documentation, especially for the reference and the book itself.

In an effort to cut down on the amount of work that we're doing on dist CI
builders in light of recent timeouts this was some relatively low hanging fruit
to cut which in theory won't have much impact on the ecosystem in the hopes that
the documentation isn't used too heavily anyway.

While initial analysis in #48827 showed only shaving 5 minutes off local builds
the same 5 minute conclusion was drawn from #48826 which ended up having nearly
a half-hour impact on the bots. In that sense I'm hoping that we can land this
and test out what happens on CI to see how it affects timing.

Note that all tier 1 platforms, Windows, Mac, and Linux, will continue to
generate documentation.
2018-03-26 15:14:58 +02:00
Tim Neumann
9e4d5cf0ce
Rollup merge of #49170 - steveklabnik:gh49127, r=nagisa
Clarify AcqRel's docs

This implied things that are not true.

Fixes #49127
2018-03-26 15:14:57 +02:00
Tim Neumann
fc9dfda6ad
Rollup merge of #49103 - glandium:uninitialized, r=cramertj
Use an uninitialized buffer in GenericRadix::fmt_int, like in Display::fmt for numeric types

The code using a slice of that buffer is only ever going to use
bytes that are subsequently initialized.
2018-03-26 15:14:56 +02:00
Tim Neumann
571734fdd7
Rollup merge of #48932 - Phlosioneer:43601-document-opaque-size, r=KodrAus
Document when types have OS-dependent sizes

As per issue #43601, types that can change size depending on the
target operating system should say so in their documentation.

I used this template when adding doc comments:

```
The size of a(n) <name> struct may vary depending on the target
operating system, and may change between Rust releases.
```

For enums, I used "instance" instead of "struct".

I added documentation to these types:
```
- std::time::Instant						(contains sys::time::Instant)
- std::time::SystemTime						(contains sys::time::SystemTime)

- std::io::StdinRaw							(contains sys::stdio::Stdin)
- std::io::StdoutRaw						(contains sys::stdio::Stdout)
- std::io::Stderr							(contains sys::stdio::Stderr)

- std::net::addr::SocketAddrV4				(contains sys::net::netc::sockaddr_in)
- std::net::addr::SocketAddrV6				(contains sys::net::netc::sockaddr_in6)
- std::net::addr::SocketAddr				(contains std::net::addr::SocketAddrV4 and SocketAddrV6)
- std::net::ip::Ipv4Addr					(contains sys::net::netc::in_addr)
- std::net::ip::Ipv6Addr					(contains sys::net::netc::in6_addr)
- std::net::ip::IpAddr						(contains std::net::ip::Ipv4Addr and Ipv6Addr)
```

I also found that these types varied in size; however, I don't think they need documentation, as it's already fairly obvious that they change based on different OS's:

```
- std::fs::DirBuilder						(contains sys::fs::DirBuilder)
- std::fs::FileType							(contains sys::fs::FileType)
- std::fs::Permissions						(contains sys::fs::FilePermissions)
- std::fs::OpenOptions						(contains sys::fs::OpenOptions)
- std::fs::DirEntry							(contains sys::fs::DirEntry)
- std::fs::ReadDir							(contains sys::fs::ReadDir)
- std::fs::Metadata							(contains sys::fs::FileAttr)
- std::fs::File								(contains sys::fs::File)

- std::process::Child						(contains sys::process::Process)
- std::process::ChildStdin					(contains sys::process::AnonPipe)
- std::process::ChildStdout					(contains sys::process::AnonPipe)
- std::process::ChildStderr					(contains sys::process::AnonPipe)
- std::process::Command						(contains sys::process::Command)
- std::process::Stdio						(contains sys::process::Stdio)
- std::process::ExitStatus					(contains sys::process::ExitStatus)
- std::process::Output						(contains std::process::ExitStatus)

- std::sys_common::condvar::Condvar			(contains sys::condvar::Condvar)
- std::sys_common::mutex::Mutex				(contains sys::mutex::Mutex)
- std::sys_common::net::LookupHost			(contains sys::net::netc::addrinfo)
- std::sys_common::net::TcpStream			(contains sys::net::Socket)
- std::sys_common::net::TcpListener			(contains sys::net::Socket)
- std::sys_common::net::UdpSocket			(contains sys::net::Socket)
- std::sys_common::remutex::ReentrantMutex	(contains sys::mutex::ReentrantMutex)
- std::sys_common::rwlock::RWLock			(contains sys::rwlock::RWLock)
- std::sys_common::thread_local::Key		(contains sys::thread_local::Key)
```
Maybe we should just put a comment about the size of structs in the module-level docs for `fs`, `process`, and `sys_common`?

If anyone can think of other types that can change size, comment below. I'm also open to changing the wording.

closes #43601.
2018-03-26 15:14:54 +02:00
Tim Neumann
3d7a04610d
Rollup merge of #48693 - vorner:doc-name-resolution, r=petrochenkov
Some comments and documentation for name resolution crate

Hello

I'm trying to get a grasp of how the name resolution crate works, as part of helping with https://github.com/rust-lang-nursery/rustc-guide/issues/16. Not that I'd be succeeding much, but as I was reading the code, I started to put some notes into it, to help me understand.

I guess I didn't get very far yet, but I'd like to share what I have, in case it might be useful for someone else. I hope these are correct (even if incomplete), but I'll be glad for a fast check in case I put something misleading there.
2018-03-26 15:14:50 +02:00
bors
13a86f4d85 Auto merge of #48346 - emilio:pgo, r=alexcrichton
Add basic PGO support.

This PR adds two mutually exclusive options for profile usage and generation using LLVM's instruction profile generation (the same as clang uses), `-C pgo-use` and `-C pgo-gen`.

See each commit for details.
2018-03-26 13:00:18 +00:00
bors
5e4603f990 Auto merge of #49255 - cramertj:stable-impl-trait, r=nikomatsakis
Stabilize impl Trait

Blocked on:

- [x] https://github.com/rust-lang/rust/pull/49041 and
- [ ] completion of FCP in https://github.com/rust-lang/rust/issues/34511#issuecomment-373207183 (3 days from now).

I have not yet done any docs work for this-- I probably won't get to it until this weekend (might be a project for the flight to the all-hands).
2018-03-26 09:14:23 +00:00
Taylor Cramer
0f5b52e4a8 Stabilize conservative_impl_trait 2018-03-26 10:43:03 +02:00
gnzlbg
56aaf344c4 fix tests 2018-03-26 10:20:41 +02:00
gnzlbg
48fd903eae set min-llvm-version 6.0, ignore-emscripten 2018-03-26 10:20:41 +02:00
gnzlbg
1841f40d21 properly handle the case when LLVM does not have min/maxnum 2018-03-26 10:20:41 +02:00
gnzlbg
066c2ec9ba require llvm 6 2018-03-26 10:20:41 +02:00
gnzlbg
d2cd57c8ff add tests 2018-03-26 10:20:41 +02:00
gnzlbg
7d5343a670 implement minmax intrinsics 2018-03-26 10:20:41 +02:00
Alex Crichton
bd28641344 rustbuild: Disable docs on cross-compiled builds
This commit disables building documentation on cross-compiled compilers, for
example ARM/MIPS/PowerPC/etc. Currently I believe we're not getting much use out
of these documentation artifacts and they often take 10-15 minutes total to
build as it requires building rustdoc/rustbook and then also generating all the
documentation, especially for the reference and the book itself.

In an effort to cut down on the amount of work that we're doing on dist CI
builders in light of recent timeouts this was some relatively low hanging fruit
to cut which in theory won't have much impact on the ecosystem in the hopes that
the documentation isn't used too heavily anyway.

While initial analysis in #48827 showed only shaving 5 minutes off local builds
the same 5 minute conclusion was drawn from #48826 which ended up having nearly
a half-hour impact on the bots. In that sense I'm hoping that we can land this
and test out what happens on CI to see how it affects timing.

Note that all tier 1 platforms, Windows, Mac, and Linux, will continue to
generate documentation.
2018-03-25 23:31:41 -07:00
Taylor Cramer
c393db67ba Stabilize universal_impl_trait 2018-03-26 07:39:38 +02:00
bors
184156ed97 Auto merge of #49351 - pthariensflame:patch-1, r=oli-obk
Minor message/label formatting consistency fix.

The unimplemented label for `Termination` was missing some backticks for consistency with the message.
2018-03-26 05:09:44 +00:00
bors
445fafaa4b Auto merge of #49341 - alexcrichton:more-balance, r=kennytm
appveyor: Move run-pass-fulldeps to extra builders

We've made headway towards splitting the test suite across two appveyor builders
and this moves one more tests suite between builders. The last [failed
build][fail] had its longest running test suite and I've moved that to the
secondary builder.

cc #48844

[fail]: https://ci.appveyor.com/project/rust-lang/rust/build/1.0.6782
2018-03-26 02:39:28 +00:00
bors
39ee3aaa13 Auto merge of #49297 - scottmcm:offset-from, r=dtolnay
Introduce unsafe offset_from on pointers

Adds intrinsics::exact_div to take advantage of the unsafe, which reduces the implementation from
```asm
    sub rcx, rdx
    mov rax, rcx
    sar rax, 63
    shr rax, 62
    lea rax, [rax + rcx]
    sar rax, 2
    ret
```
down to
```asm
    sub rcx, rdx
    sar rcx, 2
    mov rax, rcx
    ret
```
(for `*const i32`)

See discussion on the `offset_to` tracking issue https://github.com/rust-lang/rust/issues/41079

Some open questions
- Would you rather I split the intrinsic PR from the library PR?
- Do we even want the safe version of the API?  https://github.com/rust-lang/rust/issues/41079#issuecomment-374426786  I've added some text to its documentation that even if it's not UB, it's useless to use it between pointers into different objects.

and todos
- [x] ~~I need to make a codegen test~~ Done
- [x] ~~Can the subtraction use nsw/nuw?~~ No, it can't https://github.com/rust-lang/rust/pull/49297#discussion_r176697574
- [x] ~~Should there be `usize` variants of this, like there are now `add` and `sub` that you almost always want over `offset`?  For example, I imagine `sub_ptr` that returns `usize` and where it's UB if the distance is negative.~~ Can wait for later; C gives a signed result https://github.com/rust-lang/rust/issues/41079#issuecomment-375842235, so we might as well, and this existing to go with `offset` makes sense.
2018-03-26 00:15:34 +00:00
Diggory Blake
fbec3ec5a7 Implement get_key_value for HashMap, BTreeMap 2018-03-25 23:50:47 +01:00