]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agodon't lazily evaulate some trivial values for Option::None replacements (clippy:...
Matthias Krüger [Tue, 15 Sep 2020 21:10:24 +0000 (23:10 +0200)]
don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations)

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 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 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 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 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 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 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 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 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

3 years agoRollup merge of #76651 - nicholasbishop:bishop-remove-windows-note, r=Mark-Simulacrum
Jonas Schievink [Sun, 13 Sep 2020 18:21:16 +0000 (20:21 +0200)]
Rollup merge of #76651 - nicholasbishop:bishop-remove-windows-note, r=Mark-Simulacrum

Remove Windows details from Unix and VmWorks symlink() docstrings

This note is not relevant to other operating systems.

3 years agoRollup merge of #76646 - CDirkx:mailmap, r=Mark-Simulacrum
Jonas Schievink [Sun, 13 Sep 2020 18:21:14 +0000 (20:21 +0200)]
Rollup merge of #76646 - CDirkx:mailmap, r=Mark-Simulacrum

Add mailmap entry

3 years agoRollup merge of #76640 - fusion-engineering-forks:synconcecell-drop, r=matklad
Jonas Schievink [Sun, 13 Sep 2020 18:21:13 +0000 (20:21 +0200)]
Rollup merge of #76640 - fusion-engineering-forks:synconcecell-drop, r=matklad

Simplify SyncOnceCell's `take` and `drop`.

Prevents copies by using `assume_init_read` and `assume_init_drop`.

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

Simplify iter zip struct doc

3 years agoRollup merge of #76527 - fusion-engineering-forks:cleanup-uninit, r=jonas-schievink
Jonas Schievink [Sun, 13 Sep 2020 18:21:09 +0000 (20:21 +0200)]
Rollup merge of #76527 - fusion-engineering-forks:cleanup-uninit, r=jonas-schievink

Remove internal and unstable MaybeUninit::UNINIT.

Looks like it is no longer necessary, as `uninit_array()` can be used instead in the few cases where it was needed.

(I wanted to just add `#[doc(hidden)]` to remove clutter from the documentation, but looks like it can just be removed entirely.)

3 years agoRollup merge of #76441 - jyn514:parallel, r=jonas-schievink
Jonas Schievink [Sun, 13 Sep 2020 18:21:07 +0000 (20:21 +0200)]
Rollup merge of #76441 - jyn514:parallel, r=jonas-schievink

Note that parallel-compiler = true causes tests to fail

Mentioning #75760.

3 years agoRollup merge of #75559 - RalfJung:union-test-move, r=joshtriplett
Jonas Schievink [Sun, 13 Sep 2020 18:21:05 +0000 (20:21 +0200)]
Rollup merge of #75559 - RalfJung:union-test-move, r=joshtriplett

unions: test move behavior of non-Copy fields

This test ensures the behaviors suggested by @petrochenkov [here](https://github.com/rust-lang/rust/issues/32836#issuecomment-242511491).

3 years agoMake const_evaluatable_unchecked lint example not depend on the architecture pointer...
Eric Huss [Sun, 13 Sep 2020 18:13:59 +0000 (11:13 -0700)]
Make const_evaluatable_unchecked lint example not depend on the architecture pointer size.

3 years agonote that test_stable_pointers does not reflect a stable guarantee
Ralf Jung [Sun, 13 Sep 2020 16:55:08 +0000 (18:55 +0200)]
note that test_stable_pointers does not reflect a stable guarantee

3 years agoSupress unused_macros error on architectures with no atomics.
Mara Bos [Sun, 13 Sep 2020 16:34:27 +0000 (18:34 +0200)]
Supress unused_macros error on architectures with no atomics.

3 years agoAuto merge of #76244 - vandenheuvel:remove__paramenv__def_id, r=nikomatsakis
bors [Sun, 13 Sep 2020 16:28:22 +0000 (16:28 +0000)]
Auto merge of #76244 - vandenheuvel:remove__paramenv__def_id, r=nikomatsakis

Removing the `def_id` field from hot `ParamEnv` to make it smaller

This PR addresses https://github.com/rust-lang/rust/issues/74865.

3 years agorebase fallout
Ralf Jung [Sun, 13 Sep 2020 16:15:19 +0000 (18:15 +0200)]
rebase fallout

3 years agoSupport `ignore` for lint examples.
Eric Huss [Sun, 13 Sep 2020 15:47:24 +0000 (08:47 -0700)]
Support `ignore` for lint examples.

3 years agoLink rustdoc lint docs to the rustdoc book.
Eric Huss [Fri, 11 Sep 2020 15:55:59 +0000 (08:55 -0700)]
Link rustdoc lint docs to the rustdoc book.

3 years agoAuto-generate lint documentation.
Eric Huss [Tue, 8 Sep 2020 22:09:57 +0000 (15:09 -0700)]
Auto-generate lint documentation.

3 years agomake union-drop mem::forget test meaningful
Ralf Jung [Sun, 30 Aug 2020 16:59:57 +0000 (18:59 +0200)]
make union-drop mem::forget test meaningful

3 years agoplease tidy
Ralf Jung [Sat, 15 Aug 2020 17:38:01 +0000 (19:38 +0200)]
please tidy

3 years agounions: test move behavior of non-Copy fields
Ralf Jung [Sat, 15 Aug 2020 11:04:32 +0000 (13:04 +0200)]
unions: test move behavior of non-Copy fields

3 years agoAuto merge of #76623 - slightlyoutofphase:master, r=jyn514
bors [Sun, 13 Sep 2020 13:36:31 +0000 (13:36 +0000)]
Auto merge of #76623 - slightlyoutofphase:master, r=jyn514

Use `is_unstable_const_fn` instead of `is_min_const_fn` in rustdoc where appropriate

This closes #76501. Specifically, it allows for nightly users with the `#![feature(const_fn)]` flag enabled to still have their `const fn` declarations documented as such, while retaining the desired behavior that rustdoc *not* document functions that have the `rustc_const_unstable` attribute as `const`.

3 years agoAdd visualization of rustc span in doc
Ivan Tham [Sun, 13 Sep 2020 12:48:15 +0000 (20:48 +0800)]
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 agoFix CI LLVM to work on NixOS out of the box
Aleksey Kladov [Sun, 13 Sep 2020 12:37:35 +0000 (14:37 +0200)]
Fix CI LLVM to work on NixOS out of the box

3 years agoFix AtomicPtr::from_mut align check: Avoid generic arg in const expr.
Mara Bos [Sat, 12 Sep 2020 19:20:17 +0000 (21:20 +0200)]
Fix AtomicPtr::from_mut align check: Avoid generic arg in const expr.

See #76200.

3 years agoAdd Atomic*::from_mut.
Mara Bos [Sun, 19 Jul 2020 18:57:04 +0000 (20:57 +0200)]
Add Atomic*::from_mut.

The atomic equivalent of Cell::from_mut.

3 years agoslice::from_raw_parts: explicitly mention that data must be initialized
Ralf Jung [Sun, 13 Sep 2020 12:02:01 +0000 (14:02 +0200)]
slice::from_raw_parts: explicitly mention that data must be initialized

3 years agoSimplify iter chain struct doc
Ivan Tham [Sun, 13 Sep 2020 11:20:57 +0000 (19:20 +0800)]
Simplify iter chain struct doc

3 years agoAuto merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebank
bors [Sun, 13 Sep 2020 11:08:41 +0000 (11:08 +0000)]
Auto merge of #76598 - ad-anssi:diagnostic_errors_fix, r=estebank

Fixing memory exhaustion when formatting short code suggestion

Details can be found in issue #76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.

3 years agoAuto merge of #76658 - Aaron1011:fix/encode-dummy-loc-span, r=lcnr
bors [Sun, 13 Sep 2020 09:18:14 +0000 (09:18 +0000)]
Auto merge of #76658 - Aaron1011:fix/encode-dummy-loc-span, r=lcnr

Properly encode spans with a dummy location and non-root `SyntaxContext`

Previously, we would throw away the `SyntaxContext` of any span with a
dummy location during metadata encoding. This commit makes metadata Span
encoding consistent with incr-cache Span encoding - an 'invalid span'
tag is only used when it doesn't lose any information.

3 years agoAuto merge of #76588 - guswynn:debug_logging, r=jyn514,Mark-Simulacrum
bors [Sun, 13 Sep 2020 07:21:31 +0000 (07:21 +0000)]
Auto merge of #76588 - guswynn:debug_logging, r=jyn514,Mark-Simulacrum

Add a dedicated debug-logging option to config.toml

`@Mark-Simulacrum` and I were talking in zulip and we found that turning on debug/trace logging in rustc is fairly confusing, as it effectively depends on debug-assertions and is not documented as such. `@Mark-Simulacrum` mentioned that we should probably have a separate option for logging anyways.

this diff adds that, having the option follow debug-assertions (so everyone's existing config.toml should be fine) and if the option is false

to test I ran ./x.py test <something> twice, once with `debug-logging = false` and once with `debug-logging = true` and made sure i only saw trace's when it was true

3 years agoIgnore rustc_private items from std docs
Lzu Tao [Thu, 10 Sep 2020 14:05:33 +0000 (14:05 +0000)]
Ignore rustc_private items from std docs

Apply suggestions from code review

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAdd ui test for 74672 and 76571
Lzu Tao [Fri, 11 Sep 2020 03:01:25 +0000 (03:01 +0000)]
Add ui test for 74672 and 76571

These tests will fall without the next commit.

3 years agoAuto merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkov
bors [Sun, 13 Sep 2020 05:16:36 +0000 (05:16 +0000)]
Auto merge of #76585 - Aaron1011:ignore-vert-plus, r=petrochenkov

Ignore `|` and `+` tokens during proc-macro pretty-print check

Fixes #76182

This is an alternative to PR #76188

These tokens are not preserved in the AST in certain cases
(e.g. a leading `|` in a pattern or a trailing `+` in a trait bound).

This PR ignores them entirely during the pretty-print/reparse check
to avoid spuriously using the re-parsed tokenstream.

3 years agoProperly encode spans with a dummy location and non-root `SyntaxContext`
Aaron Hill [Sun, 13 Sep 2020 03:26:17 +0000 (23:26 -0400)]
Properly encode spans with a dummy location and non-root `SyntaxContext`

Previously, we would throw away the `SyntaxContext` of any span with a
dummy location during metadata encoding. This commit makes metadata Span
encoding consistent with incr-cache Span encoding - an 'invalid span'
tag is only used when it doesn't lose any information.

3 years agoAuto merge of #76349 - Mark-Simulacrum:dl-llvm, r=alexcrichton
bors [Sun, 13 Sep 2020 02:16:18 +0000 (02:16 +0000)]
Auto merge of #76349 - Mark-Simulacrum:dl-llvm, r=alexcrichton

Download LLVM from CI to bootstrap (linux-only to start)

This follows #76332, adding support for using CI-built LLVM rather than building it locally. This should essentially "just work," but is left off by default in this PR.

While we can support downloading LLVM for multiple host triples, this currently only downloads it for the build triple. That said, it should be possible to expand this relatively easily should multiple host triples be desired. Most people shouldn't be adjusting host/target triples though, so this should cover most use cases.

Currently this downloads LLVM for the last bors-authored commit in the `git log`. This is a bit suboptimal -- we want the last bors-authored commit that touched the llvm-project submodule in basically all cases. But for now this just adds an extra ~20 MB download when rebasing atop latest master. Once we have a submodule bump landing after #76332, we can fix this behavior to reduce downloads further.

3 years agoAuto merge of #76306 - tmiasko:nrvo-debuginfo, r=ecstatic-morse
bors [Sun, 13 Sep 2020 00:33:04 +0000 (00:33 +0000)]
Auto merge of #76306 - tmiasko:nrvo-debuginfo, r=ecstatic-morse

NRVO: Allow occurrences of the return place in var debug info

The non-use occurrence of the return place in var debug info does not
currently inhibit NRVO optimization, but it will fail assertion in
`visit_place` when optimization is performed.

Relax assertion check to allow the return place in var debug info.

This case might be impossible to hit in optimization pipelines as of
now, but can be encountered in customized mir-opt-level=2 pipeline with
copy propagation disabled. For example in:

```rust
pub fn b(s: String) -> String {
    a(s)
}

#[inline]
pub fn a(s: String) -> String {
    let x = s;
    let y = x;
    y
}
```

3 years agoDon't query unstable data when `staged_api` is off
Jonas Schievink [Sat, 12 Sep 2020 23:58:17 +0000 (01:58 +0200)]
Don't query unstable data when `staged_api` is off

3 years agoAuto merge of #73461 - calebzulawski:validate-attribute-placement, r=matthewjasper
bors [Sat, 12 Sep 2020 22:04:37 +0000 (22:04 +0000)]
Auto merge of #73461 - calebzulawski:validate-attribute-placement, r=matthewjasper

Validate built-in attribute placement

Closes #54584, closes #47725, closes #54044.

I've changed silently ignoring some incorrectly placed attributes to errors.  I'm not sure what the policy is since this can theoretically break code (should they be warnings instead? does it warrant a crater run?).

3 years agoRemove Windows details from Unix and VmWorks symlink() docstrings
Nicholas Bishop [Sat, 12 Sep 2020 19:47:52 +0000 (15:47 -0400)]
Remove Windows details from Unix and VmWorks symlink() docstrings

This note is not relevant to other operating systems.

3 years agoSet link-shared if LLVM ThinLTO is enabled in config.rs
Mark Rousskov [Sat, 12 Sep 2020 19:10:13 +0000 (15:10 -0400)]
Set link-shared if LLVM ThinLTO is enabled in config.rs

This avoids missing a shared build when uplifting LLVM artifacts into the
sysroot. We were already producing a shared link anyway, though, so this is not
a visible change from the end user's perspective.

3 years agoDownload LLVM from CI to bootstrap
Mark Rousskov [Fri, 4 Sep 2020 23:00:04 +0000 (19:00 -0400)]
Download LLVM from CI to bootstrap

3 years agoAuto merge of #76538 - fusion-engineering-forks:check-useless-unstable-trait-impl...
bors [Sat, 12 Sep 2020 18:01:33 +0000 (18:01 +0000)]
Auto merge of #76538 - fusion-engineering-forks:check-useless-unstable-trait-impl, r=lcnr

Warn for #[unstable] on trait impls when it has no effect.

Earlier today I sent a PR with an `#[unstable]` attribute on a trait `impl`, but was informed that this attribute has no effect there. (comment: https://github.com/rust-lang/rust/pull/76525#issuecomment-689678895, issue: https://github.com/rust-lang/rust/issues/55436)

This PR adds a warning for this situation. Trait `impl` blocks with `#[unstable]` where both the type and the trait are stable will result in a warning:

```
warning: An `#[unstable]` annotation here has no effect. See issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information.
   --> library/std/src/panic.rs:235:1
    |
235 | #[unstable(feature = "integer_atomics", issue = "32976")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

---

It detects three problems in the existing code:

1. A few `RefUnwindSafe` implementations for the atomic integer types in `library/std/src/panic.rs`. Example:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/panic.rs#L235-L236
2. An implementation of `Error` for `LayoutErr` in `library/std/srd/error.rs`:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/std/src/error.rs#L392-L397
3. `From` implementations for `Waker` and `RawWaker` in `library/alloc/src/task.rs`. Example:
https://github.com/rust-lang/rust/blob/d92155bf6ae0b7d79fc83cbeeb0cc0c765353471/library/alloc/src/task.rs#L36-L37

Case 3 interesting: It has a bound with an `#[unstable]` trait (`W: Wake`), so appears to have much effect on stable code. It does however break similar blanket implementations. It would also have immediate effect if `Wake` was implemented for any stable type. (Which is not the case right now, but there are no warnings in place to prevent it.) Whether this case is a problem or not is not clear to me. If it isn't, adding a simple `c.visit_generics(..);` to this PR will stop the warning for this case.

3 years agoAuto merge of #76639 - Mark-Simulacrum:ci-hosts, r=pietroalbini
bors [Sat, 12 Sep 2020 15:44:07 +0000 (15:44 +0000)]
Auto merge of #76639 - Mark-Simulacrum:ci-hosts, r=pietroalbini

Add host triples to CI builders

This is a follow-up to #76415, which changed how x.py interprets cross-compilation target/host flags. This should fix the known cases, but I'm still working through CI logs before/after that PR to identify if anything else is missing.

3 years agoGive functions unique names
SlightlyOutOfPhase [Sat, 12 Sep 2020 15:24:19 +0000 (11:24 -0400)]
Give functions unique names

3 years agoMark Once::new as #[inline].
Mara Bos [Sat, 12 Sep 2020 15:11:47 +0000 (17:11 +0200)]
Mark Once::new as #[inline].

Without this, it was not inlined in SyncOnceCell::into_inner(), causing
unecessary checks and dead code.

3 years agoFix `const-display.rs` XPATH queries (#1)
SlightlyOutOfPhase [Sat, 12 Sep 2020 14:52:12 +0000 (10:52 -0400)]
Fix `const-display.rs` XPATH queries (#1)

* Fix `const-display.rs` XPATH queries

* Add `issue_76501.rs` test file

* Rename issue_76501.rs to issue-76501.rs

3 years agoPrint all step timings
Mark Rousskov [Sat, 12 Sep 2020 14:05:10 +0000 (10:05 -0400)]
Print all step timings

It is really painful to inspect differences in what was built in CI if things
are appearing and disappearing randomly as they hover around the 100ms mark. No
matter what we choose there's always going to be quite a bit of variability on
CI in timing, so we're going to see things appear and vanish.

3 years agoAuto merge of #76632 - andjo403:updateDep, r=Mark-Simulacrum
bors [Sat, 12 Sep 2020 14:00:39 +0000 (14:00 +0000)]
Auto merge of #76632 - andjo403:updateDep, r=Mark-Simulacrum

update the version of itertools and parking_lot

this is to avoid compiling multiple version of the crates in rustc speeding up compilation of rustc

an old version of parking_lot is still used in measureme but new version will not be released for some time see [zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/new.20release.20of.20measureme)

3 years agoAdd mailmap entry
Christiaan Dirkx [Sat, 12 Sep 2020 13:58:30 +0000 (15:58 +0200)]
Add mailmap entry

3 years agoAuto merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu
bors [Sat, 12 Sep 2020 12:06:12 +0000 (12:06 +0000)]
Auto merge of #76561 - Thomasdezeeuw:iov-constant-limits, r=Amanieu

Use IOV_MAX and UIO_MAXIOV constants in limit vectored I/O

Also updates the libc dependency to 0.2.77 (from 0.2.74) as the
constants were only recently added.

Related #68042, #75005

r? `@Amanieu` (also reviewed #75005)

3 years agoAdd host= configuration for msvc/darwin
Mark Rousskov [Sat, 12 Sep 2020 11:59:54 +0000 (07:59 -0400)]
Add host= configuration for msvc/darwin