Commit graph

128729 commits

Author SHA1 Message Date
Yuki Okushi
d4fdf6e754 Add a regression test for issue-74244 2020-10-01 14:10:44 +09:00
Yuki Okushi
50ffd6b7cb Add a regression test for issue-72565 2020-10-01 14:10:33 +09:00
Yuki Okushi
8631e1c575 Add a regression test for issue-68951 2020-10-01 14:10:23 +09:00
Yuki Okushi
c1e17f56ea Add a regression test for issue-66501 2020-10-01 14:09:57 +09:00
David Tolnay
41baa090ad
Skip dropck::check_drop_impl in is_const_item_without_destructor
adt_destructor by default also validates the Drop impl using
dropck::check_drop_impl, which contains an expect_local(). This
leads to ICE in check_const_item_mutation if the const's type is
not a local type.

    thread 'rustc' panicked at 'DefId::expect_local: `DefId(5:4805 ~ alloc[d7e9]::vec::{impl#50})` isn't local', compiler/rustc_span/src/def_id.rs:174:43
    stack backtrace:
       0: rust_begin_unwind
       1: rustc_span::def_id::DefId::expect_local::{{closure}}
       2: rustc_typeck::check::dropck::check_drop_impl
       3: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor::{{closure}}
       4: rustc_middle::ty::trait_def::<impl rustc_middle::ty::context::TyCtxt>::for_each_relevant_impl
       5: rustc_middle::ty::util::<impl rustc_middle::ty::context::TyCtxt>::calculate_dtor
       6: rustc_typeck::check::adt_destructor
       7: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::adt_destructor>::compute
       8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
       9: rustc_query_system::query::plumbing::get_query_impl
      10: rustc_mir::transform::check_const_item_mutation::ConstMutationChecker::is_const_item_without_destructor
2020-09-30 21:58:13 -07:00
David Tolnay
352ce8b299
Test a type with drop glue but no Drop impl 2020-09-30 21:58:07 -07:00
David Tolnay
0f6284c88d
Add test of const item mutation with Drop impl 2020-09-30 21:57:37 -07:00
David Tolnay
bb760b53bf
Simplify defid destructor check 2020-09-30 21:45:56 -07:00
David Tolnay
0dfe7b6434
Add justification of the destructor filter 2020-09-30 21:45:56 -07:00
David Tolnay
17db1cb5d5
Bypass const_item_mutation if const's type has Drop impl 2020-09-30 21:45:56 -07:00
bors
3bbc443cc6 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.
2020-10-01 03:28:50 +00:00
Scott McMurray
20202da09e Improve the example for ptr::copy
Fixes #77220
2020-09-30 20:00:09 -07:00
Ivan Tham
86e30b605c
Fix typo in vec doc "tries to reserves" 2020-10-01 10:08:51 +08:00
Carol (Nichols || Goulding)
2033eb1495
Write manifest for MAJOR.MINOR channel to enable rustup convenience
This connects to https://github.com/rust-lang/rustup/issues/794.

It's hard to remember if there have been patch releases for old versions
when you'd like to install the latest in a MAJOR.MINOR series.

When we're doing a stable release, we write duplicate manifests to
`stable`. With this change, only when we're doing a stable release, also
write duplicate manifests to `MAJOR.MINOR` to eventually enable rustup
(and any other tooling that builds Rust release URLs) to request, say,
`1.45` and get `1.45.2` (assuming `1.45.2` is the latest available
`1.45` and assuming that we never publish patch releases out of order).
2020-09-30 21:27:04 -04:00
bors
b218b952f8 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`
2020-10-01 01:12:41 +00:00
Dylan DPC
85e77edc82
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
2020-10-01 02:13:49 +02:00
Dylan DPC
cc1513b860
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
2020-10-01 02:13:48 +02:00
Dylan DPC
ffb771bc79
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)
2020-10-01 02:13:46 +02:00
Dylan DPC
849e5636ea
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.
2020-10-01 02:13:44 +02:00
Dylan DPC
73258f87ea
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
2020-10-01 02:13:43 +02:00
Dylan DPC
0044a9c084
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.~
2020-10-01 02:13:41 +02:00
Dylan DPC
70740b1b82
Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett
Rename AllocErr to AllocError

Implements rust-lang/wg-allocators#57
2020-10-01 02:13:39 +02:00
Dylan DPC
6d3cfd9d51
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.
2020-10-01 02:13:37 +02:00
Dylan DPC
f23559451b
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
2020-10-01 02:13:35 +02:00
Dylan DPC
37df40bd1c
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
2020-10-01 02:13:34 +02:00
Dylan DPC
8ccc063fbc
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.
2020-10-01 02:13:32 +02:00
Dylan DPC
8bd4ed9f95
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
2020-10-01 02:13:29 +02:00
Tomasz Miąsko
9845e7d5fb Use posix_spawn on musl targets
The posix_spawn had been available in a form suitable for use in a
Command implementation since musl 0.9.12. Use it in a preference to a
fork when possible, to benefit from CLONE_VM|CLONE_VFORK used there.
2020-10-01 00:00:00 +00:00
bors
9bb55dc864 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.
2020-09-30 23:04:16 +00:00
Camelid
2c5e2a6fc6 Improve wording for external crate resolution error
I think it reads better this way.
2020-09-30 16:03:01 -07:00
bors
ef663a8a48 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`
2020-09-30 20:49:27 +00:00
Vadim Petrochenkov
384eb2691f rustc_metadata: Do not forget to encode inherent impls for foreign types 2020-09-30 22:58:35 +03:00
Jonas Schievink
3624a90134
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)
2020-09-30 20:56:24 +02:00
Jonas Schievink
4202c60a59
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.
2020-09-30 20:56:22 +02:00
Jonas Schievink
fea2ad8a0a
Rollup merge of #77340 - pickfire:patch-9, r=kennytm
Alloc vec use imported path

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

cc @the8472
2020-09-30 20:56:21 +02:00
Jonas Schievink
054ba3db2d
Rollup merge of #77338 - pickfire:patch-7, r=jyn514
Fix typo in alloc vec comment

cc @the8472
2020-09-30 20:56:19 +02:00
Jonas Schievink
4e5178301b
Rollup merge of #77331 - hameerabbasi:issue-74906, r=lcnr
Add test for async/await combined with const-generics.

Fixes #74906.
2020-09-30 20:56:17 +02:00
Jonas Schievink
c46f5784a6
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
2020-09-30 20:56:15 +02:00
Jonas Schievink
b85081d46a
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.
2020-09-30 20:56:14 +02:00
Jonas Schievink
d4add198be
Rollup merge of #77296 - tmiasko:liveness-option, r=ecstatic-morse
liveness: Use Option::None to represent absent live nodes

No functional changes intended.
2020-09-30 20:56:12 +02:00
Jonas Schievink
87387fd23e
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>
2020-09-30 20:56:10 +02:00
Jonas Schievink
a4dc8dae02
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
2020-09-30 20:56:09 +02:00
Jonas Schievink
7ad03dd91d
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
2020-09-30 20:56:07 +02:00
Jonas Schievink
248d6bf1e2
Rollup merge of #77037 - matthiaskrgr:cl42ppy, r=Dylan-DPC
more tiny clippy cleanups

commits stand alone and can be reviewed one by one
2020-09-30 20:56:05 +02:00
Camelid
b2ce3e5344 Remove trailing space in error message 2020-09-30 11:52:42 -07:00
bors
867bd42c38 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
2020-09-30 18:43:48 +00:00
Dylan MacKenzie
1301f43119 Remove E0019, use E0015 for inline assembly in a const 2020-09-30 11:29:25 -07:00
Dylan MacKenzie
0c26144b1a Better span for attribute suggestions
`def_span` has the same issues as `body.span`, so do it this way instead.
2020-09-30 11:29:16 -07:00
Camelid
05d0b969d9 Add test for error message 2020-09-30 11:24:50 -07:00
Hugues de Valon
2588287def Add more tests and check for ABI
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2020-09-30 18:10:17 +01:00