Rustc explain
Fixes#48041.
To make the review easier, I separated tests update to code update. Also, I used this script to generate new ui tests stderr:
```python
from os import listdir
from os.path import isdir, isfile, join
PATH = "src/test/ui"
def do_something(path):
files = [join(path, f) for f in listdir(path)]
for f in files:
if isdir(f):
do_something(f)
continue
if not isfile(f) or not f.endswith(".stderr"):
continue
x = open(f, "r")
content = x.read().strip()
if "error[E" not in content:
continue
errors = dict()
for y in content.splitlines():
if y.startswith("error[E"):
errors[y[6:11]] = True
errors = sorted(errors.keys())
if len(errors) < 1:
print("weird... {}".format(f))
continue
if len(errors) > 1:
content += "\n\nYou've got a few errors: {}".format(", ".join(errors))
content += "\nIf you want more information on an error, try using \"rustc --explain {}\"".format(errors[0])
else:
content += "\n\nIf you want more information on this error, try using \"rustc --explain {}\"".format(errors[0])
content += "\n"
x = open(f, "w")
x.write(content)
do_something(PATH)
```
Make ".e0" not parse as 0.0
This forces floats to have either a digit before the separating point, or after. Thus `".e0"` is invalid like `"."`, when using `parse()`. Fixes#40654. As mentioned in the issue, this is technically a breaking change... but clearly incorrect behaviour at present.
test: Fix s390x-unknown-linux-gnu atomic-lock-free test not run for systemz
The s390-unknown-linux-gnu atomic-lock-free test is currently run for ```LLVM_COMPONENTS == powerpc```. I assume it was meant to be run for ```LLVM_COMPONENTS == systemz```, so let's fix this.
rustbuild: Restore Config.libdir_relative
This re-introduces a `Config.libdir_relative` field, now derived from
`libdir` and made relative to `prefix` if necessary.
This fixes a regression from #46592 when `--libdir` is given an absolute
path. `Builder::sysroot_libdir` should always use a relative path so
its callers don't clobber system locations, and `librustc` also asserts
that `CFG_LIBDIR_RELATIVE` is really relative.
Add missing pieces for sparc-linux-gnu support
I noticed that while Rust has CABI support for 32-bit SPARC, there are still some pieces missing to be able to use Rust on a 32-Bit SPARC system like Gentoo which still defaults to a 32-bit port unlike Debian's sparc64 port.
This PR is an attempt to add the missing pieces. I will send the necessary changes for libc in a separate PR.
CC @jrtc27
Add Iterator::flatten
This adds the trait method `.flatten()` on `Iterator` which flattens one level of nesting from an iterator or (into)iterators. The method `.flat_fmap(f)` is then redefined as `.map(f).flatten()`. The implementation of `Flatten` is essentially that of what it was for `FlatMap` but removing the call to `f` at various places.
Hopefully the type alias approach should be OK as was indicated / alluded to by @bluss and @eddyb in https://github.com/rust-lang/rfcs/pull/2306#issuecomment-361391370.
cc @scottmcm
pass correct pie args to gcc linker
When linking with gcc, run gcc -v to see if --enable-default-pie is
compiled in. If it is, pass -no-pie when necessary to disable pie.
Otherwise, pass -pie when necessary to enable it.
Fixes#48032 and fixes#35061
Add Condvar APIs not susceptible to spurious wake
Provide wait_until and wait_timeout_until helper wrappers that aren't susceptible to spurious wake.
Additionally wait_timeout_until makes it possible to more easily write code that waits for a fixed amount of time in face of spurious wakes since otherwise each user would have to do math on adjusting the duration.
Implements #47960.
rustc_trans: rewrite mips64 ABI code
This PR rewrites the ABI handling code for 64-bit MIPS and should fix various FFI issues including #47290.
To accomodate the 64-bit ABI I have had to add a new `CastTarget` variant which I've called `Chunked` (though maybe this isn't the best name). This allows an ABI to cast to some arbitrary structure of `Reg` types. This is required on MIPS which might need to cast to a structure containing a mixture of `i64` and `f64` types.
Introduce UnpackedKind
This adds an `UnpackedKind` type as a typesafe counterpart to `Kind`. This should make future changes to kinds (such as const generics!) more resilient, as the type-checker will be able to catch more potential issues.
r? @eddyb
cc @yodaldevoid
rustdoc: don't crash when an external trait's docs needs to import another trait
Fixes https://github.com/rust-lang/rust/issues/48414
When resolving intra-paths for an item, rustdoc needs to have information about their items on hand, for proper bookkeeping. When loading a path for an external item, it needs to load these items from their host crate, since their information isn't otherwise available. This includes resolving paths for those docs. which can cause this process to recurse. Rustdoc keeps a map of external traits in a `RefCell<HashMap<DefId, Trait>>`, and it keeps a borrow of this active when importing an external trait. In the linked crash, this led to a RefCell borrow error, panic, and ICE.
This PR manually releases the borrow while importing the trait, and also keeps a list of traits being imported at the given moment. The latter keeps rustdoc from infinitely recursing as it tries to import the same trait repeatedly.
Update the book to promote second edition
This updates the book repository, but mostly to include
https://github.com/rust-lang/book/pull/1180
TL;DR: the second edition is close enough to done that we should
universally recommend it over the first edition.
Fix exponential projection complexity on nested types
This implements solution 1 from https://github.com/rust-lang/rust/issues/38528#issuecomment-366263076.
The code quality is currently extremely poor, but we can improve them during review.
Blocking issues:
- we probably don't want a quadratic deduplication for obligations.
- is there an alternative to deduplication?
Based on #48315.
Needs changelog. Noticable improvement on compile time is expected.
Fix#38528Close#39684Close#43757
Allow two-phase borrows of &mut self in ops
We need two-phase borrows of ops to be in the initial NLL release since without them lots of existing code will break. Fixes#48129.
CC @pnkfelix and @nikomatsakis
r? @pnkfelix
Fix borrow checker unsoundness with unions
Fixes#45157. After discussion with @nikomatsakis on Gitter, this PR only adds a test since the original issue was resolved elsewhere.
r? @nikomatsakis