Commit Graph

105237 Commits

Author SHA1 Message Date
Dylan DPC
54013532cd
Rollup merge of #71744 - tshepang:obsolete-comment, r=Dylan-DPC
remove obsolete comment

Referenced was removed in 8770d0f34a
2020-05-01 19:49:11 +02:00
Alex Crichton
e1832fa4e4 Rename bitcode-in-rlib option to embed-bitcode
This commit finishes work first pioneered in #70458 and started in #71528.
The `-C bitcode-in-rlib` option, which has not yet reached stable, is
renamed to `-C embed-bitcode` since that more accurately reflects what
it does now anyway. Various tests and such are updated along the way as
well.

This'll also need to be backported to the beta channel to ensure we
don't accidentally stabilize `-Cbitcode-in-rlib` as well.
2020-05-01 09:05:13 -07:00
Tshepang Lekhonkhobe
5f4b7a4585 fix doc reference
Should of been in e0ce9f8c0a,
but that had a typo.
2020-05-01 17:53:52 +02:00
Oliver Scherer
c64c776678 Remove a comment that made only sense in the original position of this cycle check. 2020-05-01 17:45:51 +02:00
Camille GILLOT
6cde87def1 Mark query function as must_use. 2020-05-01 17:45:30 +02:00
Oliver Scherer
ba26df0998 Name test appropriately and link to the issues it regress-checks for 2020-05-01 17:45:10 +02:00
LeSeulArtichaut
8d9f73a690 Add new tests and bless old tests 2020-05-01 17:32:06 +02:00
Nicholas Nethercote
d4e5e1bcff Don't copy bytecode files into the incr. comp. cache.
It's no longer necessary now that bitcode is embedded into object files.

This change meant that `WorkProductFileKind::Bytecode` is no longer
necessary, which means that type is no longer necessary, which allowed
several places in the code to become simpler.
2020-05-01 08:14:39 -07:00
Tshepang Lekhonkhobe
7a1a69911b make Stability docs a bit more readable, and fix some rustdoc warnings 2020-05-01 16:41:50 +02:00
LeSeulArtichaut
f9b9ba51d3 Prevent functions with #[target_feature] to be coerced to safe function pointers 2020-05-01 16:37:47 +02:00
LeSeulArtichaut
f2c6cbd98f Prevent calls to functions with #[target_feature] in safe contexts 2020-05-01 16:24:59 +02:00
Oliver Scherer
004208fc46 Move recursion check for zsts back to read site instead of access check site. 2020-05-01 15:52:08 +02:00
Camille GILLOT
e4976d0caf Restrict access. 2020-05-01 15:10:45 +02:00
Camille GILLOT
282d72f6bb Inline a few things. 2020-05-01 15:10:12 +02:00
Camille GILLOT
49e024ee7c Monomorphise the interface. 2020-05-01 14:53:55 +02:00
Camille GILLOT
e15383cce1 Move the DepNode construction to librustc_query_system. 2020-05-01 14:48:14 +02:00
Camille GILLOT
8f3e96d658 Monomorphise try_execute_query. 2020-05-01 14:40:17 +02:00
Ralf Jung
1bab6a4db7 fix Miri error message padding 2020-05-01 14:39:41 +02:00
Camille GILLOT
1c7376e797 Monomorphise try_start. 2020-05-01 14:37:12 +02:00
Camille GILLOT
d56085cbc9 Monomorphise try_execute_anon_query. 2020-05-01 14:32:11 +02:00
Santiago Pastorino
8bdf988be2
Remove deadcode in eval_mir_constant_to_operand 2020-05-01 09:30:55 -03:00
Camille GILLOT
85704a41db Monomorphise load_from_disk_and_cache_in_memory. 2020-05-01 14:29:35 +02:00
Camille GILLOT
1b2deaf57a Monomorphise force_query_with_job. 2020-05-01 14:28:57 +02:00
bors
a91d64873f Auto merge of #71742 - matthiaskrgr:submodule_upd, r=Dylan-DPC
submodules: update cargo from 90931d9b3 to 258c89644

Changes:
````
Remove unnecessary loop in `maybe_spurious`
Fix error with git repo discovery and symlinks.
Allow failure when setting file mtime.
Support multiple `--target` flags on the CLI
build-std: Don't treat std like a "local" package.
Allow `cargo package --list` even for things that don't package.
````

I'd like to get https://github.com/rust-lang/cargo/pull/8186 into nightly asap. :)

r? @ehuss
2020-05-01 12:18:41 +00:00
LeSeulArtichaut
2474f0ed88 Allow #[target_feature] on safe functions 2020-05-01 14:17:43 +02:00
jumbatm
bd18ad4fef Note that try_validation_pat can take a format str directly. 2020-05-01 21:52:43 +10:00
jumbatm
830473959a Manually format macro to not go over text width. 2020-05-01 21:52:43 +10:00
jumbatm
8175c4ceec Expect at least one expr for p, what_fmt and expected_fmt. 2020-05-01 21:52:43 +10:00
jumbatm
f1d778fef1 Also make expected param wrapped in format_args. 2020-05-01 21:52:43 +10:00
jumbatm
65c36f6e38 Wrap try_validation_pat! args in format_args! 2020-05-01 21:52:43 +10:00
jumbatm
425a99f1eb Update try_validation_pat! doc comment. 2020-05-01 21:52:43 +10:00
jumbatm
cb96d41fa1 Apply suggestions for try_validation_pat!. 2020-05-01 21:52:43 +10:00
jumbatm
9459b37780 Fix comment to reflect error handling behaviour. 2020-05-01 21:52:43 +10:00
jumbatm
9c898d65b8 Allow unreachable_patterns instead of using if true 2020-05-01 21:52:43 +10:00
jumbatm
eca147896f Match kind in try_validation_pat!.
Avoids having to repeat InterpErrorInfo { .. }
2020-05-01 21:52:43 +10:00
jumbatm
656ab76397 Add FIXME about replacing all usages of try_validation. 2020-05-01 21:52:43 +10:00
jumbatm
894a83d409 Apply suggestions from code review
Co-Authored-By: Ralf Jung <post@ralfj.de>
Co-Authored-By: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-05-01 21:52:43 +10:00
jumbatm
5b1d6000a0 Update stderrs. 2020-05-01 21:52:43 +10:00
jumbatm
2887d7923e Partially unrevert #70566.
This partially reverts commit 4b5b6cbe60,
reversing some changes made to 62b362472d.
2020-05-01 21:52:43 +10:00
jumbatm
6b413d95fc Throw validation failure for InvalidUndefBytes. 2020-05-01 21:52:43 +10:00
jumbatm
bc7b7140b9 Don't fail for UndefinedBehaviourInfo in validation. 2020-05-01 21:52:43 +10:00
jumbatm
e66e37cbf1 Don't duplicate body of try_validation. 2020-05-01 21:52:43 +10:00
jumbatm
326d38fa09 Add try_validation_pat. 2020-05-01 21:52:43 +10:00
jumbatm
14d90deab9 Don't duplicate macro for optional arg. 2020-05-01 21:52:43 +10:00
Tshepang Lekhonkhobe
6a681f5ca1 remove obsolete comments
Referenced was removed in 8770d0f34a
2020-05-01 13:43:04 +02:00
Matthias Krüger
868d559699 submodules: update cargo from 90931d9b3 to 258c89644
Changes:
````
Remove unnecessary loop in `maybe_spurious`
Fix error with git repo discovery and symlinks.
Allow failure when setting file mtime.
Support multiple `--target` flags on the CLI
build-std: Don't treat std like a "local" package.
Allow `cargo package --list` even for things that don't package.
````
2020-05-01 13:04:03 +02:00
Ralf Jung
62ee0ea0b6 fmt 2020-05-01 12:08:16 +02:00
Tshepang Lekhonkhobe
8abfb685b3 remove obsolete comment
Referenced was removed in 9f492fefef
2020-05-01 11:45:05 +02:00
Ralf Jung
d0a746ecfa remove AllocId generalization of Pointer 2020-05-01 11:33:21 +02:00
Ralf Jung
6c8ae7c7e5 bootstrap: also apply unused-attributes hack without deny_warnings 2020-05-01 11:16:05 +02:00
Ralf Jung
cce0cb3c39 use hex for invalid bool and char (consistently with validation) 2020-05-01 10:56:17 +02:00
Ralf Jung
707bd7b213 rename InvalidIntPtrUsage 2020-05-01 10:50:04 +02:00
Ralf Jung
2feeb88b62 bless you 2020-05-01 10:50:04 +02:00
Ralf Jung
f94899565b InterpError printing really is more Display than Debug
also tweak InvalidDiscriminant message
2020-05-01 10:50:04 +02:00
Ralf Jung
671bc08ea8 tweak InvalidIntPointerUsage message 2020-05-01 10:50:04 +02:00
bors
bd0bacc694 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.
2020-05-01 04:43:28 +00:00
bors
e94eaa6dce 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.
2020-05-01 01:38:05 +00:00
Tyler Mandry
1b62bb67da
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
2020-04-30 15:23:19 -07:00
Tyler Mandry
a8e0511b32
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
2020-04-30 15:23:17 -07:00
Tyler Mandry
3c75f70170
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).
2020-04-30 15:23:13 -07:00
Tyler Mandry
01fffff677
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.
2020-04-30 15:23:12 -07:00
Tyler Mandry
94433a60fb
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
2020-04-30 15:23:10 -07:00
Tyler Mandry
4adebb9f29
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
2020-04-30 15:23:08 -07:00
Eduard-Mihai Burtescu
05a872df2b wf: {Int,Float}Var can only infer to always-WF ints/floats. 2020-04-30 23:01:26 +03:00
Eduard-Mihai Burtescu
d1dc2afd05 wf: handle "livelock" checking before reaching WfPredicates::compute. 2020-04-30 23:01:22 +03:00
bors
7ced01a730 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
2020-04-30 19:01:01 +00:00
Dylan DPC
97a8870022
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.
2020-04-30 20:15:28 +02:00
Dylan DPC
2770f820aa
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)
2020-04-30 20:15:26 +02:00
Dylan DPC
5e53f80d6e
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
2020-04-30 20:15:24 +02:00
Dylan DPC
be3faf3f30
Rollup merge of #71433 - antoyo:error/missing-right-operand, r=Dylan-DPC
Add help message for missing right operand in condition

closes #30035
2020-04-30 20:15:22 +02:00
Dylan DPC
09f3c908bb
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
2020-04-30 20:15:20 +02:00
Ralf Jung
c7eb91652f deduplicate warnings 2020-04-30 19:42:14 +02:00
Ralf Jung
9273962aef remove no longer needed feature flags 2020-04-30 19:34:58 +02:00
Ralf Jung
e2c99f0deb unleashed Miri: open all the gates 2020-04-30 18:58:50 +02:00
Ralf Jung
30b32c6570 Miri: port error backtraces to std::backtrace 2020-04-30 18:26:51 +02:00
Bastian Kauschke
a08bccb3c1 handle ByRef in relate 2020-04-30 17:44:24 +02:00
Bastian Kauschke
01b3637f6e coerce documentation 2020-04-30 17:44:24 +02:00
bors
be8589fc31 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
2020-04-30 15:35:16 +00:00
Oliver Scherer
8079dd8afe A test now fails during check instead of build 2020-04-30 17:27:33 +02:00
Oliver Scherer
9cdc9321fd Address review comments 2020-04-30 17:06:11 +02:00
Oliver Scherer
a91bad6542 Highlight an error that can only happen in CTFE 2020-04-30 17:06:11 +02:00
Oliver Scherer
b2395a5ea6 Add a convenience function for testing whether a static is #[thread_local] 2020-04-30 17:06:11 +02:00
Oliver Scherer
582d52f0bd Separate miri/ctfe unsupported operations 2020-04-30 17:06:11 +02:00
Mark Rousskov
bfed215ced Remove ignored type alias test
This is tracked by a GH issue 17164, and having an ignored test for it isn't
helpful.
2020-04-30 10:23:45 -04:00
Mark Rousskov
70fafed3c8 Remove unsized enum test
This was already tested (at least) by src/test/ui/unsized/unsized-enum2.rs
2020-04-30 09:55:15 -04:00
Dylan DPC
8f6eabfbae
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
2020-04-30 14:07:58 +02:00
Dylan DPC
e2333a974a
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
2020-04-30 14:07:57 +02:00
Dylan DPC
71bf986f4b
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
2020-04-30 14:07:55 +02:00
Dylan DPC
58d955e6cc
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`
2020-04-30 14:07:53 +02:00
Dylan DPC
4e6772b52b
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
2020-04-30 14:07:52 +02:00
cohenarthur
eda7f8fdff 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
2020-04-30 11:00:45 +02:00
bors
bf459752d4 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.
2020-04-30 07:04:43 +00:00
bors
7c8dbd969d 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
2020-04-30 03:48:47 +00:00
bors
1357af3a55 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.
2020-04-29 23:47:27 +00:00
bors
fa51f810e5 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
2020-04-29 20:32:41 +00:00
Dylan MacKenzie
0592976f7e Bless tests 2020-04-29 12:18:30 -07:00
David Freese
610f944231
Update src/libcore/macros/mod.rs
Co-Authored-By: kennytm <kennytm@gmail.com>
2020-04-29 12:16:32 -07:00
Alex Crichton
ef89cc8f04 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.
2020-04-29 11:57:26 -07:00
David Freese
4813a81432 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
2020-04-29 11:50:23 -07:00
Dylan MacKenzie
a1aff18689 Allow Unreachable terminators unconditionally 2020-04-29 10:53:28 -07:00
Dylan DPC
d11b5597f8
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.
2020-04-29 19:39:37 +02:00
Dylan DPC
3286436e32
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.
2020-04-29 19:39:36 +02:00
Dylan DPC
75561a56ac
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. -_-
2020-04-29 19:39:34 +02:00
Dylan DPC
e3bf8709db
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
2020-04-29 19:39:33 +02:00
Dylan DPC
843ffb8e8a
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
2020-04-29 19:39:30 +02:00
Dylan DPC
d9761daa57
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
2020-04-29 19:39:28 +02:00
Bastian Kauschke
2f5c0f59a9 emit err when using trait objects in pat 2020-04-29 19:33:50 +02:00
Dylan MacKenzie
bd8a6d7911 Allow Downcast projections unconditionally 2020-04-29 10:30:00 -07:00
Bastian Kauschke
9f34b82de2 forbid dyn Trait in const generics 2020-04-29 19:29:10 +02:00
Ralf Jung
a430bd5549 update Miri 2020-04-29 19:25:32 +02:00
bors
c50bd7e402 Auto merge of #71674 - flip1995:clippyup, r=Dylan-DPC
Update Clippy

Fixes #71608
2020-04-29 17:13:33 +00:00
Nicholas Bishop
f408a4e9bd 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.
2020-04-29 12:06:32 -04:00
Mark Rousskov
a1f81ff0ad rustdoc supports const re-exports 2020-04-29 11:52:02 -04:00
Eric Huss
d6336dfe01 Add an index page for nightly rustc docs. 2020-04-29 08:16:39 -07:00
Pietro Albini
fde5811d74
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.
2020-04-29 16:32:32 +02:00
Donough Liu
a985879113 Suggest deref when coercing ty::Ref to ty::RawPtr 2020-04-29 22:21:33 +08:00
flip1995
891b0e2dff
Update Clippy 2020-04-29 16:09:04 +02:00
bors
36d13cb01b 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](42abbd8878/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
2020-04-29 13:59:22 +00:00
Bastian Kauschke
827d6f6c3d document stable counterparts of intrinsics 2020-04-29 15:50:21 +02:00
Ralf Jung
07772fcf6f expand comment in memory.rs with extra soundness concerns 2020-04-29 14:56:40 +02:00
Ralf Jung
a03355dea0 some more test cases 2020-04-29 14:55:05 +02:00
Dylan DPC
878e92872d
Rollup merge of #71657 - Daniel-Worrall:24949, r=estebank
Add #24949 assoc constant static recursion test

Closes #24949

Forced tidy fixes
2020-04-29 12:23:26 +02:00
Dylan DPC
4955c059f8
Rollup merge of #71654 - zachreizner:patch-1, r=jonas-schievink
Update link to unstable book for llvm_asm macro
2020-04-29 12:23:24 +02:00
Dylan DPC
fb1aa5624d
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.
2020-04-29 12:23:22 +02:00
Dylan DPC
65527cbc1b
Rollup merge of #71286 - Alexendoo:test-issue-69654, r=Dylan-DPC
Add regression test for #69654

closes #69654

r? @eddyb
2020-04-29 12:23:20 +02:00
Dylan DPC
d0ff2295e0
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() { };
   |                                      ^
```
2020-04-29 12:23:15 +02:00
cohenarthur
8558ccd5c4 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
2020-04-29 11:18:31 +02:00
Ralf Jung
979bbf2ce1 also test reference into static field 2020-04-29 10:47:16 +02:00
Donough Liu
a9340b1f69 Rename function to suggest_deref_ref_or_into because it's suggesting
derefence instructions
2020-04-29 13:06:02 +08:00
Donough Liu
edfca5fe9c Move branch point upwards to avoid unnecessary mk_ptr() 2020-04-29 13:06:02 +08:00
bors
92019986aa 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.
2020-04-29 03:04:46 +00:00
Esteban Küber
2c6094e5d0 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() { };
   |                                      ^
```
2020-04-28 18:47:06 -07:00
Daniel Worrall
e91c3a1d3d Add #24949 assoc constant static recursion test 2020-04-29 01:27:28 +01:00
Amanieu d'Antras
c6817ffb2c Fix test 2020-04-29 01:21:24 +01:00
Amanieu d'Antras
eb4725fc54 Remove Session::no_landing_pads() 2020-04-29 01:05:56 +01:00
Amanieu d'Antras
06e15a4ef9 Remove -Z no-landing-pads tests 2020-04-29 01:05:55 +01:00
Amanieu d'Antras
2f5bd9d0f1 Remove -Z no-landing-pads flag 2020-04-29 01:05:55 +01:00
Dylan MacKenzie
e4c650c00d Bless test that no longer warns 2020-04-28 15:27:46 -07:00
bors
825cf51ad7 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.
2020-04-28 22:18:03 +00:00
Dylan MacKenzie
900cf82d4d TYPE -> TYPE_ASCRIPTIONG 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
532ba46402 Use path to refer to constants in cross-crate pattern tests 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
e68a5c6800 Add cross-crate const in pattern tests 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
b58da533bc Add branchy const in pattern tests 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
135cfcb5cd FIXME: ignore test that ICEs 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
66f2d44c73 Add tests from #67088 and the issues mentioned in its description 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
796c0ca554 Incorporate MIR const-checker into Pat lowering 2020-04-28 14:58:50 -07:00
Dylan MacKenzie
6b54829b78 Add CustomEq qualif 2020-04-28 14:58:50 -07:00
Ralf Jung
a089801948 clarify comment 2020-04-28 23:54:47 +02:00
Ralf Jung
a84e2a0c91 add test for const-ref-to-cross-crate-mutable-static 2020-04-28 23:49:36 +02:00
Ralf Jung
e8ffa2182b better document const-pattern dynamic soundness checks, and fix a soundness hole 2020-04-28 23:48:22 +02:00
Ulrik Sverdrup
f654daf3a6 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.
2020-04-28 23:31:32 +02:00
Dylan MacKenzie
0850c3bbb8 Pass Substs to in_adt_inherently 2020-04-28 14:25:40 -07:00
bors
6470169237 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)
2020-04-28 19:05:00 +00:00
Samrat Man Singh
a6033e33e7 Fix numeric-cast tests for new into suggestion
Remove `integer-into.rs` since the numeric-cast tests already cover
these cases.
2020-04-28 21:40:03 +05:30
Samrat Man Singh
57dd22baad Suggest into to convert into isize only if uint is of width 8
Since Into<isize> is not implemented for uint of width greater than 8
2020-04-28 21:40:03 +05:30
Dylan DPC
b17ef8669e
Rollup merge of #71641 - ehuss:update-books, r=ehuss
Update books

## nomicon

5 commits in 6eb24d6e9c0773d4aee68ed5fca121ce3cdf676a..4d2d275997746d35eabfc4d992dfbdcce2f626ed
2020-04-06 02:21:15 +0200 to 2020-04-27 10:24:52 -0400
- Fix example in FFI, section NPO
- Update implementation code of `split_at_mut`
- Use rust-lang/rust linkchecker on CI.
- Use just `std::_` instead of `::std::_`
- Remove illegal space.

## reference

2 commits in 3ce94caed4cf967106c51ae86be5e098f7875f11..ed22e6fbfcb6ce436e9ea3b4bb4a55b2fb50a57e
2020-04-11 17:00:27 +0200 to 2020-04-24 12:46:22 -0700
- Fix grammer for tuple patterns and tuple struct patterns (rust-lang-nursery/reference#794)
- Document drop scopes (rust-lang-nursery/reference#514)

## book

2 commits in f5db319e0b19c22964398d56bc63103d669e1bba..e37c0e84e2ef73d3a4ebffda8011db6814a3b02d
2020-04-13 08:06:03 -0500 to 2020-04-26 09:31:36 -0500
- Mention short-circuiting in Appendix 02 (rust-lang/book#2318)
- Increase HTTP buffer size and add 'Content-Length' header (rust-lang/book#2246)

## rust-by-example

8 commits in c106d1683c3a2b0960f0f0fb01728cbb19807332..ffc99581689fe2455908aaef5f5cf50dd03bb8f5
2020-04-09 09:14:39 -0300 to 2020-04-24 15:05:04 -0300
- Fix Example -&gt; Examples (rust-lang/rust-by-example#1340)
- Make unsuffixed literal plural (rust-lang/rust-by-example#1335)
- Ensure example error matches the comment (rust-lang/rust-by-example#1336)
- Add missing triple backticks (rust-lang/rust-by-example#1339)
- Clarify conditional compilation (rust-lang/rust-by-example#1338)
- Clarifies how to customize lib crate name (rust-lang/rust-by-example#1337)
- Fix bytes of youkoso in shiftjis (rust-lang/rust-by-example#1333)
- Fix possible typo (rust-lang/rust-by-example#1334)

## embedded-book

4 commits in 668fb07b6160b9c468f598e839c1e044db65de30..40beccdf1bb8eb9184a2e3b42db8b8c6e394247f
2020-04-13 12:38:16 +0000 to 2020-04-26 17:44:14 +0000
- Add hint on memory config to GDB debugging section  (rust-embedded/book#215)
- Adds cargo-generate to installation instructions  (rust-embedded/book#213)
- collections: Fix example allocator  (rust-embedded/book#206)
- Flip111/patch 8  (rust-embedded/book#233)
2020-04-28 17:55:50 +02:00
Dylan DPC
3d1f958b6c
Rollup merge of #71637 - mibac138:cfg-sanitize, r=petrochenkov
Minor formatting changes in `cfg-sanitize.md`
2020-04-28 17:55:48 +02:00
Dylan DPC
0bcdd5ffb8
Rollup merge of #71615 - RalfJung:share-machine-code, r=oli-obk
share some common code for compile-time miri instances

Fixes https://github.com/rust-lang/rust/issues/71129

r? @oli-obk
2020-04-28 17:55:46 +02:00
Dylan DPC
45edd23825
Rollup merge of #71456 - mzohreva:mz/sgx-no-dylib, r=nikomatsakis
Use lib crate type for SGX in `fn build_auxiliary`

since SGX does not support `dylib`

cc @Goirad
2020-04-28 17:55:44 +02:00
Dylan DPC
0144bf6a84
Rollup merge of #71340 - Valloric:more-check-pass, r=nikomatsakis
Moving more build-pass tests to check-pass

One or two tests became build-pass without the FIXME because they really
needed build-pass (were failing without it).

Helps with #62277

---
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/rust-lang/rust/71340)
<!-- Reviewable:end -->
2020-04-28 17:55:43 +02:00
Eric Huss
f23db015ad Update cargo 2020-04-28 08:34:58 -07:00
Eric Huss
501dae7112 Update books 2020-04-28 07:46:36 -07:00
bors
b7bd7c1024 Auto merge of #71636 - Dylan-DPC:rollup-9gc24ak, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #71311 (On `FnDef` type annotation suggestion, use fn-pointer output)
 - #71488 (normalize field projection ty to fix broken MIR issue)
 - #71489 (Fix off by one in treat err as bug)
 - #71585 (remove obsolete comment)
 - #71634 (Revert #71372 ("Fix #! (shebang) stripping account space issue").)

Failed merges:

r? @ghost
2020-04-28 12:28:24 +00:00
Dylan DPC
6cad1e3006
Rollup merge of #71634 - eddyb:revert-71372, r=petrochenkov
Revert #71372 ("Fix #! (shebang) stripping account space issue").

While #71372 fixed some of the problems `#!`-stripping had, it introduced others:
* inefficient implementation (`.chars().filter(...).collect()` on the entire input file)
  * this also means the length returned isn't always correct, leading to e.g. #71471
* it ignores whitespace anywhere, stripping ` # ! ...` which isn't a valid shebang
  * the definition of "whitespace" it uses includes newlines, which means even `\n#\n!\n...` is stripped as a shebang (and anything matching the regex `\s*#\s*!\s*`, and not followed by `[`, really)
* it's backward-incompatible but didn't go through Crater

Now, #71487 is already open and will solve all of these issues. But for running Crater, and just in case #71487 takes a bit longer, I decided it's safer to just revert #71372.

This will also make #71372's diff clearer, as it will start again from the original whitespace-unaware version.

r? @petrochenkov
2020-04-28 13:12:17 +02:00
Dylan DPC
8e025db592
Rollup merge of #71585 - tshepang:obsolete-comment, r=Dylan-DPC
remove obsolete comment

Not sure if it's better to have an outdated comment or no comment at all (made obsolete by 2b9fea1300).
2020-04-28 13:12:15 +02:00
Dylan DPC
2b5325dbff
Rollup merge of #71489 - spastorino:fix-treat-err-as-bug-handling, r=eddyb
Fix off by one in treat err as bug

`-Ztreat-err-as-bug` doesn't work properly with delay_span_bug.

r? @eddyb
2020-04-28 13:12:14 +02:00
Dylan DPC
5aebbe9ea2
Rollup merge of #71488 - spastorino:normalize-ty-to-fix-broken-mir, r=eddyb
normalize field projection ty to fix broken MIR issue

Fixes #71344

r? @eddyb
2020-04-28 13:12:12 +02:00
Dylan DPC
d9c1f5cf4f
Rollup merge of #71311 - estebank:fn-type-param, r=varkor
On `FnDef` type annotation suggestion, use fn-pointer output

Address the last point in #71209.
2020-04-28 13:12:09 +02:00
Eduard-Mihai Burtescu
4d67c8da55 Revert "Rollup merge of #71372 - ayushmishra2005:shebang_stripping, r=estebank"
This reverts commit 46a8dcef5c, reversing
changes made to f28e3873c5.
2020-04-28 13:02:58 +03:00
Camille GILLOT
d7d2185607 Add inlining. 2020-04-28 11:57:38 +02:00
Camille GILLOT
e33327782f Move a few queries to using an arena. 2020-04-28 11:49:55 +02:00
Camille GILLOT
0b789834dd Fix fulldeps tests. 2020-04-28 11:41:12 +02:00
Camille GILLOT
bd61870606 Fix incremental compilation. 2020-04-28 11:38:32 +02:00
Camille GILLOT
0a010b33ff Fix unused parentheses warning. 2020-04-28 11:36:30 +02:00
Camille GILLOT
143b8816a3 Stop leaking memory. 2020-04-28 11:34:53 +02:00
Camille GILLOT
e56c400432 Use the query system to allocate. 2020-04-28 11:34:17 +02:00
Camille GILLOT
bd42ef6e4f Introduce ArenaStorage. 2020-04-28 11:24:53 +02:00
Camille GILLOT
e8ef41e83f Allow the QueryCache to specify storage. 2020-04-28 11:14:48 +02:00
bors
d7afaa7247 Auto merge of #71444 - RalfJung:test-async-no-opt, r=jonas-schievink
smoke-test for async fn with mir-opt-level=0

MIR opt levels heavily influence which MIR transformations run, and we barely test non-default opt levels. I am particularly worried about `async fn` lowering and how it might (not) work when the set of preceding MIR passes changes -- see https://github.com/rust-lang/rust/pull/70073.

This adds some basic smoke testing, where at least a few `async fn` `run-pass` test are ensured to also work with mir-opt-level=0.
2020-04-28 09:06:55 +00:00
Ralf Jung
3a129df39c also run some generator tests without MIR optimizations 2020-04-28 08:22:08 +02:00
bors
fb5615a477 Auto merge of #71292 - marmeladema:queries-local-def-id, r=eddyb
Convert more queries to use `LocalDefId`

This PR is based on commits in https://github.com/rust-lang/rust/pull/71215 and should partially solve #70853
2020-04-28 05:01:27 +00:00
Félix Fischer
16ebaf9273 Polished documentation, removed not-so-useful-anymore traces, and added some doc comments in mir/transform/const_prop.rs 2020-04-28 00:53:48 -04:00
Félix Fischer
05d7a60ff8 Changed simplify_match output query because it had become outdated 2020-04-28 00:53:48 -04:00
Félix Fischer
e2ab2758f2 Added MIR const-prop diff tests to show why some assertions now fail at compile-time 2020-04-28 00:53:44 -04:00
Félix Fischer
072649ec5d Added new ui tests to show what errors MIR can now find at compile time 2020-04-28 00:44:54 -04:00
Félix Fischer
86927eddaf Allow Locals to be propagated into and from, but restricted to their own block 2020-04-28 00:44:50 -04:00
bors
6db2094c90 Auto merge of #71606 - Xanewok:update-rls, r=Xanewok
Update RLS to unbreak toolstate

Breakage caused by https://github.com/rust-lang/rust/pull/71263.

r? @ghost
2020-04-28 01:46:47 +00:00
Félix Fischer
3fd2d4aaa6 Blocked MutatingUseContext::Projection for all locals of kind LocalKind::Temp. Added a cache of LocalKinds to CanConstProp 2020-04-27 20:13:22 -04:00
Félix Fischer
6316601ec4 Added regression test for literal propagation and for scalar pair propagation 2020-04-27 20:13:16 -04:00
Donough Liu
8d2f301283 Fix wrong argument in autoderef process 2020-04-28 08:05:24 +08:00
marmeladema
1349272a6e Accept LocalDefId as key for check_impl_item_well_formed query 2020-04-27 23:58:11 +01:00
marmeladema
14119a2a05 Accept LocalDefId as key for check_trait_item_well_formed query 2020-04-27 23:58:11 +01:00
marmeladema
d9e5fa15ff Accept LocalDefId as key for check_item_well_formed query 2020-04-27 23:58:11 +01:00
marmeladema
c9f6ffc3b0 Change return type of entry_fn query to return a LocalDefId 2020-04-27 23:58:11 +01:00
marmeladema
3877f54000 Declare body_owner and subject_def_id as LocalDefId in RegionCtxt 2020-04-27 23:57:55 +01:00
marmeladema
91d5ab3fb1 Declare body_owner as LocalDefId in MemCategorizationContext 2020-04-27 23:55:41 +01:00
marmeladema
3c6e6ca729 Accept LocalDefId as key for check_mod_privacy query 2020-04-27 23:55:41 +01:00
marmeladema
49d0b727ea Accept LocalDefId as key for lint_mod query 2020-04-27 23:55:41 +01:00
marmeladema
9e3bb615d5 Accept LocalDefId as argument for mir_build::lint::check 2020-04-27 23:55:41 +01:00
marmeladema
eada4101a0 Accept LocalDefId as key for mir_validated query 2020-04-27 23:55:32 +01:00
Zach Reizner
4b762ec95a
Update link to unstable book for llvm_asm macro 2020-04-27 15:51:51 -07:00
bors
c354509343 Auto merge of #71620 - Dylan-DPC:rollup-9wgtisb, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #67841 (Add Read/Write::can_read/write_vectored)
 - #71524 (Minimize parameter of coerce_borrowed_pointer())
 - #71558 (Cleanup and document `-Z tls-model` )
 - #71578 (linkchecker: fix typo in main.rs)
 - #71596 (Fix broken link in `QPath` documentation)
 - #71604 (make recursive-zst test unleashed)
 - #71605 (No need to whitelist E0750 anymore)

Failed merges:

r? @ghost
2020-04-27 22:49:05 +00:00
Vadim Petrochenkov
1686f5c68c Disable localization for all linkers 2020-04-27 23:56:28 +03:00
marmeladema
6e930f72d0 Accept LocalDefId as key for mir_borrowck query 2020-04-27 21:50:18 +01:00
marmeladema
82823c0229 Return a FxHashSet<LocalDefId> from mir_keys query 2020-04-27 21:50:17 +01:00
marmeladema
82cc530431 Accept LocalDefId as keyt for names_imported_by_glob_use
and `maybe_unused_trait_import` queries
2020-04-27 21:50:17 +01:00
marmeladema
da975c318d Use LocalDefId for type_param_predicates query 2020-04-27 21:50:17 +01:00
marmeladema
f2f0478de7 Use LocalDefId in mir_built query 2020-04-27 21:50:17 +01:00
marmeladema
abd31ad6e8 Use LocalDefId in unsafety_check_result query 2020-04-27 21:50:17 +01:00
marmeladema
de7c9e753d Use LocalDefId in typeck_tables_of and used_trait_imports queries 2020-04-27 21:50:17 +01:00
Dylan DPC
c890912da1
Rollup merge of #71605 - GuillaumeGomez:remove-e0750-from-whitelist, r=Dylan-DPC
No need to whitelist E0750 anymore

Since #71304 has been fixed, no need to whitelist it anymore.

r? @Dylan-DPC
2020-04-27 22:15:11 +02:00
Dylan DPC
efed49b79d
Rollup merge of #71604 - RalfJung:unleash-recursive-zst, r=oli-obk
make recursive-zst test unleashed

Make sure we find this issue even without const qualification.

r? @oli-obk @ecstatic-morse
2020-04-27 22:15:09 +02:00
Dylan DPC
c1c46c751c
Rollup merge of #71596 - LeSeulArtichaut:patch-1, r=Dylan-DPC
Fix broken link in `QPath` documentation

r? @Dylan-DPC
2020-04-27 22:15:07 +02:00
Dylan DPC
f4e0431da0
Rollup merge of #71578 - ryzokuken:linkchecker, r=Dylan-DPC
linkchecker: fix typo in main.rs

Came across this while reading the file.
2020-04-27 22:15:06 +02:00
Dylan DPC
f81a41a86a
Rollup merge of #71558 - petrochenkov:tlsm, r=Amanieu
Cleanup and document `-Z tls-model`

r? @Amanieu
2020-04-27 22:15:04 +02:00
Dylan DPC
e2976c1371
Rollup merge of #71524 - ldm0:ptrparam, r=matthewjasper
Minimize parameter of coerce_borrowed_pointer()

Change last parameter of `coerce_borrowed_pointer()` from `TypeAndMut` to `Mutability` (similar to `coerce_unsafe_ptr()`), since the `TypeAndMut::ty` is never used directly in this function.
2020-04-27 22:15:01 +02:00
Dylan DPC
c4d9f42f6d
Rollup merge of #67841 - sfackler:can-vector, r=Amaneiu
Add Read/Write::can_read/write_vectored

When working with an arbitrary reader or writer, code that uses vectored
operations may end up being slower than code that copies into a single
buffer when the underlying reader or writer doesn't actually support
vectored operations. These new methods allow you to ask the reader or
witer up front if vectored operations are efficiently supported.

Currently, you have to use some heuristics to guess by e.g. checking if
the read or write only accessed the first buffer. Hyper is one concrete
example of a library that has to do this dynamically:
0eaf304644/src/proto/h1/io.rs (L582-L594)
2020-04-27 22:14:55 +02:00
bors
2d03399f53 Auto merge of #71200 - oli-obk:mir_bless, r=eddyb
Emit basic block info for stmts and terminators in MIR dumps only with -Zverbose

r? @eddyb

as per https://github.com/rust-lang/rust/pull/70755#discussion_r403419476
2020-04-27 19:36:46 +00:00
Samrat Man Singh
1f0a864570 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
2020-04-28 00:43:20 +05:30
Esteban Kuber
432ab343f8
fix typo
Co-Authored-By: varkor <github@varkor.com>
2020-04-27 10:59:44 -07:00
Ralf Jung
fad64db578 share some common code for compile-time miri instances 2020-04-27 19:02:10 +02:00
Santiago Pastorino
3fe280451b
Add test for delay_span_bug and -Ztrear-err-as-bug 2020-04-27 13:05:11 -03:00
Ralf Jung
b12faeb027 keep 'pointer' terminology around 2020-04-27 17:54:17 +02:00
Oliver Scherer
a2fdc94686 Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
Santiago Pastorino
230e40644b
Fix off by one error for delay_span_bug
delay_span_bug bumps error_count after checking treat_err_as_bug
2020-04-27 09:14:30 -03:00
Igor Matuszewski
f4ac42fb72 Update RLS to unbreak toolstate
Breakage caused by https://github.com/rust-lang/rust/pull/71263.
2020-04-27 14:14:18 +02:00
Steven Fackler
c68f23ff6d fix wasi 2020-04-27 04:50:03 -07:00
Ralf Jung
3bce639fc0 make recursive-zst test unleashed 2020-04-27 13:40:26 +02:00
Guillaume Gomez
116dca5d85 No need to whitelist E0750 anymore 2020-04-27 13:36:45 +02:00
bors
46ec74e60f Auto merge of #71268 - estebank:devectorize, r=eddyb
Remove some `Vec` allocations to improve performance

This claws back most of the performance lost in https://github.com/rust-lang/rust/pull/69745.
r? @eddyb
2020-04-27 10:00:05 +00:00
bors
d81f5597ac Auto merge of #70073 - wesleywiser:mir_opt_level_0, r=oli-obk
Don't run various MIR optimizations at mir-opt-level=0

Add missing checks for mir-opt-level to non-essential MIR passes.

I verified that this can still bootstrap even with these passes disabled.

r? @oli-obk cc @RalfJung
2020-04-27 07:04:46 +00:00
bors
d13ffbe3fe Auto merge of #5522 - CrazyRoka:match_vec_item, r=phansch
New  lint `match_vec_item`

Added new lint to warn a match on index item which can panic. It's always better to use `get(..)` instead.
Closes #5500
changelog: New lint `match_on_vec_items`
2020-04-27 06:02:05 +00:00
bors
ef71df106b Auto merge of #71600 - Dylan-DPC:rollup-7tvzi9n, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #68716 (Stabilize `Span::mixed_site`)
 - #71263 (Remove unused abs_path method from rustc_span::source_map::FileLoader)
 - #71409 (Point at the return type on `.into()` failure caused by `?`)
 - #71419 (add message for resolution failure because wrong namespace)
 - #71438 (Tweak some suggestions in `rustc_resolve`)
 - #71589 (remove Unique::from for shared pointer types)

Failed merges:

r? @ghost
2020-04-27 02:38:50 +00:00
Dylan DPC
cddbed0003
Rollup merge of #71589 - RalfJung:unique-no-shr, r=SimonSapin
remove Unique::from for shared pointer types

r? @SimonSapin
2020-04-27 03:26:18 +02:00
Dylan DPC
ac62dcef05
Rollup merge of #71438 - estebank:resolve-sugg-tiny, r=petrochenkov
Tweak some suggestions in `rustc_resolve`
2020-04-27 03:26:17 +02:00
Dylan DPC
94ac0ac59f
Rollup merge of #71419 - contrun:wrong-namespace-rustc-resolve, r=petrochenkov
add message for resolution failure because wrong namespace

closes https://github.com/rust-lang/rust/issues/71406
2020-04-27 03:26:15 +02:00
Dylan DPC
c95bcbc9d5
Rollup merge of #71409 - estebank:point-at-ret-question-mark-op, r=petrochenkov
Point at the return type on `.into()` failure caused by `?`

Fix #35946.
2020-04-27 03:26:13 +02:00
Dylan DPC
89aff5f33e
Rollup merge of #71263 - shlevy:FileLoader-remove-abs_path, r=Xanewok
Remove unused abs_path method from rustc_span::source_map::FileLoader
2020-04-27 03:26:11 +02:00
Dylan DPC
9d0025263a
Rollup merge of #68716 - petrochenkov:stabmixed, r=dtolnay
Stabilize `Span::mixed_site`

Closes https://github.com/rust-lang/rust/issues/65049.
cc https://github.com/rust-lang/rust/issues/54727#issuecomment-580647446

Pre-requisite for https://github.com/rust-lang/rust/pull/68717 ("Stabilize fn-like proc macros in expression, pattern and statement positions").

Stabilization report: https://github.com/rust-lang/rust/pull/68716#issuecomment-581076337.
2020-04-27 03:26:05 +02:00
Steven Fackler
b00afb5782 fix wasm build 2020-04-26 16:34:14 -07:00
bors
5794e779a6 Auto merge of #71468 - matthiaskrgr:submodule_upd, r=Dylan-DPC
submodules: update clippy from 891e1a85 to d01a4981

Changes:
````
`predecessors_for` will be removed soon
Rustup "Remove `BodyAndCache`"
span_lint_and_note now takes an Option<Span> for the note_span instead of just a span
Make lint also capture blocks and closures, adjust language to mention other mutex types
don't test the code in the lint docs
Switch to matching against full paths instead of just the last element of the path
Lint for holding locks across await points
fix crash on issue-69020-assoc-const-arith-overflow.rs
update stderr file
util/fetch_prs_between.sh: Add Markdown formatted Link
factor ifs into function, add differing mutex test
Update the changelog update documentation
Apply suggestions from PR review
update span_lint_and_help call to six args
test for mutex eq, add another test case
use if chain
cargo dev fmt
fix map import to rustc_middle
dev update_lints
fix internal clippy warnings
change visitor name to OppVisitor
use Visitor api to find Mutex::lock calls
add note about update-all-refs script, revert redundant pat to master
move closures to seperate fns, remove known problems
use span_lint_and_help, cargo dev fmt
creating suggestion
progress work on suggestion for auto fix
Implement unsafe_derive_deserialize lint
Update empty_enum.stderr
Formatting and naming
Formatting and naming
Cleanup: `node_id` -> `hir_id`
Fix issue #2907.
Don't trigger toplevel_ref_arg for `for` loops
Cleanup: future_not_send: use `return_ty` method
Remove badge FIXME from Cargo.toml
Change note_span argument for span_lint_and_note.
Add an Option<Span> argument to span_lint_and_help.
Fixes internal lint warning in code base.
Implement collapsible_span_lint_calls lint.
````

Fixes #71453

r? @Dylan-DPC
2020-04-26 23:31:54 +00:00
Vadim Petrochenkov
45dc4350c3 unstable-book: Document -Z tls-model 2020-04-26 23:36:00 +03:00
Vadim Petrochenkov
feeb75e263 rustc_target: Stop using "string typing" for TLS models
Introduce `enum TlsModel` instead.
2020-04-26 23:36:00 +03:00
LeSeulArtichaut
efb6d6c027
Fix broken link in QPath documentation 2020-04-26 22:32:14 +02:00
Eduardo Broto
149f6d6046 Implement mismatched_target_os lint 2020-04-26 21:27:29 +02:00
Dylan DPC
962cae070f
Rollup merge of #71576 - lcnr:inline-as_mut, r=oli-obk
check that `AsRef` and `AsMut` are inlined

Adds a regression test for #58867

r? @Dylan-DPC
2020-04-26 21:02:40 +02:00
Dylan DPC
b2a8a8a0f8
Rollup merge of #71569 - samrat:miri-ub-on-size-mismatch, r=RalfJung
[miri] Throw UB if target size and data size don't match

Issue: https://github.com/rust-lang/miri/issues/1355

If an extern C function is defined as

```
extern "C" {
    fn malloc(size: u32) -> *mut std::ffi::c_void;
}
```

on a 64-bit machine(ie. pointer sizes don't match), return undefined behaviour from Miri when [converting the argument into machine_usize](https://github.com/rust-lang/miri/blob/master/src/shims/foreign_items.rs#L200)
2020-04-26 21:02:39 +02:00
Dylan DPC
d1287746cd
Rollup merge of #71551 - gizmondo:gen-index-vec, r=jonas-schievink
Minor refactoring around IndexVec usage in generator transformation

Replace hash map with IndexVec for liveness data.
Utilize IndexVec::push return value to avoid redundant object creation.

r? @eddyb
2020-04-26 21:02:36 +02:00
Dylan DPC
4199ef14d7
Rollup merge of #71537 - Mark-Simulacrum:no-self-open, r=davidtwco
Remove support for self-opening

This was only used for linkage test cases, which is already covered by
the [run-make-fulldeps/symbol-visibility test](https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/symbol-visibility/Makefile) -- which fairly extensively makes
sure we're correctly exporting the right symbols at the right visibility (for
various Rust crate types).

This fixes #10379 and resolves #10356 by removing the test case (and underlying support in the compiler). AFAICT, the better way to test visibility is via nm, like the symbol visibility test. It seems like that's sufficient; I suspect that given that we don't use this we should just drop it (android is tier 2 anyway). But happy to hear otherwise.
2020-04-26 21:02:35 +02:00
Dylan DPC
398d3eeca1
Rollup merge of #71421 - elichai:2020-04-boxed-slice, r=sfackler
Add a function to turn Box<T> into Box<[T]>

Hi,
I think this is very useful, as currently it's not possible in safe rust to do this without re-allocating.
an alternative implementation of the same function can be:
```rust
pub fn into_boxed_slice<T>(boxed: Box<T>) -> Box<[T]> {
    unsafe {
        let slice = slice::from_raw_parts_mut(Box::into_raw(boxed), 1);
        Box::from_raw(slice)
    }
}
```

The only thing that makes me a little uncomfortable is this line :
> The alignment of array types is greater or equal to the alignment of its element type

from https://rust-lang.github.io/unsafe-code-guidelines/layout/arrays-and-slices.html

But then I see:
> The alignment of &T, &mut T, *const T and *mut T are the same, and are at least the word size.
> The alignment of &[T] is the word size.

from https://rust-lang.github.io/unsafe-code-guidelines/layout/pointers.html#representation

So I do believe this is valid(FWIW it also passes in miri https://play.rust-lang.org/?gist=c002b99364ee6b29862aeb3565a91c19)
2020-04-26 21:02:32 +02:00