Tyler Mandry [Tue, 18 Aug 2020 03:20:29 +0000 (20:20 -0700)]
Rollup merge of #75637 - ctaggart:wasm32build, r=Mark-Simulacrum
update stacker to 0.1.11 to unbreak build for wasm32-unknown-unknown
Like #72079, this updates stacker. The related problem is stacker is here https://github.com/rust-lang/stacker/issues/42. It was fixed by switching from `libc::c_void` to `std::ffi::c_void` https://github.com/rust-lang/stacker/pull/43/files.
Make sure to test file types against the non-canonicalized name to
avoid detecting the wrong type. Some systems save build artifacts
into associate file stores that do not preserve extensions, and
then link to those using conventionally-named symbolic links, that
are the arguments to `rustc` et al. If we canonicalize before
testing the type, we resolve the symlink, the extension is
lost and we might treat rlibs and rmetas as dylibs.
The fix is to tntroduce a temporary to hold the canonicalized name,
compare against the non-canonical name, and add a comment
explaining what's going on for the would-be mainter who sees a
potential cleanup.
bors [Tue, 18 Aug 2020 01:11:43 +0000 (01:11 +0000)]
Auto merge of #75653 - JohnTitor:rollup-0ejtdfo, r=JohnTitor
Rollup of 8 pull requests
Successful merges:
- #75389 (attempt to improve span_label docs)
- #75392 (Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods)
- #75464 (Move to intra doc links for ascii.rs and panic.rs)
- #75578 (Allowing raw ptr dereference in const fn)
- #75613 (Add explanation for `&mut self` method call when expecting `-> Self`)
- #75626 (Clean up E0754 explanation)
- #75629 (Use intra-doc links in `std::env`, `std::alloc` and `std::error`)
- #75634 (Mark x86_64-linux-kernel as *)
Yuki Okushi [Tue, 18 Aug 2020 00:27:47 +0000 (09:27 +0900)]
Rollup merge of #75613 - estebank:explain-mut-method, r=petrochenkov
Add explanation for `&mut self` method call when expecting `-> Self`
When a user tries to use a method as if it returned a new value of the
same type as its receiver, we will emit a type error. Try to detect this
and provide extra explanation that the method modifies the receiver
in-place.
This has confused people in the wild, like in
https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322
Yuki Okushi [Tue, 18 Aug 2020 00:27:45 +0000 (09:27 +0900)]
Rollup merge of #75578 - 5M1Sec:master, r=oli-obk
Allowing raw ptr dereference in const fn
Reflect on issue #75340
Discussion in previous PR #75425
## Updates
Change `UnsafetyViolationKind::General` to `UnsafetyViolationKind::GeneralAndConstFn` in check_unsafety.rs
Remove `unsafe` in min_const_fn_unsafe_bad.rs
Bless min_const_fn
Add the test case from issue 75340
***
Sorry for the chaos. I messed up and ended up deleting the repo in the last PR. I have to create a new PR for the new repo. I will make a feature branch next time. I will edit the old PR once I receive the commends.
@RalfJung Thank you all for your replies. They are helpful!
Yuki Okushi [Tue, 18 Aug 2020 00:27:42 +0000 (09:27 +0900)]
Rollup merge of #75392 - TimDiekmann:non-null-uninit-slice, r=RalfJung
Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods
This adds a convenient method to retrieve a `&(mut) [MaybeUninit<T>]` from slice pointers (`*const [T]`, `*mut [T]`, `NonNull<[T]>`). See also https://github.com/rust-lang/wg-allocators/issues/66#issuecomment-671789105.
~I'll add a tracking issue as soon as it's reviewed and CI passed.~
Tracking Issue: #75402
Yuki Okushi [Tue, 18 Aug 2020 00:27:39 +0000 (09:27 +0900)]
Rollup merge of #75389 - RalfJung:span_label, r=davidtwco
attempt to improve span_label docs
I was still confused by the `span_label` docs, so I did some more digging. However, this needs careful checking as I have no idea if any of this is correct.
bors [Mon, 17 Aug 2020 20:51:59 +0000 (20:51 +0000)]
Auto merge of #75145 - davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov
Reference lang items during AST lowering
Fixes #60607 and fixes #61019.
This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols:
- Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#diff-c0f791ead38d2d02916faaad0f56f41d).
- ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~
- Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct.
- I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](https://github.com/matthewjasper/rust/commit/a227c706b7809ff07021baf3856b7540d5b57f8a#r40107992) but I'd prefer that be left for a follow-up.
- I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit.
bors [Mon, 17 Aug 2020 18:33:24 +0000 (18:33 +0000)]
Auto merge of #74748 - simonvandel:simplify-discriminant-arm, r=wesleywiser
MIR-OPT: Make SimplifyBranchSame able to remove identity match with fieldless variant
Modifies SimplifyBranchSame so that it can see that the statements can be considered equal in the following example
`_0 = _1` and `discriminant(_0) = discriminant(0)` are considered equal if 0 is a fieldless variant of an enum.
Make sure to test for file types against the non-canonicalized name
to avoid detecting the wrong type. Some systems save build artifacts
into associative file stores that do not preserve extensions, and
then link to those using conventionally-named symbolic links that
are the arguments to `rustc` et al. If we canonicalize before
testing the type, we resolve the symlink, the extension is lost and
we might treat rlibs and rmetas as dylibs.
The fix is to introduce a temporary to hold the canonicalized name,
compare against the non-canonical name, and add a comment
explaining what's going on for the would-be maintainer who sees a
potential cleanup.
bors [Mon, 17 Aug 2020 03:52:46 +0000 (03:52 +0000)]
Auto merge of #75568 - ehuss:cloudabi-tier3, r=Mark-Simulacrum
Move CloudABI to tier 3.
The CloudABI target hasn't had much work done on it in a while, and it doesn't appear to be in active use. It has a fairly substantial amount of code, particularly in the [sys module](https://github.com/rust-lang/rust/tree/5addb135edc2653b07670482a430aac9b655a86b/library/std/src/sys/cloudabi) that requires actively supporting. I contacted @EdSchouten who indicated that many of the CloudABI concepts are now in WASI, and that they are OK with the target being moved to tier 3.
Esteban Küber [Mon, 17 Aug 2020 01:33:30 +0000 (18:33 -0700)]
Add explanation for `&mut self` method call when expecting `-> Self`
When a user tries to use a method as if it returned a new value of the
same type as its receiver, we will emit a type error. Try to detect this
and provide extra explanation that the method modifies the receiver
in-place.
This has confused people in the wild, like in
https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322
bors [Sun, 16 Aug 2020 23:52:32 +0000 (23:52 +0000)]
Auto merge of #74562 - pickfire:is_ascii_branchless, r=nagisa
Remove branch in optimized is_ascii
Performs slightly better in short or medium bytes by eliminating
the last branch check on `byte_pos == len` and always check the
last byte as it is always at most one `usize`.
Benchmark, before `libcore`, after `libcore_new`. It improves
medium and short by 1ns but regresses unaligned_tail by 2ns,
either way we can get unaligned_tail have a tiny chance of 1/8
on a 64 bit machine. I don't think we should bet on that, the
probability is worse than dice.
bors [Sun, 16 Aug 2020 22:00:29 +0000 (22:00 +0000)]
Auto merge of #75609 - tmandry:rollup-yrcmgke, r=tmandry
Rollup of 10 pull requests
Successful merges:
- #74204 (Don't visit foreign function bodies when lowering ast to hir)
- #74314 (rustc_typeck: construct {Closure,Generator}Substs more directly.)
- #74346 (Use LocalDefId instead of HirId for reachable_set elements.)
- #74399 (Move DelaySpanBugEmitted to ty::context)
- #75177 (Add regression test for issue-66768)
- #75223 (Add #[track_caller] to `Session::delay_span_bug`)
- #75423 (Move to intra-doc links for /library/core/src/hint.rs)
- #75485 (pin docs: add some forward references)
- #75569 (Bump minor version of emsdk to 1.38.47)
- #75596 (Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rs)
Tyler Mandry [Sun, 16 Aug 2020 21:59:34 +0000 (14:59 -0700)]
Rollup merge of #75569 - tmiasko:emscripten, r=tlively
Bump minor version of emsdk to 1.38.47
Release Notes:
```
v1.38.47: 10/02/2019
--------------------
- Add support for FETCH API in WASM backend. This doesn't support FETCH in the
main thread (`USE_FETCH_WORKER=0` is enforced). #9490
- Redefine errno values to be consistent with wasi. This will let us avoid
needing to convert the values back and forth as we use more wasi APIs.
This is an ABI change, which should not be noticeable from user code
unless you use errno defines (like EAGAIN) *and* keep around binaries
compiled with an older version that you link against. In that case, you
should rebuild them. See #9545.
- Removed build option `-s ONLY_MY_CODE` as we now have much better solutions
for that, like building to a wasm object file or using `STANDALONE_WASM`
etc. (see
https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone).
- Emscripten now supports the config file (.emscripten) being placed in the
emscripten directory rather that the current user's home directory.
See #9543
```
Motivated by changes to errno values which are currently out of sync with those
in libc crate which uses wasi values already. Helps with #72808 and #75532.
Tyler Mandry [Sun, 16 Aug 2020 21:59:32 +0000 (14:59 -0700)]
Rollup merge of #75485 - RalfJung:pin, r=nagisa
pin docs: add some forward references
@nagisa had some questions about pinning that were answered in the docs, which they did not realize because that discussion is below the examples. I still think it makes sense to introduce the examples before that discussion, since it give the discussion something concrete to refer to, but this PR adds some forward references so people don't think the examples conclude the docs.
Tyler Mandry [Sun, 16 Aug 2020 21:59:27 +0000 (14:59 -0700)]
Rollup merge of #75177 - JohnTitor:broken-mir-test, r=eddyb
Add regression test for issue-66768
Fixes #66768
This is fixed by #70452 (in particular, https://github.com/rust-lang/rust/pull/70452/files#diff-53aef089a36a8e2ed07627fc8915fe63R1763) and I'm not sure it's worth to add this test (i.e. the tests in #70452 are enough), so r? @eddyb to confirm it.
Tyler Mandry [Sun, 16 Aug 2020 21:59:23 +0000 (14:59 -0700)]
Rollup merge of #74346 - eddyb:reachable-defs, r=nikomatsakis
Use LocalDefId instead of HirId for reachable_set elements.
The only `HirId`s being tracked there that don't have matching `DefId`s are local variables, and that's an accident from #44316 (where I preserved the old behavior, even if nothing relied on reachability tracking local variables).
Tyler Mandry [Sun, 16 Aug 2020 21:59:21 +0000 (14:59 -0700)]
Rollup merge of #74314 - eddyb:closure-substs-direct, r=nikomatsakis
rustc_typeck: construct {Closure,Generator}Substs more directly.
We've previously not had a way to create `{Closure,Generator}Substs` other than instantiating all generics as inference variables and unifying the inference types (extracted using the regular `{Closure,Generator}Substs` accessors), with the actual types.
With this PR, those hacks, and assumptions about the order of closure/generator-specific components, are replaced with a simple API where the base `Substs` are combined with the additional information into a `{Closure,Generator}Substs`.
This might also be faster than relying inference, although probably not by much.
Tyler Mandry [Sun, 16 Aug 2020 21:59:20 +0000 (14:59 -0700)]
Rollup merge of #74204 - ayazhafiz:i/74120, r=eddyb
Don't visit foreign function bodies when lowering ast to hir
Previously the existence of bodies inside a foreign function block would
cause a panic in the hir `NodeCollector` during its collection of crate
bodies to compute a crate hash:
The collector walks the hir tree and creates a map of hir nodes, then
attaching bodies in the crate to their owner in the map. For a code like
```rust
extern "C" {
fn f() {
fn g() {}
}
}
```
The crate bodies include the body of the function `g`. But foreign
functions cannot have bodies, and while the parser AST permits a foreign
function to have a body, the hir doesn't. This means that the body of
`f` is not present in the hir, and so neither is `g`. So when the
`NodeCollector` finishes the walking the hir, it has no record of `g`,
cannot find an owner for the body of `g` it sees in the crate bodies,
and blows up.
Why do the crate bodies include the body of `g`? The AST walker has a
need a for walking function bodies, and FFIs share the same AST node as
functions in other contexts.
There are at least two options to fix this:
- Don't unwrap the map entry for an hir node in the `NodeCollector`
- Modifier the ast->hir lowering visitor to ignore foreign function
blocks
I don't think the first is preferrable, since we want to know when we
can't find a body for an hir node that we thought had one (dropping this
information may lead to an invalid hash). So this commit implements the
second option.
Implement 'considered equal' for statements, so that for example `_0 = _1` and `discriminant(_0) = discriminant(0)` are considered equal if 0 is a fieldless variant of an enum
bors [Sun, 16 Aug 2020 18:48:26 +0000 (18:48 +0000)]
Auto merge of #73176 - LeSeulArtichaut:tyctxtat-err, r=eddyb
Add `TyCtxtAt::{ty_error, ty_error_with_message}`
~~Only e2d957d was added, the rest comes from #70551.~~
I was unsure where to put the implementation for those methods, please tell me if there is a better place for it.
Closes #72619, ~~blocked on #70551~~.
r? @eddyb cc @mark-i-m, maybe this should be part of #70551? If so feel free to cherry-pick or ask me to file a PR against your fork.
bors [Sun, 16 Aug 2020 16:58:13 +0000 (16:58 +0000)]
Auto merge of #75472 - Mark-Simulacrum:mangling-config, r=eddyb
Add option to use the new symbol mangling in rustc/std
I don't know if this causes problems in some cases -- maybe it should be on by default for at least rustc. I've never encountered problems with it other than tools not supporting it, though.
David Wood [Tue, 4 Aug 2020 13:22:16 +0000 (14:22 +0100)]
rustdoc: clean `QPath::LangItem`
This commit adds support for cleaning `QPath::LangItem` and
`hir::GenericBound::LangItemTrait` in rustdoc. `QPath::LangItem`
does not require lowering, and `hir::GenericBound::LangItemTrait`
is lowered to a `GenericBound::TraitBound`.
David Wood [Tue, 4 Aug 2020 13:34:24 +0000 (14:34 +0100)]
hir: introduce `QPath::LangItem`
This commit introduces `QPath::LangItem` to the HIR and uses it in AST
lowering instead of constructing a `hir::Path` from a slice of symbols.
This might be better for performance, but is also much cleaner as the
previous approach is fragile. In addition, it resolves a bug (#61019)
where an extern crate imported as "std" would result in the paths
created during AST lowering being resolved incorrectly (or not at all).
Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
David Wood [Tue, 4 Aug 2020 09:47:07 +0000 (10:47 +0100)]
tests: add test for #61019's current behaviour
This commit adds a test for #61019 where a extern crate is imported as
`std` which results in name resolution to fail due to the uses of `std`
types introduced from lowering.
bors [Sun, 16 Aug 2020 06:26:38 +0000 (06:26 +0000)]
Auto merge of #75561 - kornelski:stringcol, r=Dylan-DPC
Doc: String isn't a collection
On forums one user was confused by this text, interpreting it as saying that `String` is a `Vec<char>` literally, rather than figuratively for the purpose of collect. I've reworded that paragraph.
Tomasz Miąsko [Sat, 15 Aug 2020 00:00:00 +0000 (00:00 +0000)]
Bump minor version of emsdk to 1.38.47
Release Notes:
```
v1.38.47: 10/02/2019
--------------------
- Add support for FETCH API in WASM backend. This doesn't support FETCH in the
main thread (`USE_FETCH_WORKER=0` is enforced). #9490
- Redefine errno values to be consistent with wasi. This will let us avoid
needing to convert the values back and forth as we use more wasi APIs.
This is an ABI change, which should not be noticeable from user code
unless you use errno defines (like EAGAIN) *and* keep around binaries
compiled with an older version that you link against. In that case, you
should rebuild them. See #9545.
- Removed build option `-s ONLY_MY_CODE` as we now have much better solutions
for that, like building to a wasm object file or using `STANDALONE_WASM`
etc. (see
https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone).
- Emscripten now supports the config file (.emscripten) being placed in the
emscripten directory rather that the current user's home directory.
See #9543
```
bors [Sat, 15 Aug 2020 18:01:06 +0000 (18:01 +0000)]
Auto merge of #75560 - Mark-Simulacrum:rustc-docs, r=matthiaskrgr
Add rustc-docs as a component
Previously it was listed as a package but wasn't available in the component
lists in rustup, so wasn't actually installable.
rustc-docs is also only present for x86_64-unknown-linux-gnu. Eventually it'll
also be shipped for aarch64-gnu with current CI configuration, but that builder
isn't quite up and running yet.
We probably want to ship compiler docs for other platforms as well, though, but
this commit doesn't enable that quite yet. A future PR may do so by adding
--enable-compiler-docs to the relevant builders (but it would also need to
decide the set of builders which we'd ship on).
bors [Sat, 15 Aug 2020 15:51:55 +0000 (15:51 +0000)]
Auto merge of #75483 - mati865:mingw-lld-flags, r=petrochenkov
Add LLD flags for MinGW
Tested locally and this now works:
- `RUSTFLAGS="-Zlink-self-contained=yes -Clinker=rust-lld" cargo b`
- `RUSTFLAGS="-Zlink-self-contained=no -Clinker=rust-lld -Zpre-link-arg=-Ld:/msys64/mingw64/x86_64-w64-mingw32/lib -Zpre-link-arg=-Ld:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/10.2.0 -Zpre-link-arg=crt2.o" cargo b`
This is "harmless" part of the changes to make possible linking with bare LLD with windows-gnu target. More debatable changes should follow in next PRs soon.
The match branch simplification is applied when target blocks contain
statements that are either equal or perform a const bool assignment with
different values to the same place.
Previously, when constructing new statements, only statements from a
single block had been examined. This lead to a misoptimization when
statements are equal because the assign the *same* const bool value to
the same place.
Fix the issue by examining statements from both blocks when deciding on
replacement.
Additionally:
* Copy discriminant instead of moving it since it might be necessary to use its
value more than once.
* Optimize when switching on copy operand
bors [Sat, 15 Aug 2020 11:38:24 +0000 (11:38 +0000)]
Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obk
Add sanitizer support on FreeBSD
Restarting #47337. Everything is better now, no more weird llvm problems, well not everything:
Unfortunately, the sanitizers don't have proper support for versioned symbols (https://github.com/google/sanitizers/issues/628), so `libc`'s usage of `stat@FBSD_1.0` and so on explodes, e.g. in calling `std::fs::metadata`.
Building std (now easy thanks to cargo `-Zbuild-std`) and libc with `freebsd12/13` config via the `LIBC_CI=1` env variable is a good workaround…
Mark Rousskov [Sat, 15 Aug 2020 11:06:18 +0000 (07:06 -0400)]
Add rustc-docs as a component
Previously it was listed as a package but wasn't available in the component
lists in rustup, so wasn't actually installable.
rustc-docs is also only present for x86_64-unknown-linux-gnu. Eventually it'll
also be shipped for aarch64-gnu with current CI configuration, but that builder
isn't quite up and running yet.
We probably want to ship compiler docs for other platforms as well, though, but
this commit doesn't enable that quite yet. A future PR may do so by adding
--enable-compiler-docs to the relevant builders (but it would also need to
decide the set of builders which we'd ship on).