Rollup merge of #57971 - jethrogb:jb/sgx-panic, r=alexcrichton
SGX target: improve panic & exit handling
Implement this part of the spec:
> The enclave must not rely on userspace to terminate other threads still running. Similarly, the enclave must not trust that it will no longer be entered by userspace, and it must safeguard against that in the entrypoints.
Rollup merge of #57106 - matthiaskrgr:trim_must_use, r=sfackler
Mark str::trim.* functions as #[must_use].
The functions return a reference to a new object and do not modify in-place
as the following code shows:
````
let s = String::from(" hello ");
s.trim();
assert_eq!(s, " hello ");
````
The new reference should be bound to a variable as now indicated by #[must_use].
bors [Tue, 29 Jan 2019 05:22:51 +0000 (05:22 +0000)]
Auto merge of #57957 - Centril:rollup, r=Centril
Rollup of 7 pull requests
Successful merges:
- #57045 (Kill remaining uses of mem::uninitialized in libcore, liballoc)
- #57674 (Avoid erase_regions_ty queries if there are no regions to erase)
- #57833 (Print a slightly clearer message when failing to launch a thread)
- #57859 (Fix invalid background color)
- #57904 (add typo suggestion to unknown attribute error)
- #57915 (Pretty print `$crate` as `crate` or `crate_name` in more cases)
- #57950 (Extend E0106, E0261)
Rollup merge of #57950 - QuietMisdreavus:lifetime-err-desc, r=estebank
Extend E0106, E0261
This is a reopening of https://github.com/rust-lang/rust/pull/57310 with review comments addressed because the original author has since deleted their fork.
From the author (@purple-ice):
> Added an example that points out hardly obvious mistake one could make when writing impl for a new type.
Rollup merge of #57915 - petrochenkov:notto-disu, r=zackmdavis
Pretty print `$crate` as `crate` or `crate_name` in more cases
So, people do parse output of `--pretty=expanded` (sigh), so covering only the legacy proc-macro case (like it was done in https://github.com/rust-lang/rust/pull/57155) is not enough.
This PRs resolves all `$crate`s produced by macros, so they are all printed in the parseable form `$crate::foo` -> `crate::foo` or `crate_name::foo`.
Rollup merge of #57833 - jethrogb:jb/thread-spawn-unwrap, r=alexcrichton
Print a slightly clearer message when failing to launch a thread
As discussed in #46345, the `io::Error` you get when a thread fails to launch is of type `io::ErrorKind::WouldBlock`. This is super uninformative when an arbitrary `thread::spawn` fails somewhere in your code:
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11,
kind: WouldBlock, message: "operation would block" }', src/libcore/result.rs:997:5
```
This PR improves the situation a little bit by using `expect` instead of `unwrap`. I don't consider this a complete fix for #46345 though.
Rollup merge of #57045 - RalfJung:kill-more-uninit, r=SimonSapin
Kill remaining uses of mem::uninitialized in libcore, liballoc
Kill remaining uses of mem::uninitialized in libcore and liballoc, and enable a lint that will warn when uses are added again in the future.
To avoid casting raw pointers around (which is always very dangerous because it is not typechecked at all -- it doesn't even get the "same size" sanity check that `transmute` gets), I also added two new functions to `MaybeUninit`:
```rust
/// Get a pointer to the first contained values.
pub fn first_ptr(this: &[MaybeUninit<T>]) -> *const T {
this as *const [MaybeUninit<T>] as *const T
}
/// Get a mutable pointer to the first contained values.
pub fn first_mut_ptr(this: &mut [MaybeUninit<T>]) -> *mut T {
this as *mut [MaybeUninit<T>] as *mut T
}
```
I changed some of the existing code to use array-of-`MaybeUninit` instead of `MaybeUninit`-of-array, successfully removing raw pointer casts there as well.
Mateusz Mikuła [Mon, 28 Jan 2019 17:40:47 +0000 (18:40 +0100)]
bootstrap: set toolchain variables on per target basis
Using CC, CFLAGS, CXX, CXXFLAGS, AR and RANLIB breaks cross compilation
because host is built first and has correct values. The same
values are incorrect for the target however.
bors [Mon, 28 Jan 2019 14:12:15 +0000 (14:12 +0000)]
Auto merge of #55704 - Nemo157:pinned-generators, r=Zoxc
Use pinning for generators to make trait safe
I'm unsure whether there needs to be any changes to the actual generator transform. Tests are passing so the fact that `Pin<&mut T>` is fundamentally the same as `&mut T` seems to allow it to still work, but maybe there's something subtle here that could go wrong.
This is specified in [RFC 2349 § Immovable generators](https://github.com/rust-lang/rfcs/blob/master/text/2349-pin.md#immovable-generators) (although, since that RFC it has become safe to create an immovable generator, and instead it's unsafe to resume any generator; with these changes both are now safe and instead the unsafety is moved to creating a `Pin<&mut [static generator]>` which there are safe APIs for).
bors [Mon, 28 Jan 2019 09:52:31 +0000 (09:52 +0000)]
Auto merge of #57899 - davidtwco:issue-56685, r=estebank
Unused variable suggestions apply on all patterns.
Fixes #56685.
This PR extends existing suggestions to prefix unused variable bindings in match arms with an underscore so that it applies to all patterns in a match arm.
r? @estebank
cc @alexcrichton (since you filed the issue)
David Wood [Fri, 25 Jan 2019 15:56:27 +0000 (16:56 +0100)]
Unused variable suggestions on all patterns.
This commit extends existing suggestions to prefix unused variable
bindings in match arms with an underscore so that it applies to all
patterns in a match arm.
bors [Mon, 28 Jan 2019 00:46:07 +0000 (00:46 +0000)]
Auto merge of #57442 - oli-obk:lazy_const, r=RalfJung
Simplify `ConstValue::ScalarPair`
While looking at #57432 I realized that some of our types for representing constants are very big. This reduces `LazyConst` to 3/4th of its original size and simplifies some code around slices at the same time.
bors [Sun, 27 Jan 2019 20:50:17 +0000 (20:50 +0000)]
Auto merge of #56932 - clarcharr:iter_refactor, r=Centril
Refactor core::iter module
A while back, I refactored `core::ops` in #42523 because the module had become a giant mess and was difficult to modify. Now, I'm doing the same with the `core::iter` module.
Like the `core::ops` refactor, things have been split up into multiple commits to make rebasing easier, and so that you can follow changes. Although the diffs are hard to decipher, the only actual code changes I've made in the first few commits are to modify exports and imports. I save all of the actual code refactoring, e.g. modifying what methods are called, for the end.