]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoUpdate doc alias documentation
Guillaume Gomez [Wed, 16 Sep 2020 14:43:22 +0000 (16:43 +0200)]
Update doc alias documentation

3 years agoUpdate tests
Guillaume Gomez [Wed, 16 Sep 2020 14:42:06 +0000 (16:42 +0200)]
Update tests

3 years agoRemove unneeded replace
Guillaume Gomez [Wed, 16 Sep 2020 22:20:14 +0000 (00:20 +0200)]
Remove unneeded replace

3 years agoForbid some characters to be used as doc alias
Guillaume Gomez [Wed, 16 Sep 2020 14:41:45 +0000 (16:41 +0200)]
Forbid some characters to be used as doc alias

3 years agoAuto merge of #76781 - RalfJung:rollup-ve66o2j, r=RalfJung
bors [Wed, 16 Sep 2020 06:46:24 +0000 (06:46 +0000)]
Auto merge of #76781 - RalfJung:rollup-ve66o2j, r=RalfJung

Rollup of 10 pull requests

Successful merges:

 - #76056 (Add more info for Vec Drain doc)
 - #76062 (Vec slice example fix style and show type elision)
 - #76262 (Use inline(never) instead of cold)
 - #76335 (Make all methods of `Duration` unstably const)
 - #76366 (Add Arith Tests in Library)
 - #76369 (Move Various str tests in library)
 - #76534 (Add doc comments for From impls)
 - #76622 (Update bootstrap readme)
 - #76641 (Some cleanup changes and commenting)
 - #76662 (Fix liballoc test suite for Miri)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-Simulacrum
Ralf Jung [Wed, 16 Sep 2020 06:25:02 +0000 (08:25 +0200)]
Rollup merge of #76662 - RalfJung:lib-test-miri, r=Mark-Simulacrum

Fix liballoc test suite for Miri

Mostly, fix the regression introduced by https://github.com/rust-lang/rust/pull/75207 that caused slices (i.e., references) to be created to invalid memory or memory that has aliasing pointers that we want to keep valid. @dylni  this changes the type of `check_range` to only require the length, not the full reference to the slice, which indeed is all the information this function requires.

Also reduce the size of a test introduced in https://github.com/rust-lang/rust/pull/70793 to make it not take 3 minutes in Miri.

This makes https://github.com/RalfJung/miri-test-libstd work again.

3 years agoRollup merge of #76641 - nox:pointee-random-stuff, r=eddyb
Ralf Jung [Wed, 16 Sep 2020 06:25:00 +0000 (08:25 +0200)]
Rollup merge of #76641 - nox:pointee-random-stuff, r=eddyb

Some cleanup changes and commenting

r? @nikomatsakis
Cc @eddyb

3 years agoRollup merge of #76622 - jyn514:bootstrap-readme, r=Mark-Simulacrum
Ralf Jung [Wed, 16 Sep 2020 06:24:58 +0000 (08:24 +0200)]
Rollup merge of #76622 - jyn514:bootstrap-readme, r=Mark-Simulacrum

Update bootstrap readme

- Reflect changes in x.py defaults
- Remove recommendation to use nightly for incremental; it works fine on
beta
- Remove note that incremental chooses stage 1 by default; stage 1 is
already the default
- Update Discord -> Zulip

r? @Mark-Simulacrum

3 years agoRollup merge of #76534 - notriddle:doc-comments, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:56 +0000 (08:24 +0200)]
Rollup merge of #76534 - notriddle:doc-comments, r=jyn514

Add doc comments for From impls

https://github.com/rust-lang/rust/issues/51430

3 years agoRollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:54 +0000 (08:24 +0200)]
Rollup merge of #76369 - ayushmishra2005:move_various_str_tests_library, r=jyn514

Move Various str tests in library

Moved various string ui  tests in library  as a part of #76268

r? @matklad

3 years agoRollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:52 +0000 (08:24 +0200)]
Rollup merge of #76366 - ayushmishra2005:arith_tests_in_library, r=jyn514

Add Arith Tests in Library

Added Arith Tests library as a part of #76268

r? @matklad

3 years agoRollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse
Ralf Jung [Wed, 16 Sep 2020 06:24:50 +0000 (08:24 +0200)]
Rollup merge of #76335 - CDirkx:const-duration, r=ecstatic-morse

Make all methods of `Duration` unstably const

Make the following methods of `Duration` unstable const under `duration_const_2`:
 - `from_secs_f64`
 - `from_secs_f32`
 - `mul_f64`
 - `mul_f32`
 - `div_f64`
 - `div_f32`

This results in all methods of `Duration` being (unstable) const.

Moved the tests to `library` as part of #76268.

Possible because of #72449, which made the relevant `f32` and `f64` methods const.

Tracking issue: #72440

r? @ecstatic-morse

3 years agoRollup merge of #76262 - howard0su:patch-1, r=cramertj
Ralf Jung [Wed, 16 Sep 2020 06:24:49 +0000 (08:24 +0200)]
Rollup merge of #76262 - howard0su:patch-1, r=cramertj

Use inline(never) instead of cold

inline(never) is better way to avoid optimizer to inline the function instead of cold.

3 years agoRollup merge of #76062 - pickfire:patch-13, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:46 +0000 (08:24 +0200)]
Rollup merge of #76062 - pickfire:patch-13, r=jyn514

Vec slice example fix style and show type elision

3 years agoRollup merge of #76056 - pickfire:patch-10, r=jyn514
Ralf Jung [Wed, 16 Sep 2020 06:24:40 +0000 (08:24 +0200)]
Rollup merge of #76056 - pickfire:patch-10, r=jyn514

Add more info for Vec Drain doc

See its documentation for more

3 years agoAuto merge of #76625 - jyn514:default-stages, r=Mark-Simulacrum
bors [Wed, 16 Sep 2020 04:05:22 +0000 (04:05 +0000)]
Auto merge of #76625 - jyn514:default-stages, r=Mark-Simulacrum

Make the default stage for x.py configurable

This also allows configuring each sub-command individually.

Possibly #76617 should land before this? I don't feel strongly either way, I don't mind waiting.

Closes https://github.com/rust-lang/rust/issues/76165.
r? `@Mark-Simulacrum`

3 years agoAuto merge of #76771 - Dylan-DPC:rollup-qj4j3ma, r=Dylan-DPC
bors [Wed, 16 Sep 2020 00:56:12 +0000 (00:56 +0000)]
Auto merge of #76771 - Dylan-DPC:rollup-qj4j3ma, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #73955 (deny(unsafe_op_in_unsafe_fn) in libstd/process.rs)
 - #75146 (Detect overflow in proc_macro_server subspan)
 - #75304 (Note when a a move/borrow error is caused by a deref coercion)
 - #75749 (Consolidate some duplicate code in the sys modules.)
 - #75882 (Use translated variable for test string)
 - #75886 (Test that bounds checks are elided for [..index] after .position())
 - #76048 (Initial support for riscv32gc_unknown_linux_gnu)
 - #76198 (Make some Ordering methods const)
 - #76689 (Upgrade to pulldown-cmark 0.8.0)
 - #76763 (Update cargo)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76763 - ehuss:update-cargo, r=ehuss
Dylan DPC [Tue, 15 Sep 2020 23:30:45 +0000 (01:30 +0200)]
Rollup merge of #76763 - ehuss:update-cargo, r=ehuss

Update cargo

6 commits in 875e0123259b0b6299903fe4aea0a12ecde9324f..8777a6b1e8834899f51b7e09cc9b8d85b2417110
2020-09-08 20:17:21 +0000 to 2020-09-15 19:11:03 +0000
- updated yank error message (rust-lang/cargo#8697)
- Fix non-determinism with new feature resolver. (rust-lang/cargo#8701)
- Display formatted output for JSON diffing in tests. (rust-lang/cargo#8692)
- Add --name suggestion for cargo new (rust-lang/cargo#8675)
- Sweep unrelated message from unnecessary workspace infromation (rust-lang/cargo#8681)
- Docs: Make it more clear we have two types of workspaces (rust-lang/cargo#8666)

3 years agoRollup merge of #76689 - jyn514:update-pulldown, r=GuillaumeGomez
Dylan DPC [Tue, 15 Sep 2020 23:30:44 +0000 (01:30 +0200)]
Rollup merge of #76689 - jyn514:update-pulldown, r=GuillaumeGomez

Upgrade to pulldown-cmark 0.8.0

Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs!

- Get rid of unnecessary `RefCell`
- Fix duplicate warnings for broken implicit reference link
- Remove unnecessary copy of links

Closes https://github.com/rust-lang/rust/issues/73264, closes https://github.com/rust-lang/rust/issues/76687.
r? @euclio

I'm not sure if the switch away from `locate` fixes any open bugs - euclio mentioned some in https://github.com/raphlinus/pulldown-cmark/issues/165, but I didn't see any related issues open for rustdoc. Let me know if I missed one.

3 years agoRollup merge of #76198 - CDirkx:const-ordering, r=dtolnay
Dylan DPC [Tue, 15 Sep 2020 23:30:42 +0000 (01:30 +0200)]
Rollup merge of #76198 - CDirkx:const-ordering, r=dtolnay

Make some Ordering methods const

Resubmission of [PR#75463](https://github.com/rust-lang/rust/pull/75463) as per [PR#76172](https://github.com/rust-lang/rust/pull/76172).

Constify the following methods of `core::cmp::Ordering`:
 - `reverse`
 - `then`

Insta-stabilizes these methods as const under the `const_ordering` feature, as their implementation is a trivial match and the recent stabilization of #49146 (Allow `if` and `match` in constants).
Note: the `const_ordering` feature has never actually been used as these methods have not been `#[rustc_const_unstable]`.

Tracking issue:  #76113

3 years agoRollup merge of #76048 - alistair23:alistair/rv32-linux, r=Amanieu
Dylan DPC [Tue, 15 Sep 2020 23:30:40 +0000 (01:30 +0200)]
Rollup merge of #76048 - alistair23:alistair/rv32-linux, r=Amanieu

Initial support for riscv32gc_unknown_linux_gnu

Now that RISC-V 32-bit (RV32) support is in upstream glibc let's add support for userspace Rust.

3 years agoRollup merge of #75886 - erikdesjardins:index, r=nikic
Dylan DPC [Tue, 15 Sep 2020 23:30:38 +0000 (01:30 +0200)]
Rollup merge of #75886 - erikdesjardins:index, r=nikic

Test that bounds checks are elided for [..index] after .position()

Closes #73396.

This was fixed by the LLVM 11 update in #73526.

3 years agoRollup merge of #75882 - pickfire:patch-6, r=jyn514
Dylan DPC [Tue, 15 Sep 2020 23:30:36 +0000 (01:30 +0200)]
Rollup merge of #75882 - pickfire:patch-6, r=jyn514

Use translated variable for test string

Test should be educative, added english translation and pronounciation.

3 years agoRollup merge of #75749 - ehuss:consolidate-sys, r=alexcrichton
Dylan DPC [Tue, 15 Sep 2020 23:30:34 +0000 (01:30 +0200)]
Rollup merge of #75749 - ehuss:consolidate-sys, r=alexcrichton

Consolidate some duplicate code in the sys modules.

This consolidates some modules which were duplicated throughout the sys module. The intent is to make it easier to update and maintain this code. This mainly affects the wasi, sgx, and "unsupported" targets.

I explicitly skipped hermit, cloudabi, and vxworks. These tier-3 targets have copied large sections of the sys tree. I don't think they should have, but I don't want to put effort into changing them. It also doesn't help that there aren't any scripts or instructions for building them.

There are still sections of duplicate code here and there, but this PR covers the easy parts where entire modules are the same.

3 years agoRollup merge of #75304 - Aaron1011:feature/diag-deref-move-out, r=estebank
Dylan DPC [Tue, 15 Sep 2020 23:30:32 +0000 (01:30 +0200)]
Rollup merge of #75304 - Aaron1011:feature/diag-deref-move-out, r=estebank

Note when a a move/borrow error is caused by a deref coercion

Fixes #73268

When a deref coercion occurs, we may end up with a move error if the
base value has been partially moved out of. However, we do not indicate
anywhere that a deref coercion is occuring, resulting in an error
message with a confusing span.

This PR adds an explicit note to move errors when a deref coercion is
involved. We mention the name of the type that the deref-coercion
resolved to, as well as the `Deref::Target` associated type being used.

3 years agoRollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum
Dylan DPC [Tue, 15 Sep 2020 23:30:30 +0000 (01:30 +0200)]
Rollup merge of #75146 - tmiasko:range-overflow, r=Mark-Simulacrum

Detect overflow in proc_macro_server subspan

* Detect overflow in proc_macro_server subspan
* Add tests for overflow in Vec::drain
* Add tests for overflow in String / VecDeque operations using ranges

3 years agoRollup merge of #73955 - hellow554:unsafe_process, r=Mark-Simulacrum
Dylan DPC [Tue, 15 Sep 2020 23:30:28 +0000 (01:30 +0200)]
Rollup merge of #73955 - hellow554:unsafe_process, r=Mark-Simulacrum

deny(unsafe_op_in_unsafe_fn) in libstd/process.rs

The libstd/process.rs part of #73904 . Wraps the two calls to an unsafe fn Initializer::nop() in an unsafe block.

Will have to wait for #73909 to be merged, because of the feature in the libstd/lib.rs

3 years agoAuto merge of #76755 - pietroalbini:gha-macos, r=Mark-Simulacrum
bors [Tue, 15 Sep 2020 22:51:44 +0000 (22:51 +0000)]
Auto merge of #76755 - pietroalbini:gha-macos, r=Mark-Simulacrum

Gate macOS on both Azure and GHA

As discussed in the previous infrastructure team meeting, this PR gates macOS builds on both GHA and Azure. Once this is merged we'll wait a week or two to see if there is a troublesome rate of spurious failures, and if not we'll remove the builds on the Azure side.

r? `@Mark-Simulacrum`
cc #71988

3 years agoUpdate cargo
Eric Huss [Tue, 15 Sep 2020 21:52:18 +0000 (14:52 -0700)]
Update cargo

3 years agohopefully fix rustdoc links
Ralf Jung [Tue, 15 Sep 2020 21:46:26 +0000 (23:46 +0200)]
hopefully fix rustdoc links

3 years agofix slice::check_range aliasing problems
Ralf Jung [Sun, 13 Sep 2020 10:14:59 +0000 (12:14 +0200)]
fix slice::check_range aliasing problems

3 years agoreduce size of test_from_iter_specialization_with_iterator_adapters test in Miri
Ralf Jung [Sun, 13 Sep 2020 09:27:21 +0000 (11:27 +0200)]
reduce size of test_from_iter_specialization_with_iterator_adapters test in Miri

3 years agoAuto merge of #73595 - SNCPlay42:lifetime-after-mut, r=Mark-Simulacrum
bors [Tue, 15 Sep 2020 21:01:30 +0000 (21:01 +0000)]
Auto merge of #73595 - SNCPlay42:lifetime-after-mut, r=Mark-Simulacrum

improve diagnostics for lifetime after `&mut`

If, when parsing a borrow pointee type, we see a lifetime after `mut`, suggest placing the lifetime before `mut` and eat the lifetime to avoid a large number of unhelpful diagnostics.

There are some subtleties to avoid false positives in cases like `&mut 'a + Trait`, where `&mut ('a + Trait)` is a better suggestion.

fixes #73568

3 years agoci: gate macOS on GHA too
Pietro Albini [Tue, 15 Sep 2020 19:56:07 +0000 (21:56 +0200)]
ci: gate macOS on GHA too

3 years agoAuto merge of #73166 - jethrogb:stdarch, r=Amanieu
bors [Tue, 15 Sep 2020 19:04:40 +0000 (19:04 +0000)]
Auto merge of #73166 - jethrogb:stdarch, r=Amanieu

Update stdarch

This PR **changes the public signature** of the following functions in `core::arch::{x86, x86_64}`:
```patch
-pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i8
+pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i32
-pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i16
+pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i32
```

This change is desired so that these signatures
* are similar to those of the 128-bit versions `_mm_extract_epi8` and `_mm_extract_epi16`
* match the Intel definitions for the intrinsics
  * [RFC 2325](https://github.com/rust-lang/rfcs/blob/master/text/2325-stable-simd.md) specifies that the exact vendor function signatures should be used

A [crater run](https://github.com/rust-lang/rust/pull/73166#issuecomment-667230319) revealed only a single breakage. The [vektor crate](https://github.com/AdamNiederer/vektor/blob/master/src/x86/avx2.rs#L2436-L2472) copied the incorrect signatures in `core` exactly to their own crate. The functions don't seem to be used by anyone anywhere.

Actual breakage is not expected, since due to the nature of the functions, users would generally write `_mm256_extract_epi8(...) as u8` or `_mm256_extract_epi16(...) as u16`.

See https://github.com/rust-lang/stdarch/pull/868/. Note that the changes from that stdarch PR have already partially landed in core after https://github.com/rust-lang/stdarch/pull/878/. This PR is now only about the remaining changes.

3 years agoAuto merge of #75148 - joechrisellis:master, r=Amanieu
bors [Tue, 15 Sep 2020 17:05:57 +0000 (17:05 +0000)]
Auto merge of #75148 - joechrisellis:master, r=Amanieu

Implementation of peer credentials for Unix sockets

The code in `ucred.rs` is based on the work done in [PR 13](https://github.com/tokio-rs/tokio-uds/pull/13) in the tokio-uds repository on GitHub.

This commit is effectively a port to the stdlib, so credit to Martin Habovštiak (`@Kixunil)` and contributors for the meat of this work. 🥇

Happy to make changes as needed. 🙂

3 years agoUpdate stdarch
Jethro Beekman [Tue, 8 Sep 2020 12:17:15 +0000 (14:17 +0200)]
Update stdarch

3 years agoMake the default stage for x.py configurable
Joshua Nelson [Sat, 12 Sep 2020 02:17:16 +0000 (22:17 -0400)]
Make the default stage for x.py configurable

This allows configuring the default stage for each sub-command individually.

- Normalize the stage as early as possible, so there's no confusion
  about which to use.
- Don't add an explicit `stage` option in config.toml

  This offers no more flexibility than `*_stage` and makes it confusing
  which takes precedence.

- Always give `--stage N` precedence over config.toml
- Fix bootstrap tests

  This changes the tests to go through `Config::parse` so that they test
  the actual defaults, not the dummy ones provided by `default_opts`.  To
  make this workable (and independent of the environment), it does not
  read `config.toml` for tests.

3 years agodoc: platform-support.md: Move to tier 3
Alistair Francis [Tue, 15 Sep 2020 15:13:01 +0000 (08:13 -0700)]
doc: platform-support.md: Move to tier 3

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoAuto merge of #76708 - Mark-Simulacrum:lld-macos, r=alexcrichton
bors [Tue, 15 Sep 2020 15:06:59 +0000 (15:06 +0000)]
Auto merge of #76708 - Mark-Simulacrum:lld-macos, r=alexcrichton

Always try to promote shared LLVM to the sysroot

Even when LLVM is not generally participating in a shared link with rustc, we
will likely still link to the shared dylib from rust-lld, so we still need to
promote it.

This reverts part of #76349; my expectation that the link-shared rule was sufficient was likely wrong.

Hopefully fixes #76698.

r? `@alexcrichton`

3 years agodoc: platform-support.md: Document port
Alistair Francis [Tue, 15 Sep 2020 14:58:33 +0000 (07:58 -0700)]
doc: platform-support.md: Document port

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoimprove diagnostics for lifetime after `&mut`
SNCPlay42 [Sun, 21 Jun 2020 20:37:17 +0000 (21:37 +0100)]
improve diagnostics for lifetime after `&mut`

3 years agoEnable shared linking to LLVM on non-Windows
Mark Rousskov [Mon, 14 Sep 2020 20:22:56 +0000 (16:22 -0400)]
Enable shared linking to LLVM on non-Windows

Windows doesn't quite support dynamic linking to LLVM yet, but on other
platforms we do. In #76708, it was discovered that we dynamically link to LLVM
from the LLVM tools (e.g., rust-lld), so we need the shared LLVM library to link
against. That means that if we do not have a shared link to LLVM, and want LLVM
tools to work, we'd be shipping two copies of LLVM on all of these platforms:
one in librustc_driver and one in libLLVM.

Also introduce an error into rustbuild if we do end up configured for shared
linking on Windows.

3 years agoConsolidate wasi::process and unsupported::process
Eric Huss [Thu, 20 Aug 2020 18:22:46 +0000 (11:22 -0700)]
Consolidate wasi::process and unsupported::process

3 years agoConsolidate wasi alloc with unix alloc.
Eric Huss [Thu, 20 Aug 2020 18:00:41 +0000 (11:00 -0700)]
Consolidate wasi alloc with unix alloc.

3 years agoConsolidate byte-identical modules.
Eric Huss [Thu, 20 Aug 2020 17:45:18 +0000 (10:45 -0700)]
Consolidate byte-identical modules.

3 years agoAuto merge of #76311 - lzutao:split_core-slice, r=lcnr
bors [Tue, 15 Sep 2020 12:15:59 +0000 (12:15 +0000)]
Auto merge of #76311 - lzutao:split_core-slice, r=lcnr

Split `core::slice` to smaller mods

Unfortunately the `#[lang = "slice"]` is too big (3003 lines), I cannot split it further.

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:
  ```
  git show --reverse --color-moved=dimmed-zebra master..
  ```

---

I split core/slice/mod.rs to these modules:

* `ascii`: For operations on `[u8]`.
* `cmp`: For comparison operations on `[T]`, like PartialEq and SliceContains impl.
* `index`: For indexing operations like Index/IndexMut and SliceIndex.
* `iter`: For Iterator definitions and implementation on `[T]`.
  - `macros`: For iterator! and forward_iterator! macros.
* `raw`: For free function to create `&[T]` or `&mut [T]` from pointer + length or a reference.

The heapsort wrapper in mod.rs is removed in favor of reexport from `sort::heapsort`.

3 years agoFix clippy hard-code slice::Iter path
Lzu Tao [Tue, 15 Sep 2020 10:21:40 +0000 (10:21 +0000)]
Fix clippy hard-code slice::Iter path

3 years agoAuto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwco
bors [Tue, 15 Sep 2020 10:14:52 +0000 (10:14 +0000)]
Auto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwco

Detect turbofish with multiple type params missing leading `::`

Fix #76072.

3 years agoAuto merge of #76684 - jyn514:refactor-intra-links, r=manishearth
bors [Tue, 15 Sep 2020 07:42:13 +0000 (07:42 +0000)]
Auto merge of #76684 - jyn514:refactor-intra-links, r=manishearth

Refactor intra doc link code

I got tired of `fold_item` being 500 lines long.
This is best reviewed one commit at a time with whitespace changes hidden.
There are no logic changes other than the last commit making a parameter checked by the caller instead of the callee.

r? `@Manishearth`

3 years agoVec doc use elision as code rather than comment
Ivan Tham [Tue, 15 Sep 2020 06:41:43 +0000 (14:41 +0800)]
Vec doc use elision as code rather than comment

3 years agoAuto merge of #76682 - richkadel:vec-take, r=Mark-Simulacrum
bors [Tue, 15 Sep 2020 05:01:17 +0000 (05:01 +0000)]
Auto merge of #76682 - richkadel:vec-take, r=Mark-Simulacrum

Optimize behavior of vec.split_off(0) (take all)

Optimization improvement to `split_off()` so the performance meets the
intuitively expected behavior when `at == 0`, avoiding the current behavior
of copying the entire vector.

The change honors documented behavior that the original vector's
"previous capacity unchanged".

This improvement better supports the pattern for building and flushing a
buffer of elements, such as the following:

```rust
    let mut vec = Vec::new();
    loop {
        vec.push(something);
        if condition_is_met {
            process(vec.split_off(0));
        }
    }
```

`Option` wrapping is the first alternative I thought of, but is much
less obvious and more verbose:

```rust
    let mut capacity = 1;
    let mut vec: Option<Vec<Stuff>> = None;
    loop {
        vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something);
        if condition_is_met {
            capacity = vec.capacity();
            process(vec.take().unwrap());
        }
    }
```

Directly using `mem::replace()` (instead of  calling`split_off()`) could work,
but `mem::replace()` is a more advanced tool for Rust developers, and in
this case, I believe developers would assume the standard library should
be sufficient for the purpose described here.

The benefit of the approach to this change is it does not change the
existing API contract, but improves the peformance of `split_off(0)` for
`Vec`, `String` (which delegates `split_off()` to `Vec`), and any other
existing use cases.

This change adds tests to validate the behavior of `split_off()` with
regard to capacity, as originally documented, and confirm that behavior
still holds, when `at == 0`.

The change is an implementation detail, and does not require a
documentation change, but documenting the new behavior as part of its
API contract may benefit future users.

(Let me know if I should make that documentation update.)

Note, for future consideration:

I think it would be helpful to introduce an additional method to `Vec`
(if not also to `String`):

```
    pub fn take_all(&mut self) -> Self {
        self.split_off(0)
    }
```

This would make it more clear how `Vec` supports the pattern, and make
it easier to find, since the behavior is similar to other `take()`
methods in the Rust standard library.

r? `@wesleywiser`
FYI: `@tmandry`

3 years agoTest that bounds checks are elided for indexing after .[r]position()
Erik Desjardins [Mon, 24 Aug 2020 17:15:20 +0000 (13:15 -0400)]
Test that bounds checks are elided for indexing after .[r]position()

3 years agoAuto merge of #74532 - fusion-engineering-forks:atomic-from-mut, r=KodrAus
bors [Tue, 15 Sep 2020 02:09:34 +0000 (02:09 +0000)]
Auto merge of #74532 - fusion-engineering-forks:atomic-from-mut, r=KodrAus

Add Atomic*::from_mut.

The atomic equivalent of [`Cell::from_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.from_mut).

3 years agolibrustc_target: Address comments
Alistair Francis [Tue, 15 Sep 2020 00:43:06 +0000 (17:43 -0700)]
librustc_target: Address comments

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
3 years agolibrustc_target: Initial support for riscv32gc_unknown_linux_gnu
Alistair Francis [Tue, 7 Jul 2020 20:35:55 +0000 (13:35 -0700)]
librustc_target: Initial support for riscv32gc_unknown_linux_gnu

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoAuto merge of #76612 - estebank:pat-missing-fields-suggestion, r=davidtwco
bors [Tue, 15 Sep 2020 00:17:13 +0000 (00:17 +0000)]
Auto merge of #76612 - estebank:pat-missing-fields-suggestion, r=davidtwco

Provide suggestion for missing fields in patterns

3 years agoAuto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco
bors [Mon, 14 Sep 2020 21:43:17 +0000 (21:43 +0000)]
Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco

use sort_unstable to sort primitive types

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive

3 years agoAuto merge of #75608 - estebank:suggest-boxed-match-exprs, r=lcnr,varkor
bors [Mon, 14 Sep 2020 19:57:57 +0000 (19:57 +0000)]
Auto merge of #75608 - estebank:suggest-boxed-match-exprs, r=lcnr,varkor

More structured suggestions for boxed trait objects instead of impl Trait on non-coerceable tail expressions

When encountering a `match` or `if` as a tail expression where the
different arms do not have the same type *and* the return type of that
`fn` is an `impl Trait`, check whether those arms can implement `Trait`
and if so, suggest using boxed trait objects.

Use structured suggestion for `impl T` to `Box<dyn T>`.

Fix https://github.com/rust-lang/rust/issues/69107

3 years agoFix rebase and add comments
Esteban Küber [Sat, 12 Sep 2020 00:20:56 +0000 (17:20 -0700)]
Fix rebase and add comments

3 years agoDetect turbofish with multiple type params missing leading `::`
Esteban Küber [Mon, 31 Aug 2020 17:24:37 +0000 (10:24 -0700)]
Detect turbofish with multiple type params missing leading `::`

Fix #76072.

3 years agoAuto merge of #76278 - jethrogb:jb/sgx-rwlock-init-test, r=Mark-Simulacrum
bors [Mon, 14 Sep 2020 18:04:18 +0000 (18:04 +0000)]
Auto merge of #76278 - jethrogb:jb/sgx-rwlock-init-test, r=Mark-Simulacrum

Improve SGX RWLock initializer test

r? `@eddyb`

This addresses https://github.com/pnkfelix/rust/pull/1#discussion_r374239895

Fixes https://github.com/fortanix/rust-sgx/issues/213

3 years agoAuto merge of #75740 - GuillaumeGomez:stabilize-doc-alias-feature, r=ollie27
bors [Mon, 14 Sep 2020 10:56:30 +0000 (10:56 +0000)]
Auto merge of #75740 - GuillaumeGomez:stabilize-doc-alias-feature, r=ollie27

Stabilize doc_alias feature

Fixes #50146.

This PR intend to stabilize the `doc_alias` feature. The last remaining bits were missing checks on the attribute usage and on its arguments. Both have been added so I think we can now move to the next step.

r? `@ollie27`

cc `@rust-lang/rustdoc`

3 years agoRemoved outdated comments
Lzu Tao [Fri, 4 Sep 2020 15:15:18 +0000 (15:15 +0000)]
Removed outdated comments

3 years agoMove ascii to new module
Lzu Tao [Fri, 4 Sep 2020 01:45:11 +0000 (01:45 +0000)]
Move ascii to new module

3 years agomove indexing impl to new mod
Lzu Tao [Fri, 4 Sep 2020 02:26:45 +0000 (02:26 +0000)]
move indexing impl to new mod

3 years agoMove free functions to a new module
Lzu Tao [Fri, 4 Sep 2020 04:46:02 +0000 (04:46 +0000)]
Move free functions to a new module

3 years agoMove iterator impls to a new module
Lzu Tao [Thu, 3 Sep 2020 15:51:57 +0000 (15:51 +0000)]
Move iterator impls to a new module

3 years agoFix peer credentials for Android
Joe Ellis [Thu, 10 Sep 2020 08:11:49 +0000 (09:11 +0100)]
Fix peer credentials for Android

3 years agoConditionally compile peer credentials feature for supported platforms
Joe Ellis [Tue, 8 Sep 2020 15:08:21 +0000 (16:08 +0100)]
Conditionally compile peer credentials feature for supported platforms

3 years agoAdd documentation to public fields of UCred struct
Joe Ellis [Tue, 8 Sep 2020 12:11:13 +0000 (13:11 +0100)]
Add documentation to public fields of UCred struct

3 years agoMove Unix peer credentials tests to their own file
Joe Ellis [Tue, 8 Sep 2020 09:31:56 +0000 (10:31 +0100)]
Move Unix peer credentials tests to their own file

3 years agoAdd pid as an option to UCred struct
Joe Ellis [Tue, 8 Sep 2020 08:41:23 +0000 (09:41 +0100)]
Add pid as an option to UCred struct

Currently, PID will be populated for Linux, and set to None for BSDs.

3 years agoUse `u32::MAX` instead of `u32::max_value`
Joe Ellis [Wed, 5 Aug 2020 14:47:45 +0000 (15:47 +0100)]
Use `u32::MAX` instead of `u32::max_value`

Co-authored-by: lzutao <taolzu@gmail.com>
3 years agoAdd basic test for Unix peer credentials
Joe Ellis [Wed, 5 Aug 2020 11:19:05 +0000 (12:19 +0100)]
Add basic test for Unix peer credentials

3 years agoRemove use of `MaybeUninit` in `ucred.rs`
Joe Ellis [Wed, 5 Aug 2020 11:18:32 +0000 (12:18 +0100)]
Remove use of `MaybeUninit` in `ucred.rs`

We can simply init the struct directly. There is no real need to use
uninit memory here.

3 years agoImplementation of peer credentials for Unix sockets
Joe Ellis [Tue, 4 Aug 2020 10:18:13 +0000 (11:18 +0100)]
Implementation of peer credentials for Unix sockets

The code in `ucred.rs` is based on the work done in PR 13 in the
tokio-uds repository on GitHub. Link below for reference:

    https://github.com/tokio-rs/tokio-uds/pull/13

Credit to Martin Habovštiak (GitHub username Kixunil) and contributors
for this work!

3 years agoMake bootstrap build on stable
Mark Rousskov [Sun, 6 Sep 2020 23:38:26 +0000 (19:38 -0400)]
Make bootstrap build on stable

This is generally a good idea, and will help with being able to build bootstrap
without Python over time as it means we can "just" build with cargo +beta build
rather than needing the user to set environment variables. This is a minor step,
but a necessary one on that road.

3 years agoStabilize doc_alias feature
Guillaume Gomez [Thu, 20 Aug 2020 11:35:00 +0000 (13:35 +0200)]
Stabilize doc_alias feature

3 years agoAuto merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514
bors [Mon, 14 Sep 2020 08:25:41 +0000 (08:25 +0000)]
Auto merge of #76571 - lzutao:rustdoc-private-traits, r=jyn514

Ignore rustc_private items from std docs

By ignoring rustc_private items for non local impl block,
this may fix #74672 and fix #75588 .

This might suppress #76529 if it is simple enough for backport.

3 years agoAuto merge of #76549 - ehuss:lints-comments, r=wesleywiser
bors [Mon, 14 Sep 2020 05:54:44 +0000 (05:54 +0000)]
Auto merge of #76549 - ehuss:lints-comments, r=wesleywiser

Auto-generate lint documentation.

This adds a tool which will generate the lint documentation in the rustc book automatically. This is motivated by keeping the documentation up-to-date, and consistently formatted. It also ensures the examples are correct and that they actually generate the expected lint. The lint groups table is also auto-generated. See https://github.com/rust-lang/compiler-team/issues/349 for the original proposal.

An outline of how this works:
- The `declare_lint!` macro now accepts a doc comment where the documentation is written. This is inspired by how clippy works.
- A new tool `src/tools/lint-docs` scrapes the documentation and adds it to the rustc book during the build.
    - It runs each example and verifies its output and embeds the output in the book.
    - It does a few formatting checks.
    - It verifies that every lint is documented.
- Groups are collected from `rustc -W help`.

I updated the documentation for all the missing lints. I have also added an "Explanation" section to each lint providing a reason for the lint and suggestions on how to resolve it.

This can lead towards a future enhancement of possibly showing these docs via the `--explain` flag to make them easily accessible and discoverable.

3 years agoAuto merge of #76195 - lcnr:const-Self, r=varkor
bors [Mon, 14 Sep 2020 04:07:08 +0000 (04:07 +0000)]
Auto merge of #76195 - lcnr:const-Self, r=varkor

allow concrete self types in consts

This is quite a bad hack to fix #75486. There might be a better way to check if the self type depends on generic parameters, but I wasn't able to come up with one.

r? `@varkor` cc `@petrochenkov`

3 years agoAuto merge of #76123 - tmiasko:inline-args-storage, r=wesleywiser
bors [Mon, 14 Sep 2020 02:13:02 +0000 (02:13 +0000)]
Auto merge of #76123 - tmiasko:inline-args-storage, r=wesleywiser

inliner: Emit storage markers for introduced arg temporaries

When introducing argument temporaries during inlining, emit storage
marker statements just before the assignment and in the beginning of
the return block.

This ensures that such temporaries will not be considered live across
yield points after inlining inside a generator.

Fixes #71793.

3 years agoUse `.as_str()` instead of `CowStr::Borrowed`
Joshua Nelson [Mon, 14 Sep 2020 01:13:04 +0000 (21:13 -0400)]
Use `.as_str()` instead of `CowStr::Borrowed`

3 years agoDon't use `link.span` yet
Joshua Nelson [Mon, 14 Sep 2020 00:56:33 +0000 (20:56 -0400)]
Don't use `link.span` yet

This shows the span of the _whole_ link, including the brackets.
But rustdoc only wants to warn about the link text.

3 years agoAuto merge of #76656 - jonas-schievink:fewer-unstable-metadata-queries, r=lcnr
bors [Mon, 14 Sep 2020 00:26:43 +0000 (00:26 +0000)]
Auto merge of #76656 - jonas-schievink:fewer-unstable-metadata-queries, r=lcnr

Don't query stability data when `staged_api` is off

This data only needs to be encoded when `#![feature(staged_api)]` or `-Zforce-unstable-if-unmarked` is on. Running these queries takes measurable time on large crates with many items, so skip it when the unstable flags have not been enabled.

3 years agoUpgrade to pulldown-cmark 0.8.0
Joshua Nelson [Mon, 14 Sep 2020 00:15:01 +0000 (20:15 -0400)]
Upgrade to pulldown-cmark 0.8.0

Thanks to marcusklaas' hard work in https://github.com/raphlinus/pulldown-cmark/pull/469, this fixes a lot of rustdoc bugs!

- Get rid of unnecessary `RefCell`
- Fix duplicate warnings for broken implicit reference link
- Remove unnecessary copy of links

3 years agoAuto merge of #76678 - jonas-schievink:rollup-vzl9yhx, r=jonas-schievink
bors [Sun, 13 Sep 2020 22:34:09 +0000 (22:34 +0000)]
Auto merge of #76678 - jonas-schievink:rollup-vzl9yhx, r=jonas-schievink

Rollup of 12 pull requests

Successful merges:

 - #75559 (unions: test move behavior of non-Copy fields)
 - #76441 (Note that parallel-compiler = true causes tests to fail)
 - #76527 (Remove internal and unstable MaybeUninit::UNINIT.)
 - #76629 (Simplify iter zip struct doc)
 - #76640 (Simplify SyncOnceCell's `take` and `drop`.)
 - #76646 (Add mailmap entry)
 - #76651 (Remove Windows details from Unix and VmWorks symlink() docstrings)
 - #76663 (Simplify iter chain struct doc)
 - #76665 (slice::from_raw_parts: explicitly mention that data must be initialized)
 - #76667 (Fix CI LLVM to work on NixOS out of the box)
 - #76668 (Add visualization of rustc span in doc)
 - #76677 (note that test_stable_pointers does not reflect a stable guarantee)

Failed merges:

r? `@ghost`

3 years agoOptimize behavior of vec.split_off(0) (take all)
Rich Kadel [Sun, 13 Sep 2020 18:58:43 +0000 (11:58 -0700)]
Optimize behavior of vec.split_off(0) (take all)

Optimization improvement to `split_off()` so the performance meets the
intuitively expected behavior when `at == 0`, avoiding the current
behavior of copying the entire vector.

The change honors documented behavior that the method leaves the
original vector's "previous capacity unchanged".

This improvement better supports the pattern for building and flushing a
buffer of elements, such as the following:

```rust
    let mut vec = Vec::new();
    loop {
        vec.push(something);
        if condition_is_met {
            process(vec.split_off(0));
        }
    }
```

`Option` wrapping is the first alternative I thought of, but is much
less obvious and more verbose:

```rust
    let mut capacity = 1;
    let mut vec: Option<Vec<Stuff>> = None;
    loop {
        vec.get_or_insert_with(|| Vec::with_capacity(capacity)).push(something);
        if condition_is_met {
            capacity = vec.capacity();
            process(vec.take().unwrap());
        }
    }
```

Directly applying `mem::replace()` could work, but `mem::` functions are
typically a last resort, when a developer is actively seeking better
performance than the standard library provides, for example.

The benefit of the approach to this change is it does not change the
existing API contract, but improves the peformance of `split_off(0)` for
`Vec`, `String` (which delegates `split_off()` to `Vec`), and any other
existing use cases.

This change adds tests to validate the behavior of `split_off()` with
regard to capacity, as originally documented, and confirm that behavior
still holds, when `at == 0`.

The change is an implementation detail, and does not require a
documentation change, but documenting the new behavior as part of its
API contract may benefit future users.

(Let me know if I should make that documentation update.)

Note, for future consideration:

I think it would be helpful to introduce an additional method to `Vec`
(if not also to `String`):

```
    pub fn take_all(&mut self) -> Self {
        self.split_off(0)
    }
```

This would make it more clear how `Vec` supports the pattern, and make
it easier to find, since the behavior is similar to other `take()`
methods in the Rust standard library.

3 years agoRequire `module_id` param to `resolve` to be non-empty
Joshua Nelson [Sun, 13 Sep 2020 21:15:40 +0000 (17:15 -0400)]
Require `module_id` param to `resolve` to be non-empty

Previously, `resolve` would immediately check that `module_id` was
non-empty and give an error if not. This had two downsides:

- It introduced `Option`s everywhere, even if the calling function knew
it had a valid module, and
- It checked the module on each namespace, which is unnecessary: it only
needed to be checked once.

This makes the caller responsible for checking the module exists, making
the code a lot simpler.

3 years agoRefactor `resolve_with_disambiguator` into a separate function
Joshua Nelson [Sun, 13 Sep 2020 21:04:44 +0000 (17:04 -0400)]
Refactor `resolve_with_disambiguator` into a separate function

3 years agobless tests
Bastian Kauschke [Sun, 13 Sep 2020 21:02:43 +0000 (23:02 +0200)]
bless tests

3 years agoreview, improve note span
Bastian Kauschke [Tue, 8 Sep 2020 09:37:27 +0000 (11:37 +0200)]
review, improve note span

3 years agoallow concrete self types in consts
Bastian Kauschke [Tue, 1 Sep 2020 12:30:16 +0000 (14:30 +0200)]
allow concrete self types in consts

3 years agoRefactor `resolve_link` into a separate function
Joshua Nelson [Sun, 13 Sep 2020 20:48:51 +0000 (16:48 -0400)]
Refactor `resolve_link` into a separate function

3 years agoRollup merge of #76677 - RalfJung:stable-pointers, r=jonas-schievink
Jonas Schievink [Sun, 13 Sep 2020 18:21:24 +0000 (20:21 +0200)]
Rollup merge of #76677 - RalfJung:stable-pointers, r=jonas-schievink

note that test_stable_pointers does not reflect a stable guarantee

Just to be sure...

3 years agoRollup merge of #76668 - pickfire:patch-9, r=jonas-schievink
Jonas Schievink [Sun, 13 Sep 2020 18:21:22 +0000 (20:21 +0200)]
Rollup merge of #76668 - pickfire:patch-9, r=jonas-schievink

Add visualization of rustc span in doc

It took me quite some time to figure out what Span::to means.
A picture is worth a thousand words.

3 years agoRollup merge of #76667 - matklad:patch-llvm, r=Mark-Simulacrum
Jonas Schievink [Sun, 13 Sep 2020 18:21:20 +0000 (20:21 +0200)]
Rollup merge of #76667 - matklad:patch-llvm, r=Mark-Simulacrum

Fix CI LLVM to work on NixOS out of the box

r? @Mark-Simulacrum

Tested locally, seems to work!

3 years agoRollup merge of #76665 - RalfJung:slice-from-raw, r=sfackler
Jonas Schievink [Sun, 13 Sep 2020 18:21:19 +0000 (20:21 +0200)]
Rollup merge of #76665 - RalfJung:slice-from-raw, r=sfackler

slice::from_raw_parts: explicitly mention that data must be initialized

This reflects the status quo, until the discussion in https://github.com/rust-lang/unsafe-code-guidelines/issues/77 reaches a conclusion.

3 years agoRollup merge of #76663 - pickfire:patch-7, r=jonas-schievink
Jonas Schievink [Sun, 13 Sep 2020 18:21:17 +0000 (20:21 +0200)]
Rollup merge of #76663 - pickfire:patch-7, r=jonas-schievink

Simplify iter chain struct doc