]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoUplift drop-bounds lint from clippy
Michael Howell [Wed, 19 Aug 2020 10:05:44 +0000 (03:05 -0700)]
Uplift drop-bounds lint from clippy

3 years agoAuto merge of #76919 - fusion-engineering-forks:thread-parker, r=dtolnay
bors [Thu, 1 Oct 2020 13:21:34 +0000 (13:21 +0000)]
Auto merge of #76919 - fusion-engineering-forks:thread-parker, r=dtolnay

Use futex-based thread::park/unpark on Linux.

This moves the parking/unparking logic out of `thread/mod.rs` into a module named `thread_parker` in `sys_common`. The current implementation is moved to `sys_common/thread_parker/generic.rs` and the new implementation using futexes is added in `sys_common/thread_parker/futex.rs`.

3 years agoAuto merge of #74839 - alarsyo:multiple_return_terminators, r=oli-obk
bors [Thu, 1 Oct 2020 09:52:58 +0000 (09:52 +0000)]
Auto merge of #74839 - alarsyo:multiple_return_terminators, r=oli-obk

Implement multiple return terminator optimization

Closes #72022

3 years agoBless mir-opt tests for 32 bit
Antoine Martin [Thu, 1 Oct 2020 08:27:28 +0000 (10:27 +0200)]
Bless mir-opt tests for 32 bit

3 years agoAdd test for multiple terminator optimization
Antoine Martin [Thu, 1 Oct 2020 08:08:09 +0000 (10:08 +0200)]
Add test for multiple terminator optimization

3 years agoBless mir-opt tests with new opt
Antoine Martin [Thu, 1 Oct 2020 08:07:04 +0000 (10:07 +0200)]
Bless mir-opt tests with new opt

3 years agoImplement multiple return terminators optimization
Antoine Martin [Thu, 1 Oct 2020 08:06:37 +0000 (10:06 +0200)]
Implement multiple return terminators optimization

3 years agoAuto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obk
bors [Thu, 1 Oct 2020 07:38:47 +0000 (07:38 +0000)]
Auto merge of #77354 - ecstatic-morse:const-checking-moar-errors, r=oli-obk

Overhaul const-checking diagnostics

The primary purpose of this PR was to remove `NonConstOp::STOPS_CONST_CHECKING`, which causes any additional errors found by the const-checker to be silenced. I used this flag to preserve diagnostic parity with `qualify_min_const_fn.rs`, which has since been removed.

However, simply removing the flag caused a deluge of errors in some cases, since an error would be emitted any time a local or temporary had a wrong type. To remedy this, I added an alternative system (`DiagnosticImportance`) to silence additional error messages that were likely to distract the user from the underlying issue. When an error of the highest importance occurs, all less important errors are silenced. When no error of the highest importance occurs, all less important errors are emitted after checking is complete. Following the suggestions from the important error is usually enough to fix the less important errors, so this should lead to better UX most of the time.

There's also some unrelated diagnostics improvements in this PR isolated in their own commits. Splitting them out would be possible, but a bit of a pain. This isn't as tidy as some of my other PRs, but it should *only* affect diagnostics, never whether or not something passes const-checking. Note that there are a few trivial exceptions to this, like banning `Yield` in all const-contexts, not just `const fn`.

As always, meant to be reviewed commit-by-commit.

r? `@oli-obk`

3 years agoAuto merge of #77383 - pickfire:patch-6, r=Mark-Simulacrum
bors [Thu, 1 Oct 2020 05:35:48 +0000 (05:35 +0000)]
Auto merge of #77383 - pickfire:patch-6, r=Mark-Simulacrum

Fix typo in vec doc "tries to reserves"

Superseeds #77192

3 years agoAuto merge of #77379 - camelid:improve-wording-crate-resolution-error, r=davidtwco
bors [Thu, 1 Oct 2020 03:28:50 +0000 (03:28 +0000)]
Auto merge of #77379 - camelid:improve-wording-crate-resolution-error, r=davidtwco

Improve wording for external crate resolution error

I think it reads better this way.

3 years agoFix typo in vec doc "tries to reserves"
Ivan Tham [Thu, 1 Oct 2020 02:08:51 +0000 (10:08 +0800)]
Fix typo in vec doc "tries to reserves"

3 years agoAuto merge of #77381 - Dylan-DPC:rollup-0sr6p5p, r=Dylan-DPC
bors [Thu, 1 Oct 2020 01:12:41 +0000 (01:12 +0000)]
Auto merge of #77381 - Dylan-DPC:rollup-0sr6p5p, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #76909 (Add Iterator::advance_by and DoubleEndedIterator::advance_back_by)
 - #77153 (Fix recursive nonterminal expansion during pretty-print/reparse check)
 - #77202 (Defer Apple SDKROOT detection to link time.)
 - #77303 (const evaluatable: improve `TooGeneric` handling)
 - #77305 (move candidate_from_obligation_no_cache)
 - #77315 (Rename AllocErr to AllocError)
 - #77319 (Stable hashing: add comments and tests concerning platform-independence)
 - #77324 (Don't fire `const_item_mutation` lint on writes through a pointer)
 - #77343 (Validate `rustc_args_required_const`)
 - #77349 (Update cargo)
 - #77360 (References to ZSTs may be at arbitrary aligned addresses)
 - #77371 (Remove trailing space in error message)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #77371 - camelid:remove-extra-space-in-diagnostic, r=varkor
Dylan DPC [Thu, 1 Oct 2020 00:13:49 +0000 (02:13 +0200)]
Rollup merge of #77371 - camelid:remove-extra-space-in-diagnostic, r=varkor

Remove trailing space in error message

- Add test for error message
- Remove trailing space in error message

3 years agoRollup merge of #77360 - oli-obk:zst_const_pat_regression, r=RalfJung
Dylan DPC [Thu, 1 Oct 2020 00:13:48 +0000 (02:13 +0200)]
Rollup merge of #77360 - oli-obk:zst_const_pat_regression, r=RalfJung

References to ZSTs may be at arbitrary aligned addresses

fixes #77320

r? @RalfJung

3 years agoRollup merge of #77349 - ehuss:update-cargo, r=ehuss
Dylan DPC [Thu, 1 Oct 2020 00:13:46 +0000 (02:13 +0200)]
Rollup merge of #77349 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in 05c611ae3c4255b7a2bcf4fcfa65b20286a07839..75615f8e69f748d7ef0df7bc0b064a9b1f5c78b2
2020-09-23 23:10:38 +0000 to 2020-09-29 18:42:19 +0000
- Correct mistake about supporting sub-makes and document CARGO_MAKEFLAGS (rust-lang/cargo#8741)
- Properly set for_host for proc-macro tests. (rust-lang/cargo#8742)
- Add Zsh completion for target triples (rust-lang/cargo#8740)
- Reinitialize index on "Object not found" error. (rust-lang/cargo#8735)
- Normalize raw string indentation. (rust-lang/cargo#8739)
- Update links to rustup docs. (rust-lang/cargo#8738)
- Add contributor guide. (rust-lang/cargo#8715)
- Fix minor error in `cargo update` docs. (rust-lang/cargo#8737)

3 years agoRollup merge of #77343 - varkor:rustc_args_required_const-validation, r=lcnr
Dylan DPC [Thu, 1 Oct 2020 00:13:44 +0000 (02:13 +0200)]
Rollup merge of #77343 - varkor:rustc_args_required_const-validation, r=lcnr

Validate `rustc_args_required_const`

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

3 years agoRollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkov
Dylan DPC [Thu, 1 Oct 2020 00:13:43 +0000 (02:13 +0200)]
Rollup merge of #77324 - Aaron1011:fix/const-item-mutation-ptr, r=petrochenkov

Don't fire `const_item_mutation` lint on writes through a pointer

Fixes #77321

3 years agoRollup merge of #77319 - tgnottingham:siphasher_endianness, r=nnethercote
Dylan DPC [Thu, 1 Oct 2020 00:13:41 +0000 (02:13 +0200)]
Rollup merge of #77319 - tgnottingham:siphasher_endianness, r=nnethercote

Stable hashing: add comments and tests concerning platform-independence

SipHasher128 implements short_write in an endian-independent way, yet
its write_xxx Hasher trait methods undo this endian-independence by byte
swapping the integer inputs on big-endian hardware. StableHasher then
adds endian-independence back by also byte-swapping on big-endian
hardware prior to invoking SipHasher128.

This double swap may have the appearance of being a no-op, but is in
fact by design. In particular, we really do want SipHasher128 to be
platform-dependent, in order to be consistent with the libstd SipHasher.
Try to clarify this intent. Also, add and update a couple of unit tests.

---

Previous commit text:

~SipHasher128: fix platform-independence confusion~

~StableHasher is supposed to ensure platform independence by converting
integers to little-endian and extending isize and usize to 64 bits as
necessary, but in fact, much of that work is already handled by
SipHasher128.~

~In particular, SipHasher128 implements short_write in an
endian-independent way, yet both StableHasher and SipHasher128
additionally attempt to achieve endian-independence by byte swapping on
BE hardware before invoking short writes. This double swap has no
effect, so let's remove it.~

~Because short_write is endian-independent, SipHasher128 is already
handling part of the platform-independence, and it would be somewhat
difficult to make it *not* handle that part with the current
implementation. As splitting platform-independence responsibilities
between StableHasher and SipHasher128 would be confusing, let's make
SipHasher128 handle all of it.~

~Finally, update some incorrect comments and increase test coverage.
Unit tests pass on both LE and BE systems.~

3 years agoRollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett
Dylan DPC [Thu, 1 Oct 2020 00:13:39 +0000 (02:13 +0200)]
Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett

Rename AllocErr to AllocError

Implements rust-lang/wg-allocators#57

3 years agoRollup merge of #77305 - lcnr:candidate_from_obligation, r=davidtwco
Dylan DPC [Thu, 1 Oct 2020 00:13:37 +0000 (02:13 +0200)]
Rollup merge of #77305 - lcnr:candidate_from_obligation, r=davidtwco

move candidate_from_obligation_no_cache

It's only called from `candidate_from_obligation` which is already in this file.

3 years agoRollup merge of #77303 - lcnr:const-evaluatable-TooGeneric, r=oli-obk,varkor
Dylan DPC [Thu, 1 Oct 2020 00:13:35 +0000 (02:13 +0200)]
Rollup merge of #77303 - lcnr:const-evaluatable-TooGeneric, r=oli-obk,varkor

const evaluatable: improve `TooGeneric` handling

Instead of emitting an error in `fulfill`, we now correctly stall on inference variables.

As `const_eval_resolve` returns `ErrorHandled::TooGeneric` when encountering generic parameters on which
we actually do want to error, we check for inference variables and eagerly emit an error if they don't exist, returning `ErrorHandled::Reported` instead.

Also contains a small bugfix for `ConstEquate` where we previously only stalled on type variables. This is probably a leftover from
when we did not yet support stalling on const inference variables.

r? @oli-obk cc @varkor @eddyb

3 years agoRollup merge of #77202 - ehuss:defer-apple-sdkroot, r=petrochenkov
Dylan DPC [Thu, 1 Oct 2020 00:13:34 +0000 (02:13 +0200)]
Rollup merge of #77202 - ehuss:defer-apple-sdkroot, r=petrochenkov

Defer Apple SDKROOT detection to link time.

This defers the detection of the SDKROOT for Apple iOS/tvOS targets to link time, instead of when the `Target` is defined. This allows commands that don't need to link to work (like `rustdoc` or `rustc --print=target-list`). This also makes `--print=target-list` a bit faster.

This also removes the note in the platform support documentation about these targets being missing. When I wrote it, I misunderstood how the SDKROOT stuff worked.

Notes:
* This means that JSON spec targets can't explicitly override these flags. I think that is probably fine, as I believe the value is generally required, and can be set with the SDKROOT environment variable.
* This changes `x86_64-apple-tvos` to use `appletvsimulator`. I think the original code was wrong (it was using `iphonesimulator`). Also, `x86_64-apple-tvos` seems broken in general, and I cannot build it locally. The `data_layout` does not appear to be correct (it is a copy of the arm64 layout instead of the x86_64 layout). I have not tried building Apple's LLVM to see if that helps, but I suspect it is just wrong (I'm uncertain since I don't know how the tvOS simulator works with its bitcode-only requirements).
* I'm tempted to remove the use of `Result` for built-in target definitions, since I don't think they should be fallible. This was added in https://github.com/rust-lang/rust/pull/34980, but that only relates to JSON definitions. I think the built-in targets shouldn't fail. I can do this now, or not.

Fixes #36156
Fixes #76584

3 years agoRollup merge of #77153 - Aaron1011:fix/better-recursive-expand, r=petrochenkov
Dylan DPC [Thu, 1 Oct 2020 00:13:32 +0000 (02:13 +0200)]
Rollup merge of #77153 - Aaron1011:fix/better-recursive-expand, r=petrochenkov

Fix recursive nonterminal expansion during pretty-print/reparse check

Makes progress towards #43081

In PR #73084, we started recursively expanded nonterminals during the
pretty-print/reparse check, allowing them to be properly compared
against the reparsed tokenstream.

Unfortunately, the recursive logic in that PR only handles the case
where a nonterminal appears inside a `TokenTree::Delimited`. If a
nonterminal appears directly in the expanded tokens of another
nonterminal, the inner nonterminal will not be expanded.

This PR fixes the recursive expansion of nonterminals, ensuring that
they are expanded wherever they occur.

3 years agoRollup merge of #76909 - timvermeulen:advance_by, r=Amanieu
Dylan DPC [Thu, 1 Oct 2020 00:13:29 +0000 (02:13 +0200)]
Rollup merge of #76909 - timvermeulen:advance_by, r=Amanieu

Add Iterator::advance_by and DoubleEndedIterator::advance_back_by

This PR adds the iterator method

```rust
fn advance_by(&mut self, n: usize) -> Result<(), usize>
```

that advances the iterator by `n` elements, returning `Ok(())` if this succeeds or `Err(len)` if the length of the iterator was less than `n`.

Currently `Iterator::nth` is the method to override for efficiently advancing an iterator by multiple elements at once. `advance_by` is superior for this purpose because
- it's simpler to implement: instead of advancing the iterator and producing the next element you only need to advance the iterator
- it composes better: iterators like `Chain` and `FlatMap` can implement `advance_by` in terms of `advance_by` on their inner iterators, but they cannot implement `nth` in terms of `nth` on their inner iterators (see #60395)
- the default implementation of `nth` can trivially be implemented in terms of `advance_by` and `next`, which this PR also does

This PR also adds `DoubleEndedIterator::advance_back_by` for all the same reasons.

I'll make a tracking issue if it's decided this is worth merging. Also let me know if anything can be improved, this went through several iterations so there might very well still be room for improvement (especially in the doc comments). I've written overrides of these methods for most iterators that already override `nth`/`nth_back`, but those still need tests so I'll add them in a later PR.

cc @cuviper @scottmcm @Amanieu

3 years agoAuto merge of #76325 - lzutao:split-core-str, r=Amanieu
bors [Wed, 30 Sep 2020 23:04:16 +0000 (23:04 +0000)]
Auto merge of #76325 - lzutao:split-core-str, r=Amanieu

Split core/str/mod.rs to smaller files

Note for reviewer:
* I split to multiple commits for easier reviewing, but I could git squash them all to one if requested.
* Recommend pulling this change locally and using advanced git diff viewer or this command:
  ```bash
  git show --reverse --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space master..
  ```

---

I split `core/str/mod.rs` to these modules:

* `converts`: Contains helper functions to convert from bytes to str.
* `error`: For error structs like Utf8Error.
* `iter`: For iterators of many str methods.
* `traits`: For indexing operations and build in traits on str.
* `validations`: For functions validating utf8 --- This name is awkward, maybe utf8.rs is better.

3 years agoImprove wording for external crate resolution error
Camelid [Wed, 30 Sep 2020 22:52:13 +0000 (15:52 -0700)]
Improve wording for external crate resolution error

I think it reads better this way.

3 years agoAuto merge of #77372 - jonas-schievink:rollup-e5bdzga, r=jonas-schievink
bors [Wed, 30 Sep 2020 20:49:27 +0000 (20:49 +0000)]
Auto merge of #77372 - jonas-schievink:rollup-e5bdzga, r=jonas-schievink

Rollup of 12 pull requests

Successful merges:

 - #77037 (more tiny clippy cleanups)
 - #77233 (BTreeMap: keep an eye out on the size of the main components)
 - #77280 (Ensure that all LLVM components requested by tests are available on CI)
 - #77284 (library: Forward compiler-builtins "mem" feature)
 - #77296 (liveness: Use Option::None to represent absent live nodes)
 - #77322 (Add unstable book docs for `-Zunsound-mir-opts`)
 - #77328 (Use `rtassert!` instead of `assert!` from the child process after fork() in std::sys::unix::process::Command::spawn())
 - #77331 (Add test for async/await combined with const-generics.)
 - #77338 (Fix typo in alloc vec comment)
 - #77340 (Alloc vec use imported path)
 - #77345 (Add test for issue #74761)
 - #77348 (Update books)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #77348 - ehuss:update-books, r=ehuss
Jonas Schievink [Wed, 30 Sep 2020 18:56:24 +0000 (20:56 +0200)]
Rollup merge of #77348 - ehuss:update-books, r=ehuss

Update books

## rust-by-example

5 commits in 19f0a0372af497b34369cf182d9d16156cab2969..7d3ff1c12db08a847a57a054be4a7951ce532d2d
2020-08-26 09:38:48 -0300 to 2020-09-28 15:54:25 -0300
- Prevent duplicated error information in "wrapping errors" example (rust-lang/rust-by-example#1375)
- Avoid lifetime annotation in struct example (rust-lang/rust-by-example#1378)
- Clone.md comment and variable name change (rust-lang/rust-by-example#1379)
- Replace panic example with a simpler version (rust-lang/rust-by-example#1380)
- Prefer `const` over `static` (rust-lang/rust-by-example#1381)

## embedded-book

1 commits in 0cd2ca116274b915924c3a7e07c1e046b6f19b77..dd310616308e01f6cf227f46347b744aa56b77d9
2020-08-19 10:33:15 +0000 to 2020-09-26 08:54:08 +0000
- Add instructions for ARM v8 instruction sets  (rust-embedded/book#265)

3 years agoRollup merge of #77345 - samlich:test-issue-74761, r=lcnr
Jonas Schievink [Wed, 30 Sep 2020 18:56:22 +0000 (20:56 +0200)]
Rollup merge of #77345 - samlich:test-issue-74761, r=lcnr

Add test for issue #74761

Adds test for and closes #74761 which previously crashed compiler.

3 years agoRollup merge of #77340 - pickfire:patch-9, r=kennytm
Jonas Schievink [Wed, 30 Sep 2020 18:56:21 +0000 (20:56 +0200)]
Rollup merge of #77340 - pickfire:patch-9, r=kennytm

Alloc vec use imported path

mem::ManuallyDrop::new -> ManuallyDrop::new

cc @the8472

3 years agoRollup merge of #77338 - pickfire:patch-7, r=jyn514
Jonas Schievink [Wed, 30 Sep 2020 18:56:19 +0000 (20:56 +0200)]
Rollup merge of #77338 - pickfire:patch-7, r=jyn514

Fix typo in alloc vec comment

cc @the8472

3 years agoRollup merge of #77331 - hameerabbasi:issue-74906, r=lcnr
Jonas Schievink [Wed, 30 Sep 2020 18:56:17 +0000 (20:56 +0200)]
Rollup merge of #77331 - hameerabbasi:issue-74906, r=lcnr

Add test for async/await combined with const-generics.

Fixes #74906.

3 years agoRollup merge of #77328 - hyd-dev:assert-to-rtassert, r=Amanieu
Jonas Schievink [Wed, 30 Sep 2020 18:56:15 +0000 (20:56 +0200)]
Rollup merge of #77328 - hyd-dev:assert-to-rtassert, r=Amanieu

Use `rtassert!` instead of `assert!` from the child process after fork() in std::sys::unix::process::Command::spawn()

As discussed in #73894, `assert!` panics on failure, which is not signal-safe, and `rtassert!` is a suitable replacement.

Fixes #73894.

r? @Amanieu @cuviper @joshtriplett

3 years agoRollup merge of #77322 - rust-lang:wesleywiser-patch-1, r=steveklabnik
Jonas Schievink [Wed, 30 Sep 2020 18:56:14 +0000 (20:56 +0200)]
Rollup merge of #77322 - rust-lang:wesleywiser-patch-1, r=steveklabnik

Add unstable book docs for `-Zunsound-mir-opts`

The `-Zunsound-mir-opts` flag was added in #76899.

3 years agoRollup merge of #77296 - tmiasko:liveness-option, r=ecstatic-morse
Jonas Schievink [Wed, 30 Sep 2020 18:56:12 +0000 (20:56 +0200)]
Rollup merge of #77296 - tmiasko:liveness-option, r=ecstatic-morse

liveness: Use Option::None to represent absent live nodes

No functional changes intended.

3 years agoRollup merge of #77284 - josephlr:mem, r=Mark-Simulacrum
Jonas Schievink [Wed, 30 Sep 2020 18:56:10 +0000 (20:56 +0200)]
Rollup merge of #77284 - josephlr:mem, r=Mark-Simulacrum

library: Forward compiler-builtins "mem" feature

This fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/53

Now users will be able to do:
```
cargo build -Zbuild-std=core -Zbuild-std-features=compiler-builtins-mem
```
and correctly get the Rust implemenations for `memcpy` and friends.

Signed-off-by: Joe Richey <joerichey@google.com>
3 years agoRollup merge of #77280 - petrochenkov:llvmcomp, r=Mark-Simulacrum
Jonas Schievink [Wed, 30 Sep 2020 18:56:09 +0000 (20:56 +0200)]
Rollup merge of #77280 - petrochenkov:llvmcomp, r=Mark-Simulacrum

Ensure that all LLVM components requested by tests are available on CI

Addresses https://github.com/rust-lang/rust/pull/75064#issuecomment-667722652

I used an environment variable because passing a command line option all the way from CI to compiletest would be just too much hassle for this task.
I added a new variable, but any of the already existing ones defined by CI could be used instead.
r? @Mark-Simulacrum

3 years agoRollup merge of #77233 - ssomers:btree_size_matters, r=Mark-Simulacrum
Jonas Schievink [Wed, 30 Sep 2020 18:56:07 +0000 (20:56 +0200)]
Rollup merge of #77233 - ssomers:btree_size_matters, r=Mark-Simulacrum

BTreeMap: keep an eye out on the size of the main components

r? @Mark-Simulacrum

3 years agoRollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPC
Jonas Schievink [Wed, 30 Sep 2020 18:56:05 +0000 (20:56 +0200)]
Rollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPC

more tiny clippy cleanups

commits stand alone and can be reviewed one by one

3 years agoRemove trailing space in error message
Camelid [Wed, 30 Sep 2020 18:29:19 +0000 (11:29 -0700)]
Remove trailing space in error message

3 years agoAuto merge of #75810 - hug-dev:cmse-nonsecure-entry, r=jonas-schievink
bors [Wed, 30 Sep 2020 18:43:48 +0000 (18:43 +0000)]
Auto merge of #75810 - hug-dev:cmse-nonsecure-entry, r=jonas-schievink

Add support for cmse_nonsecure_entry attribute

This pull request adds the `cmse_nonsecure_entry` attribute under an unstable feature.

I was not sure if it was fine for me to send directly the pull-request or if I should submit a RFC first. I was told on Zulip that it was fine to do so but please close it if I need first submit a RFC or follow another process instead.

The `cmse_nonsecure_entry` attribute is a LLVM attribute that will be available in LLVM 11. I plan to rebase on the [upgrade PR](https://github.com/rust-lang/rust/pull/73526) once merged to make this one compile.

This attribute modifies code generation of the function as explained [here](https://developer.arm.com/documentation/ecm0359818/latest/) to make it work with the TrustZone-M hardware feature. This feature is only available on `thumbv8m` targets so I created an error for that if one tries to use this attribute for another target.

I added this attribute in Rust as any other LLVM attribute are added but since this one is target-dependent I am not sure if it was the best thing to do. Please indicate me if you think of other ways, like isolating target-dependent attributes together.

----------------

Tracking issue: https://github.com/rust-lang/rust/issues/75835

3 years agoRemove E0019, use E0015 for inline assembly in a const
Dylan MacKenzie [Wed, 30 Sep 2020 16:58:01 +0000 (09:58 -0700)]
Remove E0019, use E0015 for inline assembly in a const

3 years agoBetter span for attribute suggestions
Dylan MacKenzie [Wed, 30 Sep 2020 16:48:18 +0000 (09:48 -0700)]
Better span for attribute suggestions

`def_span` has the same issues as `body.span`, so do it this way instead.

3 years agoAdd test for error message
Camelid [Wed, 30 Sep 2020 18:24:50 +0000 (11:24 -0700)]
Add test for error message

3 years agoAdd more tests and check for ABI
Hugues de Valon [Wed, 30 Sep 2020 17:10:17 +0000 (18:10 +0100)]
Add more tests and check for ABI

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
3 years agoAuto merge of #77298 - jyn514:bootstrap-config, r=Mark-Simulacrum
bors [Wed, 30 Sep 2020 15:03:09 +0000 (15:03 +0000)]
Auto merge of #77298 - jyn514:bootstrap-config, r=Mark-Simulacrum

Don't warn if the config file is somewhere other than `config.toml`

Previously, `config.config` was always hardcoded as `"config.toml"`.
I thought that it was being overridden with the actual value later, but
it turns out `flags.config` was being completely discarded. This keeps
`config.config` in sync with `flags.config`.

Fixes https://github.com/rust-lang/rust/issues/77293
r? `@Mark-Simulacrum`
cc `@davidtwco`

3 years agoAdd support for cmse_nonsecure_entry attribute
Hugues de Valon [Mon, 28 Sep 2020 20:10:38 +0000 (21:10 +0100)]
Add support for cmse_nonsecure_entry attribute

This patch adds support for the LLVM cmse_nonsecure_entry attribute.
This is a target-dependent attribute that only has sense for the
thumbv8m Rust targets.
You can find more information about this attribute here:
https://developer.arm.com/documentation/ecm0359818/latest/

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
3 years agoUpdate LLVM and add Unsupported diagnostic
Hugues de Valon [Tue, 29 Sep 2020 11:20:56 +0000 (12:20 +0100)]
Update LLVM and add Unsupported diagnostic

Secure entry functions do not support if arguments are passed on the
stack. An "unsupported" diagnostic will be emitted by LLVM if that is
the case.
This commits adds support in Rust for that diagnostic so that an error
will be output if that is the case!

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
3 years agoAuto merge of #77281 - tmiasko:liveness-everybody, r=oli-obk
bors [Wed, 30 Sep 2020 12:44:31 +0000 (12:44 +0000)]
Auto merge of #77281 - tmiasko:liveness-everybody, r=oli-obk

Liveness analysis for everybody

Perform liveness analysis for every body instead of limiting it to fns.

Fixes #77169.

3 years agoValidate `rustc_args_required_const`
varkor [Tue, 29 Sep 2020 16:44:32 +0000 (17:44 +0100)]
Validate `rustc_args_required_const`

3 years agoAuto merge of #77356 - RalfJung:miri, r=RalfJung
bors [Wed, 30 Sep 2020 10:08:28 +0000 (10:08 +0000)]
Auto merge of #77356 - RalfJung:miri, r=RalfJung

update miri

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

3 years agoupdate miri
Ralf Jung [Wed, 30 Sep 2020 07:19:28 +0000 (09:19 +0200)]
update miri

3 years agoReferences to ZSTs may be at arbitrary aligned addresses
Oliver Scherer [Wed, 30 Sep 2020 08:40:49 +0000 (10:40 +0200)]
References to ZSTs may be at arbitrary aligned addresses

3 years agoAuto merge of #77294 - shepmaster:try-anchors, r=pietroalbini
bors [Wed, 30 Sep 2020 07:57:48 +0000 (07:57 +0000)]
Auto merge of #77294 - shepmaster:try-anchors, r=pietroalbini

Use YAML anchors for try builds

r? `@pietroalbini`

3 years agoStable hashing: add comments and tests concerning platform-independence
Tyson Nottingham [Tue, 29 Sep 2020 00:34:27 +0000 (17:34 -0700)]
Stable hashing: add comments and tests concerning platform-independence

SipHasher128 implements short_write in an endian-independent way, yet
its write_xxx Hasher trait methods undo this endian-independence by byte
swapping the integer inputs on big-endian hardware. StableHasher then
adds endian-independence back by also byte-swapping on big-endian
hardware prior to invoking SipHasher128.

This double swap may have the appearance of being a no-op, but is in
fact by design. In particular, we really do want SipHasher128 to be
platform-dependent, in order to be consistent with the libstd SipHasher.
Try to clarify this intent. Also, add and update a couple of unit tests.

3 years agoAuto merge of #77292 - lzutao:std_asm, r=Amanieu
bors [Wed, 30 Sep 2020 05:27:16 +0000 (05:27 +0000)]
Auto merge of #77292 - lzutao:std_asm, r=Amanieu

Prefer asm! in std - all in sgx module

Similar to the change in #76669 but all `llvm_asm!` is gate in x86/x86_64 target.
Godbolt:
- https://rust.godbolt.org/z/h7nG1h
- https://rust.godbolt.org/z/xx39hW

3 years agoRewrite E0019 example
Dylan MacKenzie [Wed, 30 Sep 2020 04:09:45 +0000 (21:09 -0700)]
Rewrite E0019 example

Inline assembly is now the only user of E0019. What is it doing that
E0015 is not?

3 years agoRemove default `build_error` impl
Dylan MacKenzie [Wed, 30 Sep 2020 04:01:35 +0000 (21:01 -0700)]
Remove default `build_error` impl

Now all structured errors must have their own error code

3 years agoAuto merge of #77069 - sexxi-goose:closure_print_2, r=nikomatsakis
bors [Wed, 30 Sep 2020 03:10:47 +0000 (03:10 +0000)]
Auto merge of #77069 - sexxi-goose:closure_print_2, r=nikomatsakis

pretty.rs: Update Closure and Generator print

More detailed outline: https://github.com/rust-lang/project-rfc-2229/pull/17

Closes: https://github.com/rust-lang/project-rfc-2229/issues/11
r? `@nikomatsakis`
cc `@eddyb` `@davidtwco` `@estebank`

3 years agoUpdate `compile-fail` test
Dylan MacKenzie [Wed, 30 Sep 2020 02:45:06 +0000 (19:45 -0700)]
Update `compile-fail` test

3 years agoAdd test for issue #74761
samlich [Tue, 29 Sep 2020 19:46:01 +0000 (19:46 +0000)]
Add test for issue #74761

3 years agoRemove machinery for halting error output
Dylan MacKenzie [Wed, 30 Sep 2020 01:58:45 +0000 (18:58 -0700)]
Remove machinery for halting error output

3 years agoBless tests
Dylan MacKenzie [Wed, 30 Sep 2020 01:52:26 +0000 (18:52 -0700)]
Bless tests

3 years agoDon't stop const-checking after erroneous trait bound
Dylan MacKenzie [Wed, 30 Sep 2020 01:52:00 +0000 (18:52 -0700)]
Don't stop const-checking after erroneous trait bound

3 years agoBless output
Dylan MacKenzie [Wed, 30 Sep 2020 01:32:38 +0000 (18:32 -0700)]
Bless output

3 years agoEmit multiple function pointer errors from const-checker
Dylan MacKenzie [Wed, 30 Sep 2020 01:32:08 +0000 (18:32 -0700)]
Emit multiple function pointer errors from const-checker

3 years agoBless tests
Dylan MacKenzie [Wed, 30 Sep 2020 00:31:04 +0000 (17:31 -0700)]
Bless tests

3 years agoDon't emit duplicate errors for the return place
Dylan MacKenzie [Wed, 30 Sep 2020 00:30:07 +0000 (17:30 -0700)]
Don't emit duplicate errors for the return place

3 years agoPriority levels
Dylan MacKenzie [Wed, 30 Sep 2020 00:52:12 +0000 (17:52 -0700)]
Priority levels

3 years agoBless mut tests
Dylan MacKenzie [Tue, 29 Sep 2020 21:58:00 +0000 (14:58 -0700)]
Bless mut tests

3 years agoGive `MutDeref` a real error message
Dylan MacKenzie [Tue, 29 Sep 2020 21:40:14 +0000 (14:40 -0700)]
Give `MutDeref` a real error message

3 years agoRemove `ops::non_const`
Dylan MacKenzie [Tue, 29 Sep 2020 20:17:38 +0000 (13:17 -0700)]
Remove `ops::non_const`

This helper function was meant to reduce code duplication between
const-checking pre- and post-drop-elaboration. Most of the functionality
is only relevant for the pre-drop-elaboration pass.

3 years agoFix "unstable in stable" error
Dylan MacKenzie [Tue, 29 Sep 2020 20:18:43 +0000 (13:18 -0700)]
Fix "unstable in stable" error

The "otherwise" note is printed before the suggestion currently.

3 years agoReturn a `DiagnosticBuilder` from structured errors
Dylan MacKenzie [Tue, 29 Sep 2020 18:19:40 +0000 (11:19 -0700)]
Return a `DiagnosticBuilder` from structured errors

This ensures that `emit_error` will actually cause compilation to fail.

3 years agoForbid generator-specific MIR in all const-contexts
Dylan MacKenzie [Wed, 30 Sep 2020 02:20:05 +0000 (19:20 -0700)]
Forbid generator-specific MIR in all const-contexts

3 years ago`delay_span_bug` if const-checking an `async` function
Dylan MacKenzie [Wed, 30 Sep 2020 02:13:25 +0000 (19:13 -0700)]
`delay_span_bug` if const-checking an `async` function

This errors during AST lowering. Any errors we emit here are just noise.

3 years agoContinue after `impl Trait` in `const fn`
Dylan MacKenzie [Wed, 30 Sep 2020 02:13:11 +0000 (19:13 -0700)]
Continue after `impl Trait` in `const fn`

3 years agoAuto merge of #77133 - tmandry:bootstrap-host, r=Mark-Simulacrum
bors [Wed, 30 Sep 2020 00:59:12 +0000 (00:59 +0000)]
Auto merge of #77133 - tmandry:bootstrap-host, r=Mark-Simulacrum

bootstrap: Always build for host, even when target is given

This changes the behavior from *not* building for host whenever an
explicit target is specified. I find this much less confusing.

You can still disable host steps by passing an explicit empty list for
host.

Fixes #76990.

r? `@Mark-Simulacrum`

3 years agoContinue const-checking after errors when easy
Dylan MacKenzie [Tue, 29 Sep 2020 04:51:11 +0000 (21:51 -0700)]
Continue const-checking after errors when easy

This doesn't change any UI test output

3 years agoUseful derives on `mir::LocalKind`
Dylan MacKenzie [Wed, 30 Sep 2020 00:27:59 +0000 (17:27 -0700)]
Useful derives on `mir::LocalKind`

3 years agoliveness: Use Option::None to represent absent live nodes
Tomasz Miąsko [Wed, 30 Sep 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Use Option::None to represent absent live nodes

No functional changes intended.

3 years agoUpdate cargo
Eric Huss [Tue, 29 Sep 2020 22:55:35 +0000 (15:55 -0700)]
Update cargo

3 years agoFilter out empty items in bootstrap::flags::split
Tyler Mandry [Tue, 29 Sep 2020 22:50:57 +0000 (22:50 +0000)]
Filter out empty items in bootstrap::flags::split

3 years agoUpdate books
Eric Huss [Tue, 29 Sep 2020 22:36:08 +0000 (15:36 -0700)]
Update books

3 years agoAuto merge of #77289 - TimDiekmann:alloc-ref-by-ref, r=Amanieu
bors [Tue, 29 Sep 2020 22:13:37 +0000 (22:13 +0000)]
Auto merge of #77289 - TimDiekmann:alloc-ref-by-ref, r=Amanieu

Change `AllocRef::by_ref` to take `&self` instead of `&mut self`

r? `@Amanieu`

3 years agoLiveness analysis for everybody
Tomasz Miąsko [Mon, 28 Sep 2020 00:00:00 +0000 (00:00 +0000)]
Liveness analysis for everybody

Perform liveness analysis for every body instead of limiting it to fns.

3 years agoUse --host='' instead of --host ''
Tyler Mandry [Tue, 29 Sep 2020 20:13:52 +0000 (20:13 +0000)]
Use --host='' instead of --host ''

Trying to fix a problem in CI. Maybe some version of Docker is not
passing '' args correctly?

3 years agoAuto merge of #77274 - tmiasko:liveness-cnd, r=lcnr
bors [Tue, 29 Sep 2020 19:25:10 +0000 (19:25 +0000)]
Auto merge of #77274 - tmiasko:liveness-cnd, r=lcnr

Liveness refactoring continued

* Move body_owner field from IrMaps to Liveness (the only user of the field).
* Use upvars instead of FnKind to check for closures (avoids FnKind, will be useful when checking all bodies, not just fns).
* Use visit_param to add variables corresponding to params.
* Store upvars_mentioned inside Liveness struct.
* Inline visitor implementation for IrMaps, avoiding unnecessary indirection.
* Test interaction with automatically_derived attribute (not covered by any of existing tests).

No functional changes intended.

3 years agoAuto merge of #77145 - pietroalbini:refactor-build-manifest-versions, r=Mark-Simulacrum
bors [Tue, 29 Sep 2020 16:41:53 +0000 (16:41 +0000)]
Auto merge of #77145 - pietroalbini:refactor-build-manifest-versions, r=Mark-Simulacrum

Refactor versions detection in build-manifest

This PR refactors how `build-manifest` handles versions, making the following changes:

* `build-manifest` now detects the "package releases" on its own, without relying on rustbuild providing them through CLI arguments. This drastically simplifies calling the tool outside of `x.py`, and will allow to ship the prebuilt tool in a tarball in the future, with the goal of stopping to invoke `x.py` during `promote-release`.
* The `tar` command is not used to extract the version and the git hash from tarballs anymore. The `flate2` and `tar` crates are used instead. This makes detecting those pieces of data way faster, as the archive is decompressed just once and we stop parsing the archive once all the information is retrieved.
* The code to extract the version and the git hash now stores all the collected data dynamically, without requiring to add new fields to the `Builder` struct every time.

I tested the changes locally and it should behave the same as before.

r? `@Mark-Simulacrum`

3 years agoAlloc vec use imported path
Ivan Tham [Tue, 29 Sep 2020 15:00:02 +0000 (23:00 +0800)]
Alloc vec use imported path

mem::ManuallyDrop::new -> ManuallyDrop::new

3 years agoFix typo in alloc vec comment
Ivan Tham [Tue, 29 Sep 2020 14:33:57 +0000 (22:33 +0800)]
Fix typo in alloc vec comment

3 years agoAuto merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morse
bors [Tue, 29 Sep 2020 14:28:58 +0000 (14:28 +0000)]
Auto merge of #76754 - varkor:diagnostic-cleanup-ii, r=ecstatic-morse

Clean up diagnostics for arithmetic operation errors

Plus a small tweak to a range pattern error message.

3 years agoAuto merge of #77253 - jyn514:crate-link, r=Manishearth
bors [Tue, 29 Sep 2020 12:11:17 +0000 (12:11 +0000)]
Auto merge of #77253 - jyn514:crate-link, r=Manishearth

Resolve `crate` in intra-doc links properly across crates

Closes https://github.com/rust-lang/rust/issues/77193; see https://github.com/rust-lang/rust/issues/77193#issuecomment-699065946 for an explanation of what's going on here.
~~This also fixes the BTreeMap docs that have been broken for a while; see the description on the second commit for why and how.~~ Nope, see the second commit for why the link had to be changed.

r? `@Manishearth`
cc `@dylni`

`@dylni` note that this doesn't solve your original problem - now _both_ `with_code` and `crate::with_code` will be broken links. However this will fix a lot of other broken links (in particular I think https://docs.rs/sqlx/0.4.0-beta.1/sqlx/query/struct.Query.html is because of this bug). I'll open another issue for resolving additional docs in the new scope.

3 years agoAdd test for async/await combined with const-generics.
Hameer Abbasi [Tue, 29 Sep 2020 11:18:29 +0000 (13:18 +0200)]
Add test for async/await combined with const-generics.

3 years agoEnsure that all LLVM components requested by tests are available on CI
Vadim Petrochenkov [Sun, 27 Sep 2020 21:06:58 +0000 (00:06 +0300)]
Ensure that all LLVM components requested by tests are available on CI

3 years agoUse `rtassert!` instead of `assert!` from the child process after fork() in std:...
hyd-dev [Tue, 29 Sep 2020 07:16:46 +0000 (15:16 +0800)]
Use `rtassert!` instead of `assert!` from the child process after fork() in std::sys::unix::process::Command::spawn()

`assert!` panics on failure, which is not signal-safe.

3 years agoAuto merge of #77275 - petrochenkov:interpid, r=varkor
bors [Tue, 29 Sep 2020 05:14:36 +0000 (05:14 +0000)]
Auto merge of #77275 - petrochenkov:interpid, r=varkor

expand: Stop normalizing `NtIdent`s before passing them to built-in macros

Built-in macros should be able to deal with `NtIdents` in the input by themselves like any other parser code.

You can't imagine how bad mutable AST visitors are, *especially* if they are modifying tokens.
This is one step towards removing token visiting from the visitor infrastructure (https://github.com/rust-lang/rust/pull/77271 also works in this direction.)

3 years agoDon't fire `const_item_mutation` lint on writes through a pointer
Aaron Hill [Tue, 29 Sep 2020 03:51:57 +0000 (23:51 -0400)]
Don't fire `const_item_mutation` lint on writes through a pointer

Fixes #77321

3 years agoAdd unstable book docs for `-Zunsound-mir-opts`
Wesley Wiser [Tue, 29 Sep 2020 02:48:07 +0000 (22:48 -0400)]
Add unstable book docs for `-Zunsound-mir-opts`

3 years agoAuto merge of #77257 - ecstatic-morse:optimize-int-range-from-pat, r=Mark-Simulacrum
bors [Tue, 29 Sep 2020 02:29:13 +0000 (02:29 +0000)]
Auto merge of #77257 - ecstatic-morse:optimize-int-range-from-pat, r=Mark-Simulacrum

Optimize `IntRange::from_pat`, then shrink `ParamEnv`

Resolves #77058.

r? `@Mark-Simulacrum`
cc `@vandenheuvel`

Looking at the output of `perf report` for #76244, the hot instructions seemed to be around the call to `pat_constructor` in `IntRange::from_pat`. I carried out an obvious optimization, but it actually made the instruction count higher (see #77075). However, it seems to have mitigated whatever was causing the pipeline stalls, so when combined with #76244, it's a net win.

As you can see below, the regression in #76244 seems to have originated from something measured by `stalled-cycles-backend`. I'll try to collect some finer-grained stats to see if I can isolate it. I wish I had a better idea of what was going on here. I'd like to prevent the regression from reappearing in the future due to small changes in unrelated code.

<details>
<summary>Current `master`:</summary>

```
 Performance counter stats for 'cargo +baseline-stage1 check':

          2,275.67 msec task-clock:u              #    0.998 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,826      page-faults:u             #    0.022 M/sec
     5,117,221,678      cycles:u                  #    2.249 GHz
       299,655,943      stalled-cycles-frontend:u #    5.86% frontend cycles idle
     2,284,213,395      stalled-cycles-backend:u  #   44.64% backend cycles idle
     8,051,871,959      instructions:u            #    1.57  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,359,589,402      branches:u                #  597.447 M/sec
         7,359,347      branch-misses:u           #    0.54% of all branches

       2.281030026 seconds time elapsed

       2.108197000 seconds user
       0.164183000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` without changing `IntRange::from_pat`:</summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,751.79 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            50,103      page-faults:u             #    0.018 M/sec
     6,260,590,019      cycles:u                  #    2.275 GHz
       317,355,920      stalled-cycles-frontend:u #    5.07% frontend cycles idle
     3,397,743,582      stalled-cycles-backend:u  #   54.27% backend cycles idle
     8,276,224,367      instructions:u            #    1.32  insn per cycle
                                                  #    0.41  stalled cycles per insn
     1,370,453,386      branches:u                #  498.023 M/sec
         7,281,031      branch-misses:u           #    0.53% of all branches

       2.763265838 seconds time elapsed

       2.544578000 seconds user
       0.204548000 seconds sys
```
</details>

<details>
<summary>Shrink `ParamEnv` and change `IntRange::from_pat`: </summary>

```
 Performance counter stats for 'cargo +perf-stage1 check':

          2,295.57 msec task-clock:u              #    0.996 CPUs utilized
                 0      context-switches:u        #    0.000 K/sec
                 0      cpu-migrations:u          #    0.000 K/sec
            49,959      page-faults:u             #    0.022 M/sec
     5,151,407,066      cycles:u                  #    2.244 GHz
       324,517,829      stalled-cycles-frontend:u #    6.30% frontend cycles idle
     2,301,671,001      stalled-cycles-backend:u  #   44.68% backend cycles idle
     8,130,868,329      instructions:u            #    1.58  insn per cycle
                                                  #    0.28  stalled cycles per insn
     1,356,618,512      branches:u                #  590.972 M/sec
         7,323,800      branch-misses:u           #    0.54% of all branches

       2.304509653 seconds time elapsed

       2.128090000 seconds user
       0.163909000 seconds sys
```
</details>