]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agofix doc reference
Tshepang Lekhonkhobe [Fri, 1 May 2020 15:53:52 +0000 (17:53 +0200)]
fix doc reference

Should of been in e0ce9f8c0a97e5949c9cadd220279d6969289daa,
but that had a typo.

4 years agoAuto merge of #71704 - RalfJung:miri-error-print, r=oli-obk
bors [Fri, 1 May 2020 09:15:12 +0000 (09:15 +0000)]
Auto merge of #71704 - RalfJung:miri-error-print, r=oli-obk

Miri: tweak error print

I started by adjusting the "invalid use of int as pointer" message (it wasn't really clear what is invalid about the use). But then I realized that these are all `Debug` impls we use for these errors, for some reason, so I fixed that to use `Display` instead.

~~This includes https://github.com/rust-lang/rust/pull/71590 (to get the `Display` impl for `Pointer`), so the diff will look better once that finally lands. Here's the [relative diff](https://github.com/RalfJung/rust/compare/e72ebf5119e833b70231c3f2f8c7ca4904b1f0a3...RalfJung:miri-error-print).~~

r? @oli-obk

4 years agouse hex for invalid bool and char (consistently with validation)
Ralf Jung [Fri, 1 May 2020 08:56:17 +0000 (10:56 +0200)]
use hex for invalid bool and char (consistently with validation)

4 years agorename InvalidIntPtrUsage
Ralf Jung [Thu, 30 Apr 2020 18:37:58 +0000 (20:37 +0200)]
rename InvalidIntPtrUsage

4 years agobless you
Ralf Jung [Thu, 30 Apr 2020 09:59:48 +0000 (11:59 +0200)]
bless you

4 years agoInterpError printing really is more Display than Debug
Ralf Jung [Thu, 30 Apr 2020 09:03:55 +0000 (11:03 +0200)]
InterpError printing really is more Display than Debug

also tweak InvalidDiscriminant message

4 years agotweak InvalidIntPointerUsage message
Ralf Jung [Thu, 30 Apr 2020 08:49:45 +0000 (10:49 +0200)]
tweak InvalidIntPointerUsage message

4 years agoAuto merge of #71623 - petrochenkov:localink, r=estebank
bors [Fri, 1 May 2020 04:43:28 +0000 (04:43 +0000)]
Auto merge of #71623 - petrochenkov:localink, r=estebank

Disable localization for all linkers

We previously disabled non-English output from `link.exe` due to encoding issues (#35785).

In https://github.com/rust-lang/rust/pull/70740 it was pointed out that it also prevents correct inspection of the linker output, which we have to do occasionally.

So this PR disables localization for all linkers.

4 years agoAuto merge of #70674 - cjgillot:query-arena-all, r=matthewjasper
bors [Fri, 1 May 2020 01:38:05 +0000 (01:38 +0000)]
Auto merge of #70674 - cjgillot:query-arena-all, r=matthewjasper

Have the per-query caches store the results on arenas

This PR leverages the cache for each query to serve as storage area for the query results.

It introduces a new cache `ArenaCache`, which moves the result to an arena,
and only stores the reference in the hash map.
This allows to remove a sizeable part of the usage of the global `TyCtxt` arena.

I only migrated queries that already used arenas before.

4 years agoAuto merge of #71721 - tmandry:rollup-e27pxex, r=tmandry
bors [Thu, 30 Apr 2020 22:24:24 +0000 (22:24 +0000)]
Auto merge of #71721 - tmandry:rollup-e27pxex, r=tmandry

Rollup of 8 pull requests

Successful merges:

 - #71148 (Vec drop and truncate: drop using raw slice *mut [T])
 - #71465 (Add a convenience method on `TyCtxt` for checking for thread locals)
 - #71567 (Handle build completion message from Cargo)
 - #71590 (MIR dump: print pointers consistently with Miri output)
 - #71682 (Bump pulldown-cmark)
 - #71688 (Allow `Downcast` projections unconditionally in const-checking)
 - #71691 (Allow `Unreachable` terminators unconditionally in const-checking)
 - #71719 (Update backtrace-sys)

Failed merges:

r? @ghost

4 years agoRollup merge of #71719 - tmandry:update-backtrace-sys, r=Mark-Simulacrum
Tyler Mandry [Thu, 30 Apr 2020 22:23:20 +0000 (15:23 -0700)]
Rollup merge of #71719 - tmandry:update-backtrace-sys, r=Mark-Simulacrum

Update backtrace-sys

Diff:

- Don't look for old RUSTC_DEBUGINFO vars (rust-lang/backtrace-rs#313)

This fixes an issue of libbacktrace never being built with debuginfo.

r? @Mark-Simulacrum
cc @alexcrichton

4 years agoRollup merge of #71691 - ecstatic-morse:const-unreachable, r=oli-obk,RalfJung
Tyler Mandry [Thu, 30 Apr 2020 22:23:19 +0000 (15:23 -0700)]
Rollup merge of #71691 - ecstatic-morse:const-unreachable, r=oli-obk,RalfJung

Allow `Unreachable` terminators unconditionally in const-checking

If we ever actually reach an `Unreachable` terminator while executing, the MIR is ill-formed or the user's program is UB due to something like `unreachable_unchecked`. I don't think we need to forbid these in `qualify_min_const_fn`.

r? @oli-obk

4 years agoRollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obk
Tyler Mandry [Thu, 30 Apr 2020 22:23:17 +0000 (15:23 -0700)]
Rollup merge of #71688 - ecstatic-morse:const-downcast, r=oli-obk

Allow `Downcast` projections unconditionally in const-checking

`ProjectionElem::Downcast` sounds scary, but it's really just the projection we use to access a particular enum variant. They usually appear in the lowering of a `match` statement, so they have been associated with control flow in const-checking, but they don't do any control flow by themselves. We already have a HIR pass that looks for `if` and `match` (even ones that have 1 or fewer reachable branches). That pass is double-checked by a MIR pass that looks for `SwitchInt`s and `FakeRead`s for match scrutinees. In my opinion, there's no need to look for `Downcast` as well.

r? @oli-obk

4 years agoRollup merge of #71682 - ehuss:bump-pulldown-cmark, r=Dylan-DPC
Tyler Mandry [Thu, 30 Apr 2020 22:23:15 +0000 (15:23 -0700)]
Rollup merge of #71682 - ehuss:bump-pulldown-cmark, r=Dylan-DPC

Bump pulldown-cmark

Pulls in 0.7.1 with the following fixes:

- Update html5ever to 0.25
- Fix hang on unclosed html element

Closes #70871

4 years agoRollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obk
Tyler Mandry [Thu, 30 Apr 2020 22:23:13 +0000 (15:23 -0700)]
Rollup merge of #71590 - RalfJung:mir-dump-pointers, r=oli-obk

MIR dump: print pointers consistently with Miri output

This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a `0x` prefix. To save some space, MIR dump replaces the `alloc` prefix by `a` when necessary.

I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).

4 years agoRollup merge of #71567 - Mark-Simulacrum:no-success, r=matthiaskrgr
Tyler Mandry [Thu, 30 Apr 2020 22:23:12 +0000 (15:23 -0700)]
Rollup merge of #71567 - Mark-Simulacrum:no-success, r=matthiaskrgr

Handle build completion message from Cargo

This was introduced in the recent bump to 1.44 bootstrap cargo

Fixes #71561.

4 years agoRollup merge of #71465 - oli-obk:is_thread_local_cleanup, r=matthewjasper
Tyler Mandry [Thu, 30 Apr 2020 22:23:10 +0000 (15:23 -0700)]
Rollup merge of #71465 - oli-obk:is_thread_local_cleanup, r=matthewjasper

Add a convenience method on `TyCtxt` for checking for thread locals

This PR extracts the cleanup part of #71192

r? @bjorn3

4 years agoRollup merge of #71148 - bluss:vec-drop-raw-slice, r=RalfJung
Tyler Mandry [Thu, 30 Apr 2020 22:23:08 +0000 (15:23 -0700)]
Rollup merge of #71148 - bluss:vec-drop-raw-slice, r=RalfJung

Vec drop and truncate: drop using raw slice *mut [T]

By creating a *mut [T] directly (without going through &mut [T]), avoid
questions of validity of the contents of the slice.

Consider the following risky code:

```rust
unsafe {
    let mut v = Vec::<bool>::with_capacity(16);
    v.set_len(16);
}
```

The intention is that with this change, we avoid one of the soundness
questions about the above snippet, because Vec::drop no longer
produces a mutable slice of the vector's contents.

r? @RalfJung

4 years agoUpdate backtrace-sys
Tyler Mandry [Thu, 30 Apr 2020 19:29:40 +0000 (12:29 -0700)]
Update backtrace-sys

Diff:

- Don't look for old RUSTC_DEBUGINFO vars (rust-lang/backtrace-rs#313)

4 years agoAuto merge of #71717 - Dylan-DPC:rollup-av5vjor, r=Dylan-DPC
bors [Thu, 30 Apr 2020 19:01:01 +0000 (19:01 +0000)]
Auto merge of #71717 - Dylan-DPC:rollup-av5vjor, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #70950 (extend NLL checker to understand `'empty` combined with universes)
 - #71433 (Add help message for missing right operand in condition)
 - #71449 (Move `{Free,}RegionRelations` and `FreeRegionMap` to `rustc_infer`)
 - #71559 (Detect git version before attempting to use --progress)
 - #71597 (Rename Unique::empty() -> Unique::dangling())

Failed merges:

r? @ghost

4 years agoRollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmaster
Dylan DPC [Thu, 30 Apr 2020 18:15:28 +0000 (20:15 +0200)]
Rollup merge of #71597 - CohenArthur:refactor-unique-empty, r=shepmaster

Rename Unique::empty() -> Unique::dangling()

A `FIXME` comment in `src/libcore/ptr/unique.rs` suggested refactoring `Unique::empty()` to `Unique::dangling()` which this PR does.

4 years agoRollup merge of #71559 - dillona:detect_git_progress_version, r=Mark-Simulacrum
Dylan DPC [Thu, 30 Apr 2020 18:15:26 +0000 (20:15 +0200)]
Rollup merge of #71559 - dillona:detect_git_progress_version, r=Mark-Simulacrum

Detect git version before attempting to use --progress

Otherwise each update is run twice and errors are printed

I've tested this with:
git version 2.8.2.windows.1 (Windows)
git version 2.26.2.266.ge870325ee8 (Linux built from source)
git version 2.17.1 (Linux)
git version 2.21.1 (Apple Git-122.3) (MacOS)

I've tested with Python 2.7 (Windows, Linux, MacOS), 3.6 (Linux), and 3.7 (MacOS)

4 years agoRollup merge of #71449 - ecstatic-morse:free-region-cleanup, r=Mark-Simulacrum
Dylan DPC [Thu, 30 Apr 2020 18:15:24 +0000 (20:15 +0200)]
Rollup merge of #71449 - ecstatic-morse:free-region-cleanup, r=Mark-Simulacrum

Move `{Free,}RegionRelations` and `FreeRegionMap` to `rustc_infer`

...and out of `rustc_middle`. This is to further #65031, albeit in a very minor way

r? @Mark-Simulacrum

4 years agoRollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPC
Dylan DPC [Thu, 30 Apr 2020 18:15:22 +0000 (20:15 +0200)]
Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPC

Add help message for missing right operand in condition

closes #30035

4 years agoRollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasper
Dylan DPC [Thu, 30 Apr 2020 18:15:20 +0000 (20:15 +0200)]
Rollup merge of #70950 - nikomatsakis:leak-check-nll-2, r=matthewjasper

extend NLL checker to understand `'empty` combined with universes

This PR extends the NLL region checker to understand `'empty` combined with universes. In particular, it means that the NLL region checker no longer considers `exists<R2> { forall<R1> { R1: R2 } }` to be provable. This is work towards https://github.com/rust-lang/rust/issues/59490, but we're not all the way there. One thing in particular it does not address is error messages.

The modifications to the NLL region inference code turned out to be simpler than expected. The main change is to require that if `R1: R2` then `universe(R1) <= universe(R2)`.

This constraint follows from the region lattice (shown below), because we assume then that `R2` is "at least" `empty(Universe(R2))`, and hence if `R1: R2` (i.e., `R1 >= R2` on the lattice) then `R1` must be in some universe that can name `'empty(Universe(R2))`, which requires that `Universe(R1) <= Universe(R2)`.

```
static ----------+-----...------+       (greatest)
|                |              |
early-bound and  |              |
free regions     |              |
|                |              |
scope regions    |              |
|                |              |
empty(root)   placeholder(U1)   |
|            /                  |
|           /         placeholder(Un)
empty(U1) --         /
|                   /
...                /
|                 /
empty(Un) --------                      (smallest)
```

I also made what turned out to be a somewhat unrelated change to add a special region to represent `'empty(U0)`, which we use (somewhat hackily) to indicate well-formedness checks in some parts of the compiler. This fixes #68550.

I did some investigation into fixing the error message situation. That's a bit trickier: the existing "nice region error" code around placeholders relies on having better error tracing than NLL currently provides, so that it knows (e.g.) that the constraint arose from applying a trait impl and things like that. I feel like I was hoping *not* to do such fine-grained tracing in NLL, and it seems like we...largely...got away with that. I'm not sure yet if we'll have to add more tracing information or if there is some sort of alternative.

It's worth pointing out though that I've not kind of shifted my opinion on whose job it should be to enforce lifetimes: I tend to think we ought to be moving back towards *something like* the leak-check (just not the one we *had*). If we took that approach, it would actually resolve this aspect of the error message problem, because we would be resolving 'higher-ranked errors' in the trait solver itself, and hence we wouldn't have to thread as much causal information back to the region checker. I think it would also help us with removing the leak check while not breaking some of the existing crates out there.

Regardless, I think it's worth landing this change, because it was relatively simple and it aligns the set of programs that NLL accepts with those that are accepted by the main region checker, and hence should at least *help* us in migration (though I guess we still also have to resolve the existing crates that rely on leak check for coherence).

r? @matthewjasper

4 years agoAuto merge of #71675 - pietroalbini:ci-fix-shrink-regression, r=Mark-Simulacrum
bors [Thu, 30 Apr 2020 15:35:16 +0000 (15:35 +0000)]
Auto merge of #71675 - pietroalbini:ci-fix-shrink-regression, r=Mark-Simulacrum

ci: use bash when executing the "bors build finished" jobs

We don't clone the repository in those builders, so the default shell (`src/ci/exec-with-shell.py`) is not present there. This fixes a GHA regression introduced in #71434.

r? @Mark-Simulacrum

4 years agoA test now fails during check instead of build
Oliver Scherer [Thu, 30 Apr 2020 15:27:33 +0000 (17:27 +0200)]
A test now fails during check instead of build

4 years agoAddress review comments
Oliver Scherer [Thu, 30 Apr 2020 15:05:36 +0000 (17:05 +0200)]
Address review comments

4 years agoHighlight an error that can only happen in CTFE
Oliver Scherer [Thu, 30 Apr 2020 12:53:28 +0000 (14:53 +0200)]
Highlight an error that can only happen in CTFE

4 years agoAdd a convenience function for testing whether a static is `#[thread_local]`
Oliver Scherer [Fri, 17 Apr 2020 16:55:23 +0000 (18:55 +0200)]
Add a convenience function for testing whether a static is `#[thread_local]`

4 years agoSeparate miri/ctfe unsupported operations
Oliver Scherer [Thu, 16 Apr 2020 15:32:48 +0000 (17:32 +0200)]
Separate miri/ctfe unsupported operations

4 years agoAuto merge of #71707 - Dylan-DPC:rollup-hk8itvo, r=Dylan-DPC
bors [Thu, 30 Apr 2020 12:17:15 +0000 (12:17 +0000)]
Auto merge of #71707 - Dylan-DPC:rollup-hk8itvo, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71205 (rustc: fix check_attr() for methods, closures and foreign functions)
 - #71540 (Suggest deref when coercing `ty::Ref` to `ty::RawPtr`)
 - #71655 (Miri: better document and fix dynamic const pattern soundness checks)
 - #71672 (document missing stable counterparts of intrinsics)
 - #71692 (Add clarification on std::cfg macro docs v. #[cfg] attribute)

Failed merges:

r? @ghost

4 years agoRollup merge of #71692 - dfreese:cfgdocs, r=kennytm
Dylan DPC [Thu, 30 Apr 2020 12:07:58 +0000 (14:07 +0200)]
Rollup merge of #71692 - dfreese:cfgdocs, r=kennytm

Add clarification on std::cfg macro docs v. #[cfg] attribute

The wording was discussed, to a limited degree in #71679.  This tries to
address some confusion I as well as someone else had independently when
looking at this macro.

Fixes #71679

4 years agoRollup merge of #71672 - lcnr:instrinsics-wow, r=Dylan-DPC
Dylan DPC [Thu, 30 Apr 2020 12:07:57 +0000 (14:07 +0200)]
Rollup merge of #71672 - lcnr:instrinsics-wow, r=Dylan-DPC

document missing stable counterparts of intrinsics

Notes the stable counterpart of each intrinsic in case one exists.

Implements #34338

r? @Dylan-DPC

4 years agoRollup merge of #71655 - RalfJung:const-pattern-soundness, r=oli-obk
Dylan DPC [Thu, 30 Apr 2020 12:07:55 +0000 (14:07 +0200)]
Rollup merge of #71655 - RalfJung:const-pattern-soundness, r=oli-obk

Miri: better document and fix dynamic const pattern soundness checks

https://github.com/rust-lang/const-eval/issues/42 got me thinking about soundness for consts being used in patterns, and I found a hole in our existing dynamic checks: a const referring to a mutable static *in a different crate* was not caught. This PR fixes that. It also adds some comments that explain which invariants are crucial for soundness of const-patterns.

Curiously, trying to weaponize this soundness hole failed: pattern matching compilation ICEd when encountering the cross-crate static, saying "expected allocation ID alloc0 to point to memory". I don't know why that would happen, statics *should* be entirely normal memory for pattern matching to access.

r? @oli-obk
Cc @rust-lang/wg-const-eval

4 years agoRollup merge of #71540 - ldm0:ref2ptr, r=oli-obk
Dylan DPC [Thu, 30 Apr 2020 12:07:53 +0000 (14:07 +0200)]
Rollup merge of #71540 - ldm0:ref2ptr, r=oli-obk

Suggest deref when coercing `ty::Ref` to `ty::RawPtr`

Fixes #32122

Currently we do autoderef when casting `ty::Ref` ->`ty::Ref`, but we don't autoderef when casting `ty::Ref` -> `ty::RawPtr`. This PR make the compiler suggests deref when coercing `ty::Ref` to `ty::RawPtr`

4 years agoRollup merge of #71205 - NeoRaider:check_attr, r=jonas-schievink
Dylan DPC [Thu, 30 Apr 2020 12:07:52 +0000 (14:07 +0200)]
Rollup merge of #71205 - NeoRaider:check_attr, r=jonas-schievink

rustc: fix check_attr() for methods, closures and foreign functions

This fixes an issue that previously turned up for methods in https://github.com/rust-lang/rust/pull/69274, but also exists for closures and foreign function: `check_attr` does not call `codegen_fn_attrs()` for these types when it should, meaning that incorrectly used function attributes are not diagnosed without codegen.

The issue affects our UI tests, as they run with `--emit=metadata` by default, but as it turns out, this is not the only case: Function attributes are not checked on any dead code without this fix!

This makes the fix a **breaking change**. The following very silly Rust programs compiles fine on stable Rust when it should not, which is fixed by this PR.
```rust
fn main() {
    #[target_feature(enable = "sse2")]
    || {};
}
```

I assume any real-world program which may trigger this issue would at least emit a dead code warning, but of course that is no guarantee that such code does not exist...

Fixes #70307

4 years agorename-unique: Rename Unique::empty() to Unique::dangling()
cohenarthur [Thu, 30 Apr 2020 09:00:45 +0000 (11:00 +0200)]
rename-unique: Rename Unique::empty() to Unique::dangling()

rename-unique: Change calls and doc in raw_vec.rs

rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs

4 years agoAuto merge of #70175 - Amanieu:remove_nlp, r=pnkfelix
bors [Thu, 30 Apr 2020 07:04:43 +0000 (07:04 +0000)]
Auto merge of #70175 - Amanieu:remove_nlp, r=pnkfelix

Remove -Z no-landing-pads flag

Since #67502, `-Z no-landing-pads` will cause all attempted unwinds to abort since we don't generate a `try` / `catch`. This previously worked because `__rust_try` was located in libpanic_unwind which is always compiled with `-C panic=unwind`, but `__rust_try` is now directly inline into the crate that uses `catch_unwind`.

As such, `-Z no-landing-pads` is now mostly useless and people should use `-C panic=abort` instead.

4 years agoAuto merge of #71687 - RalfJung:miri, r=RalfJung
bors [Thu, 30 Apr 2020 03:48:47 +0000 (03:48 +0000)]
Auto merge of #71687 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/71632
r? @ghost
Cc @rust-lang/miri

4 years agoAuto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercote
bors [Wed, 29 Apr 2020 23:47:27 +0000 (23:47 +0000)]
Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercote

Store LLVM bitcode in object files, not compressed

This commit is an attempted resurrection of #70458 where LLVM bitcode
emitted by rustc into rlibs is stored into object file sections rather
than in a separate file. The main rationale for doing this is that when
rustc emits bitcode it will no longer use a custom compression scheme
which makes it both easier to interoperate with existing tools and also
cuts down on compile time since this compression isn't happening.

The blocker for this in #70458 turned out to be that native linkers
didn't handle the new sections well, causing the sections to either
trigger bugs in the linker or actually end up in the final linked
artifact. This commit attempts to address these issues by ensuring that
native linkers ignore the new sections by inserting custom flags with
module-level inline assembly.

Note that this does not currently change the API of the compiler at all.
The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate
whether the bitcode should be present in the object file or not.

Finally, note that an important consequence of this commit, which is also
one of its primary purposes, is to enable rustc's `-Clto` bitcode
loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here
is that when you're building with LTO Cargo will tell rustc to skip
codegen of all intermediate crates and only generate LLVM IR. Today
rustc will generate both object code and LLVM IR, but the object code is
later simply thrown away, wastefully.

4 years agoAuto merge of #71689 - Dylan-DPC:rollup-8nyuwm1, r=Dylan-DPC
bors [Wed, 29 Apr 2020 20:32:41 +0000 (20:32 +0000)]
Auto merge of #71689 - Dylan-DPC:rollup-8nyuwm1, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #71507 (Document unsafety in core::ptr)
 - #71572 (test iterator chain type length blowup)
 - #71617 (Suggest `into` instead of `try_into` if possible with int types)
 - #71627 (Fix wrong argument in autoderef process)
 - #71678 (Add an index page for nightly rustc docs.)
 - #71680 (Fix doc link to Eq trait from PartialEq trait)

Failed merges:

 - #71597 (Rename Unique::empty() -> Unique::dangling())

r? @ghost

4 years agoBless tests
Dylan MacKenzie [Wed, 29 Apr 2020 17:46:24 +0000 (10:46 -0700)]
Bless tests

4 years agoUpdate src/libcore/macros/mod.rs
David Freese [Wed, 29 Apr 2020 19:16:32 +0000 (12:16 -0700)]
Update src/libcore/macros/mod.rs

Co-Authored-By: kennytm <kennytm@gmail.com>
4 years agoStore LLVM bitcode in object files, not compressed
Alex Crichton [Thu, 23 Apr 2020 18:45:55 +0000 (11:45 -0700)]
Store LLVM bitcode in object files, not compressed

This commit is an attempted resurrection of #70458 where LLVM bitcode
emitted by rustc into rlibs is stored into object file sections rather
than in a separate file. The main rationale for doing this is that when
rustc emits bitcode it will no longer use a custom compression scheme
which makes it both easier to interoperate with existing tools and also
cuts down on compile time since this compression isn't happening.

The blocker for this in #70458 turned out to be that native linkers
didn't handle the new sections well, causing the sections to either
trigger bugs in the linker or actually end up in the final linked
artifact. This commit attempts to address these issues by ensuring that
native linkers ignore the new sections by inserting custom flags with
module-level inline assembly.

Note that this does not currently change the API of the compiler at all.
The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate
whether the bitcode should be present in the object file or not.

Finally, note that an important consequence of this commit, which is also
one of its primary purposes, is to enable rustc's `-Clto` bitcode
loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here
is that when you're building with LTO Cargo will tell rustc to skip
codegen of all intermediate crates and only generate LLVM IR. Today
rustc will generate both object code and LLVM IR, but the object code is
later simply thrown away, wastefully.

4 years agoAdd clarification on std::cfg macro docs v. #[cfg] attribute
David Freese [Wed, 29 Apr 2020 18:50:23 +0000 (11:50 -0700)]
Add clarification on std::cfg macro docs v. #[cfg] attribute

The wording was discussed, to a limited degree in #71679.  This tries to
address some confusion I as well as someone else had independently when
looking at this macro.

Fixes #71679

4 years agoAllow `Unreachable` terminators unconditionally
Dylan MacKenzie [Wed, 29 Apr 2020 17:51:20 +0000 (10:51 -0700)]
Allow `Unreachable` terminators unconditionally

4 years agoRollup merge of #71680 - nicholasbishop:bishop-fix-eq-link, r=Mark-Simulacrum
Dylan DPC [Wed, 29 Apr 2020 17:39:37 +0000 (19:39 +0200)]
Rollup merge of #71680 - nicholasbishop:bishop-fix-eq-link, r=Mark-Simulacrum

Fix doc link to Eq trait from PartialEq trait

The `Eq` link was incorrectly going to the `eq` method of `PartialEq`
instead of to the `Eq` trait.

4 years agoRollup merge of #71678 - ehuss:rustc-doc-index, r=Mark-Simulacrum
Dylan DPC [Wed, 29 Apr 2020 17:39:36 +0000 (19:39 +0200)]
Rollup merge of #71678 - ehuss:rustc-doc-index, r=Mark-Simulacrum

Add an index page for nightly rustc docs.

This adds an `index.html` page at the root of the nightly-rustc docs so that the URL https://doc.rust-lang.org/nightly/nightly-rustc/ should have a landing page that lists all the crates.

4 years agoRollup merge of #71627 - ldm0:autoderefarg, r=Dylan-DPC
Dylan DPC [Wed, 29 Apr 2020 17:39:34 +0000 (19:39 +0200)]
Rollup merge of #71627 - ldm0:autoderefarg, r=Dylan-DPC

Fix wrong argument in autoderef process

The `overloaded_deref_ty` is a function for derefencing a type which overloads the `Deref` trait. But actually this function never uses the parameter pushed in until this PR. -_-

4 years agoRollup merge of #71617 - samrat:suggest-int-into, r=ecstatic-morse
Dylan DPC [Wed, 29 Apr 2020 17:39:33 +0000 (19:39 +0200)]
Rollup merge of #71617 - samrat:suggest-int-into, r=ecstatic-morse

Suggest `into` instead of `try_into` if possible with int types

If it is possible to convert an integer type into another using `into`, don't suggest `try_into`. This commit changes the suggested method to convert from one integer type to another for the following cases:

- u{n} -> i{m} where n < m
- u8 -> isize
- i{n} -> isize where n <= 16
- u{n} -> usize where n <= 16

Fixes #71580

4 years agoRollup merge of #71572 - lcnr:type_length, r=Dylan-DPC
Dylan DPC [Wed, 29 Apr 2020 17:39:30 +0000 (19:39 +0200)]
Rollup merge of #71572 - lcnr:type_length, r=Dylan-DPC

test iterator chain type length blowup

Adds a regression test. closes #58952

r? @Dylan-DPC

4 years agoRollup merge of #71507 - CohenArthur:document-unsafe-libcore-ptr, r=Mark-Simulacrum
Dylan DPC [Wed, 29 Apr 2020 17:39:28 +0000 (19:39 +0200)]
Rollup merge of #71507 - CohenArthur:document-unsafe-libcore-ptr, r=Mark-Simulacrum

Document unsafety in core::ptr

Contributes to #66219

I have yet to document all the `unsafe` blocks in the lib and would like to know if I'm headed in the right direction

r? @steveklabnik

4 years agoAllow `Downcast` projections unconditionally
Dylan MacKenzie [Wed, 29 Apr 2020 17:29:04 +0000 (10:29 -0700)]
Allow `Downcast` projections unconditionally

4 years agoupdate Miri
Ralf Jung [Wed, 29 Apr 2020 17:25:32 +0000 (19:25 +0200)]
update Miri

4 years agoAuto merge of #71674 - flip1995:clippyup, r=Dylan-DPC
bors [Wed, 29 Apr 2020 17:13:33 +0000 (17:13 +0000)]
Auto merge of #71674 - flip1995:clippyup, r=Dylan-DPC

Update Clippy

Fixes #71608

4 years agoBump pulldown-cmark
Eric Huss [Wed, 29 Apr 2020 16:30:16 +0000 (09:30 -0700)]
Bump pulldown-cmark

4 years agoFix doc link to Eq trait from PartialEq trait
Nicholas Bishop [Wed, 29 Apr 2020 16:06:32 +0000 (12:06 -0400)]
Fix doc link to Eq trait from PartialEq trait

The `Eq` link was incorrectly going to the `eq` method of `PartialEq`
instead of to the `Eq` trait.

4 years agoAdd an index page for nightly rustc docs.
Eric Huss [Wed, 29 Apr 2020 15:16:39 +0000 (08:16 -0700)]
Add an index page for nightly rustc docs.

4 years agoci: use bash when executing the "bors build finished" jobs
Pietro Albini [Wed, 29 Apr 2020 14:32:06 +0000 (16:32 +0200)]
ci: use bash when executing the "bors build finished" jobs

We don't clone the repository in those builders, so the default shell
(src/ci/exec-with-shell.py) is not present there.

4 years agoSuggest deref when coercing `ty::Ref` to `ty::RawPtr`
Donough Liu [Wed, 29 Apr 2020 03:41:34 +0000 (11:41 +0800)]
Suggest deref when coercing `ty::Ref` to `ty::RawPtr`

4 years agoUpdate Clippy
flip1995 [Wed, 29 Apr 2020 14:09:04 +0000 (16:09 +0200)]
Update Clippy

4 years agoAuto merge of #67343 - ecstatic-morse:qualif-structural-match, r=pnkfelix
bors [Wed, 29 Apr 2020 13:59:22 +0000 (13:59 +0000)]
Auto merge of #67343 - ecstatic-morse:qualif-structural-match, r=pnkfelix

Const qualification for `StructuralEq`

Furthers #62411. Resolves #62614.

The goal of this PR is to implement the logic in #67088 on the MIR instead of the HIR. It uses the `Qualif` trait to track `StructuralPartialEq`/`StructuralEq` in the final value of a `const`. Then, if we encounter a constant during HAIR lowering whose value may not be structurally matchable, we emit the `indirect_structural_match` lint.

This PR contains all the tests present in #67088 and emits the proper warnings for the corner cases. This PR does not handle #65466, which would require that we be [more aggressive](https://github.com/rust-lang/rust/blob/42abbd8878d3b67238f3611b0587c704ba94f39c/src/librustc_mir_build/hair/pattern/const_to_pat.rs#L126-L130) when checking matched types for `PartialEq`. I think that should be done separately.

Because this works on MIR and uses dataflow, this PR should accept more cases than #67088. Notably, the qualifs in the final value of a const are encoded cross-crate, so matching on a constant whose value is defined in another crate to be `Option::<TyWithCustomEqImpl>::None` should work. Additionally, if a `const` has branching/looping, we will only emit the warning if any possible control flow path could result in a type with a custom `PartialEq` impl ending up as the final value of a `const`. I'm not sure how #67088 handled this.

AFAIK, it's not settled that these are the semantics we actually want: it's just how the `Qualif` framework happens to work. If the cross-crate part is undesirable, it would be quite easy to change the result of `mir_const_qualif().custom_eq` to `true` before encoding it in the crate metadata. This way, other crates would have to assume that all publicly exported constants may not be safe for matching.

r? @pnkfelix
cc @eddyb

4 years agodocument stable counterparts of intrinsics
Bastian Kauschke [Wed, 29 Apr 2020 13:49:48 +0000 (15:49 +0200)]
document stable counterparts of intrinsics

4 years agoexpand comment in memory.rs with extra soundness concerns
Ralf Jung [Wed, 29 Apr 2020 12:56:40 +0000 (14:56 +0200)]
expand comment in memory.rs with extra soundness concerns

4 years agosome more test cases
Ralf Jung [Wed, 29 Apr 2020 12:55:05 +0000 (14:55 +0200)]
some more test cases

4 years agoAuto merge of #71664 - Dylan-DPC:rollup-eng60x9, r=Dylan-DPC
bors [Wed, 29 Apr 2020 10:48:11 +0000 (10:48 +0000)]
Auto merge of #71664 - Dylan-DPC:rollup-eng60x9, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71217 (Suggest `;` or assignment to drop borrows in tail exprs)
 - #71286 (Add regression test for #69654)
 - #71296 (Change wording on read_vectored docs)
 - #71654 (Update link to unstable book for llvm_asm macro)
 - #71657 (Add #24949 assoc constant static recursion test)

Failed merges:

r? @ghost

4 years agoRollup merge of #71657 - Daniel-Worrall:24949, r=estebank
Dylan DPC [Wed, 29 Apr 2020 10:23:26 +0000 (12:23 +0200)]
Rollup merge of #71657 - Daniel-Worrall:24949, r=estebank

Add #24949 assoc constant static recursion test

Closes #24949

Forced tidy fixes

4 years agoRollup merge of #71654 - zachreizner:patch-1, r=jonas-schievink
Dylan DPC [Wed, 29 Apr 2020 10:23:24 +0000 (12:23 +0200)]
Rollup merge of #71654 - zachreizner:patch-1, r=jonas-schievink

Update link to unstable book for llvm_asm macro

4 years agoRollup merge of #71296 - ChiefMilesEdgeworth:fix_doc_wording, r=Dylan-DPC
Dylan DPC [Wed, 29 Apr 2020 10:23:22 +0000 (12:23 +0200)]
Rollup merge of #71296 - ChiefMilesEdgeworth:fix_doc_wording, r=Dylan-DPC

Change wording on read_vectored docs

Closes #70154

I'm happy to work with others to make the wording on this more clear. I think what I have is an improvement but may not be the final wording.

4 years agoRollup merge of #71286 - Alexendoo:test-issue-69654, r=Dylan-DPC
Dylan DPC [Wed, 29 Apr 2020 10:23:20 +0000 (12:23 +0200)]
Rollup merge of #71286 - Alexendoo:test-issue-69654, r=Dylan-DPC

Add regression test for #69654

closes #69654

r? @eddyb

4 years agoRollup merge of #71217 - estebank:tail-borrow-sugg, r=pnkfelix
Dylan DPC [Wed, 29 Apr 2020 10:23:15 +0000 (12:23 +0200)]
Rollup merge of #71217 - estebank:tail-borrow-sugg, r=pnkfelix

Suggest `;` or assignment to drop borrows in tail exprs

Address the diagnostics part of #70844.

```
error[E0597]: `counter` does not live long enough
  --> $DIR/issue-54556-niconii.rs:22:20
   |
LL |     if let Ok(_) = counter.lock() { }
   |                    ^^^^^^^-------
   |                    |
   |                    borrowed value does not live long enough
   |                    a temporary with access to the borrow is created here ...
...
LL | }
   | -
   | |
   | `counter` dropped here while still borrowed
   | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result<MutexGuard<'_>, ()>`
   |
help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
   |
LL |     if let Ok(_) = counter.lock() { };
   |                                      ^
```

4 years agosafety-ptr: Add SAFETY on some unsafe blocks from libcore/ptr
cohenarthur [Thu, 23 Apr 2020 20:32:20 +0000 (22:32 +0200)]
safety-ptr: Add SAFETY on some unsafe blocks from libcore/ptr

Add documentation example to slice_from_raw_parts_mut()
Add SAFETY explanations to some unsafe blocks in libcore/ptr

* libcore/ptr/mod.rs
* libcore/ptr/unique.rs
* libcore/ptr/non_null.rs

safety-mod.rs: Add SAFETY to slice_from_raw_parts(),
slice_from_raw_parts_mut()

slice_from_raw_parts_mut: Add documentation example

safety-ptr-unique.rs: Add SAFETY to new() and cast()

safety-ptr-non_null.rs: Add SAFETY to new()

safety-ptr-non_null.rs: Add SAFETY to cast()

safety-ptr-non_null.rs: Add SAFETY to from() impls

safety-ptr-unique.rs: Add SAFETY to from() impls

safety-ptr-non_null.rs: Add SAFETY to new()

safety-ptr-unique.rs: Add SAFETY to new()

safety-ptr-mod.rs: Fix safety explanation

https://github.com/rust-lang/rust/pull/71507#discussion_r414488884

safety-prt-non_null.rs: Fix SAFETY comment syntax

safety-ptr-unique.rs: Fix syntax for empty()

safety-ptr-non_null.rs: Fix misuse of non-null for align_of()

safety-ptr-non_null.rs: Remove incorrect SAFETY comment

safety-ptr-unique.rs: Remove unsound SAFETY comment

safety-ptr-mod.rs: Add std comment on slice_from_raw_parts guarantee

safety-ptr-unique.rs: Remove incorrect safety comment

Creating a Unique from a NonNull has strict guarantees that the current
implementation does not guarantee

https://github.com/rust-lang/rust/pull/71507#discussion_r415035952

safety-ptr: Re-adding ignore-tidy directive

4 years agoalso test reference into static field
Ralf Jung [Wed, 29 Apr 2020 08:47:16 +0000 (10:47 +0200)]
also test reference into static field

4 years agoAuto merge of #71577 - tmiasko:backtrace-sys, r=Dylan-DPC
bors [Wed, 29 Apr 2020 07:32:52 +0000 (07:32 +0000)]
Auto merge of #71577 - tmiasko:backtrace-sys, r=Dylan-DPC

Update backtrace-sys crate to 0.1.36

* Fix an off-by-one error in backtrace-sys
* Only explicitly configure debuginfo in rustc-dep-of-std

https://github.com/rust-lang/backtrace-rs/compare/0.3.46...backtrace-sys-0.1.36

Fixes #71397.

4 years agoRename function to `suggest_deref_ref_or_into` because it's suggesting
Donough Liu [Tue, 28 Apr 2020 02:58:06 +0000 (10:58 +0800)]
Rename function to `suggest_deref_ref_or_into` because it's suggesting
derefence instructions

4 years agoMove branch point upwards to avoid unnecessary mk_ptr()
Donough Liu [Sun, 26 Apr 2020 17:41:38 +0000 (01:41 +0800)]
Move branch point upwards to avoid unnecessary mk_ptr()

4 years agoAuto merge of #71518 - felix91gr:const_prop_bugfix_just_block_prop, r=wesleywiser
bors [Wed, 29 Apr 2020 03:04:46 +0000 (03:04 +0000)]
Auto merge of #71518 - felix91gr:const_prop_bugfix_just_block_prop, r=wesleywiser

Const-prop bugfix: only add propagation inside own block for user variables

A testing spinoff of #71298. This one only adds the const-prop for locals that are user variables.

4 years agoSuggest `;` or assignment to drop borrows in tail exprs
Esteban Küber [Thu, 16 Apr 2020 19:43:40 +0000 (12:43 -0700)]
Suggest `;` or assignment to drop borrows in tail exprs

Address the diagnostics part of #70844.

```
error[E0597]: `counter` does not live long enough
  --> $DIR/issue-54556-niconii.rs:22:20
   |
LL |     if let Ok(_) = counter.lock() { }
   |                    ^^^^^^^-------
   |                    |
   |                    borrowed value does not live long enough
   |                    a temporary with access to the borrow is created here ...
...
LL | }
   | -
   | |
   | `counter` dropped here while still borrowed
   | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result<MutexGuard<'_>, ()>`
   |
help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
   |
LL |     if let Ok(_) = counter.lock() { };
   |                                      ^
```

4 years agoAdd #24949 assoc constant static recursion test
Daniel Worrall [Tue, 28 Apr 2020 23:29:26 +0000 (00:29 +0100)]
Add #24949 assoc constant static recursion test

4 years agoFix test
Amanieu d'Antras [Tue, 31 Mar 2020 22:41:45 +0000 (23:41 +0100)]
Fix test

4 years agoRemove Session::no_landing_pads()
Amanieu d'Antras [Tue, 31 Mar 2020 22:15:39 +0000 (23:15 +0100)]
Remove Session::no_landing_pads()

4 years agoRemove -Z no-landing-pads tests
Amanieu d'Antras [Tue, 31 Mar 2020 03:02:58 +0000 (04:02 +0100)]
Remove -Z no-landing-pads tests

4 years agoRemove -Z no-landing-pads flag
Amanieu d'Antras [Fri, 20 Mar 2020 11:09:32 +0000 (11:09 +0000)]
Remove -Z no-landing-pads flag

4 years agoBless test that no longer warns
Dylan MacKenzie [Tue, 28 Apr 2020 22:27:28 +0000 (15:27 -0700)]
Bless test that no longer warns

4 years agoAuto merge of #71486 - alexcrichton:arm64-lld, r=Mark-Simulacrum
bors [Tue, 28 Apr 2020 22:18:03 +0000 (22:18 +0000)]
Auto merge of #71486 - alexcrichton:arm64-lld, r=Mark-Simulacrum

Enable "full tools" option on ARM dist builders

This commit switches the `--enable-extended` option on the arm-related
dist builders to `--enable-full-tools`. This alias in `config.py`
corresponds to enabling a few more options:

* `rust.lld = true` - this is the main purpose of this PR, to enable LLD
  on ARM-related platforms. This means it will effectively unlock
  compilation of wasm programs from an arm host.

* `rust.llvm-tools = true` - it turns out that this option is largely
  ignored in rustbuild today. This is only read in one location to set
  some flags for the `llvm-tools` package, but the `llvm-tools` package
  is already produced on all of these builders. It's predicted that this
  will have no effect on build times.

* `rust.codegen-backends = ['llvm']` - historically this also enabled
  the emscripten backend, but that has long since been removed.

This brings the ARM dist builders in line with the x86_64 dist builders
using this flag. The hope is that the extra time spent on CI building
LLD will acceptable because it's cached by `sccache`, LLD is a
relatively small C++ project, and the dist builders are all clocking
well under 3 hours (the slowest of all builders) around 2 hours.

There's likely some possible cleanup that can happen with these
configure options since it doesn't look like they've aged too too well,
but I'm hopeful that possible refactorings, if necessary, could be
deferred to future PRs.

4 years agoTYPE -> TYPE_ASCRIPTIONG
Dylan MacKenzie [Tue, 28 Apr 2020 21:49:35 +0000 (14:49 -0700)]
TYPE -> TYPE_ASCRIPTIONG

4 years agoUse path to refer to constants in cross-crate pattern tests
Dylan MacKenzie [Tue, 28 Apr 2020 21:30:44 +0000 (14:30 -0700)]
Use path to refer to constants in cross-crate pattern tests

4 years agoAdd cross-crate const in pattern tests
Dylan MacKenzie [Tue, 7 Apr 2020 20:01:41 +0000 (13:01 -0700)]
Add cross-crate const in pattern tests

4 years agoAdd branchy `const` in pattern tests
Dylan MacKenzie [Tue, 7 Apr 2020 19:11:29 +0000 (12:11 -0700)]
Add branchy `const` in pattern tests

4 years agoFIXME: ignore test that ICEs
Dylan MacKenzie [Tue, 7 Apr 2020 03:10:34 +0000 (20:10 -0700)]
FIXME: ignore test that ICEs

4 years agoAdd tests from #67088 and the issues mentioned in its description
Dylan MacKenzie [Tue, 17 Mar 2020 04:01:05 +0000 (21:01 -0700)]
Add tests from #67088 and the issues mentioned in its description

4 years agoIncorporate MIR const-checker into `Pat` lowering
Dylan MacKenzie [Tue, 17 Mar 2020 03:50:20 +0000 (20:50 -0700)]
Incorporate MIR const-checker into `Pat` lowering

4 years agoAdd `CustomEq` qualif
Dylan MacKenzie [Mon, 16 Mar 2020 17:45:39 +0000 (10:45 -0700)]
Add `CustomEq` qualif

4 years agoclarify comment
Ralf Jung [Tue, 28 Apr 2020 21:54:47 +0000 (23:54 +0200)]
clarify comment

4 years agoadd test for const-ref-to-cross-crate-mutable-static
Ralf Jung [Tue, 28 Apr 2020 21:49:36 +0000 (23:49 +0200)]
add test for const-ref-to-cross-crate-mutable-static

4 years agobetter document const-pattern dynamic soundness checks, and fix a soundness hole
Ralf Jung [Tue, 28 Apr 2020 21:48:22 +0000 (23:48 +0200)]
better document const-pattern dynamic soundness checks, and fix a soundness hole

4 years agoVec IntoIter: Drop using raw slice
Ulrik Sverdrup [Tue, 28 Apr 2020 21:31:32 +0000 (23:31 +0200)]
Vec IntoIter: Drop using raw slice

Update Vec drop with a comment to explain why we want to use a raw
slice, and extend this pattern to also include the Vec's IntoIter.

4 years agoPass `Substs` to `in_adt_inherently`
Dylan MacKenzie [Mon, 16 Mar 2020 17:44:46 +0000 (10:44 -0700)]
Pass `Substs` to `in_adt_inherently`

4 years agoAuto merge of #71642 - ehuss:update-cargo, r=ehuss
bors [Tue, 28 Apr 2020 19:05:00 +0000 (19:05 +0000)]
Auto merge of #71642 - ehuss:update-cargo, r=ehuss

Update cargo

11 commits in 8751eb3010d4cdb5329b5a6bd2b6d765c95b0dca..90931d9b31e8b854522fed00916504a3ac6d8619
2020-04-21 18:04:35 +0000 to 2020-04-28 01:56:59 +0000
- Use associated constants directly on primitive types instead of modules (rust-lang/cargo#8077)
- Clear `RUSTDOCFLAGS` before running tests (rust-lang/cargo#8168)
- Fix warning for `resolve` mismatch in workspace. (rust-lang/cargo#8169)
- Fix flaky linking_interrupted test. (rust-lang/cargo#8162)
- Fixed some unnecessary borrows and clones. (rust-lang/cargo#8146)
- Added warning when using restricted names in Windows. (rust-lang/cargo#8136)
- Add changelog about dylib uplift. (rust-lang/cargo#8161)
- Mention that cargo_metadata can parse json messages (rust-lang/cargo#8158)
- Re-enable rustc-info-cache test again (rust-lang/cargo#8155)
- Updates to path source walking. (rust-lang/cargo#8095)
- Bump to 0.46.0, update changelog (rust-lang/cargo#8153)