]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAdjust sync::Weak::from_raw to support unsized T
CAD97 [Tue, 14 Jul 2020 19:17:55 +0000 (15:17 -0400)]
Adjust sync::Weak::from_raw to support unsized T

3 years ago?Sized bounds for rc::Weak::as_ptr and friends
CAD97 [Wed, 8 Jul 2020 20:24:56 +0000 (16:24 -0400)]
?Sized bounds for rc::Weak::as_ptr and friends

3 years agoAdjust rc::Weak::from_raw to support unsized T
CAD97 [Wed, 8 Jul 2020 20:23:38 +0000 (16:23 -0400)]
Adjust rc::Weak::from_raw to support unsized T

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 agoAuto merge of #76637 - RalfJung:rollup-eaykf93, r=RalfJung
bors [Sat, 12 Sep 2020 09:34:37 +0000 (09:34 +0000)]
Auto merge of #76637 - RalfJung:rollup-eaykf93, r=RalfJung

Rollup of 7 pull requests

Successful merges:

 - #76114 (Add saturating methods for `Duration`)
 - #76297 (rustdoc: fix min_const_generics with ty::Param)
 - #76484 (Add MaybeUninit::assume_init_drop.)
 - #76530 (Eliminate mut reference UB in Drop impl for Rc<T>)
 - #76583 (Update `std::os` module documentation.)
 - #76599 (Finish off revisions for const generics UI tests.)
 - #76615 (Add missing examples on binary core traits)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76615 - GuillaumeGomez:missing-examples-binary-ops, r=jyn514
Ralf Jung [Sat, 12 Sep 2020 08:43:24 +0000 (10:43 +0200)]
Rollup merge of #76615 - GuillaumeGomez:missing-examples-binary-ops, r=jyn514

Add missing examples on binary core traits

r? @jyn514

3 years agoRollup merge of #76599 - hameerabbasi:const-generics-revs, r=lcnr
Ralf Jung [Sat, 12 Sep 2020 08:43:22 +0000 (10:43 +0200)]
Rollup merge of #76599 - hameerabbasi:const-generics-revs, r=lcnr

Finish off revisions for const generics UI tests.

This time it really does fix it. ðŸ˜… The only ones left are `min-and-full-same-time.rs`, which doesn't need it, and `array-impls/` which check the feature indirectly.

Fixes #75279.

r? @lcnr

3 years agoRollup merge of #76583 - CDirkx:os-doc, r=jonas-schievink
Ralf Jung [Sat, 12 Sep 2020 08:43:20 +0000 (10:43 +0200)]
Rollup merge of #76583 - CDirkx:os-doc, r=jonas-schievink

Update `std::os` module documentation.

Adds missing descriptions for the modules `std::os::linux::fs` and `std::os::windows::io`.
Also adds punctuation for consistency with other descriptions.

3 years agoRollup merge of #76530 - carbotaniuman:fix-rc, r=RalfJung
Ralf Jung [Sat, 12 Sep 2020 08:43:18 +0000 (10:43 +0200)]
Rollup merge of #76530 - carbotaniuman:fix-rc, r=RalfJung

Eliminate mut reference UB in Drop impl for Rc<T>

This changes `self.ptr.as_mut()` with `get_mut_unchecked` which
does not use an intermediate reference.  Arc<T> already handled this
case properly.

Fixes #76509

3 years agoRollup merge of #76484 - fusion-engineering-forks:maybe-uninit-drop, r=RalfJung
Ralf Jung [Sat, 12 Sep 2020 08:43:17 +0000 (10:43 +0200)]
Rollup merge of #76484 - fusion-engineering-forks:maybe-uninit-drop, r=RalfJung

Add MaybeUninit::assume_init_drop.

`ManuallyDrop`'s documentation tells the user to use `MaybeUninit` instead when handling uninitialized data. However, the main functionality of `ManuallyDrop` (`drop`) is not available directly on `MaybeUninit`. Adding it makes it easier to switch from one to the other.

I re-used the `maybe_uninit_extra` feature and tracking issue number (#63567), since it seems very related. (And to avoid creating too many features tracking issues for `MaybeUninit`.)

3 years agoRollup merge of #76297 - lcnr:const-ty-alias, r=varkor
Ralf Jung [Sat, 12 Sep 2020 08:43:15 +0000 (10:43 +0200)]
Rollup merge of #76297 - lcnr:const-ty-alias, r=varkor

rustdoc: fix min_const_generics with ty::Param

fixes #75913

r? @varkor cc @jyn514

3 years agoRollup merge of #76114 - marmeladema:duration-saturating-ops, r=shepmaster
Ralf Jung [Sat, 12 Sep 2020 08:43:08 +0000 (10:43 +0200)]
Rollup merge of #76114 - marmeladema:duration-saturating-ops, r=shepmaster

Add saturating methods for `Duration`

In some project, I needed a `saturating_add` method for `Duration`. I implemented it myself but i thought it would be a nice addition to the standard library as it matches closely with the integers types.

3 new methods have been introduced and are gated by the new `duration_saturating_ops` unstable feature:
* `Duration::saturating_add`
* `Duration::saturating_sub`
* `Duration::saturating_mul`

If have left the tracking issue to `none` for now as I want first to understand if those methods would be acceptable at all. If agreed, I'll update the PR with the tracking issue.

Further more, to match the behavior of integers types, I introduced 2 associated constants:
* `Duration::MIN`: this one is somehow a duplicate from `Duration::zero()` method, but at the time this method was added, `MIN` was rejected as it was considered a different semantic (see https://github.com/rust-lang/rust/pull/72790#issuecomment-636511743).
* `Duration::MAX`

Both have been gated by the already existing unstable feature `duration_constants`, I can introduce a new unstable feature if needed or just re-use the `duration_saturating_ops`.

We might have to decide whether:
* `MIN` should be replaced by `ZERO`?
* associated constants over methods?

3 years agoAuto merge of #76222 - guswynn:const_diag, r=estebank
bors [Sat, 12 Sep 2020 07:45:34 +0000 (07:45 +0000)]
Auto merge of #76222 - guswynn:const_diag, r=estebank

Give better suggestion when const Range*'s are used as patterns

Fixes #76191

let me know if there is more/different information you want to show in this case

3 years agoAuto merge of #75756 - jyn514:diagnostic-suggestions, r=estebank
bors [Sat, 12 Sep 2020 05:52:14 +0000 (05:52 +0000)]
Auto merge of #75756 - jyn514:diagnostic-suggestions, r=estebank

Improve suggestions for broken intra-doc links

~~Depends on #74489 and should not be merged before that PR.~~ Merged ðŸŽ‰
~~Depends on #75916 and should not be merged before.~~ Merged

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

This does a lot of different things ðŸ˜†.

- Add `PerNS::into_iter()` so I didn't have to keep rewriting hacks around it. Also add `PerNS::iter()` for consistency. Let me know if this should be `impl IntoIterator` instead.
- Make `ResolutionFailure` an enum instead of a unit variant. This was most of the changes: everywhere that said `ErrorKind::ResolutionFailure` now has to say _why_ the link failed to resolve.
- Store the resolution in case of an anchor failure. Previously this was implemented as variants on `AnchorFailure` which was prone to typos and had inconsistent output compared to the rest of the diagnostics.
- Turn some `Err`ors into unwrap() or panic()s, because they're rustdoc bugs and not user error. These have comments as to why they're bugs (in particular this would have caught #76073 as a bug a while ago).
- If an item is not in scope at all, say the first segment in the path that failed to resolve
- If an item exists but not in the current namespaces, say that and suggests linking to that namespace.
- If there is a partial resolution for an item (part of the segments resolved, but not all of them), say the partial resolution and why the following segment didn't resolve.
- Add the `DefId` of associated items to `kind_side_channel` so it can be used for diagnostics (tl;dr of the hack: the rest of rustdoc expects the id of the item, but for diagnostics we need the associated item).
- No longer suggests escaping the brackets for every link that failed to resolve; this was pretty obnoxious. Now it only suggests `\[ \]` if no segment resolved and there is no `::` in the link.
- Add `Suggestion`, which says _what_ to prefix the link with, not just 'prefix with the item kind'.

Places where this is currently buggy:

<details><summary>All outdated</summary>

~~1. When the link has the wrong namespace:~~ Now fixed.

<details>

```rust
/// [type@S::h]
impl S {
pub fn h() {}
}

/// [type@T::g]
pub trait T {
fn g() {}
}
```
```
error: unresolved link to `T::g`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:53:6
   |
53 | /// [type@T::g]
   |      ^^^^^^^^^
   |
   = note: this link partially resolves to the trait `T`,
   = note: `T` has no field, variant, or associated item named `g`

error: unresolved link to `S::h`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:48:6
   |
48 | /// [type@S::h]
   |      ^^^^^^^^^
   |
   = note: this link partially resolves to the struct `S`,
   = note: `S` has no field, variant, or associated item named `h`
```
Instead it should suggest changing the disambiguator, the way it currently does for macros:
```
error: unresolved link to `S`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:38:6
   |
38 | /// [S!]
   |      ^^ help: to link to the unit struct, use its disambiguator: `value@S`
   |
   = note: this link resolves to the unit struct `S`, which is not in the macro namespace
```

</details>

2. ~~Associated items for values. It says that the value isn't in scope; instead it should say that values can't have associated items.~~ Fixed.

<details>

```
error: unresolved link to `f::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:14:6
   |
14 | /// [f::A]
   |      ^^^^
   |
   = note: no item named `f` is in scope
   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
```
This is _mostly_ fixed, it now says

```rust
warning: unresolved link to `f::A`
 --> /home/joshua/test-rustdoc/f.rs:1:6
  |
1 | /// [f::A]
  |      ^^^^
  |
  = note: this link partially resolves to the function `f`
  = note: `f` is a function, not a module
```

'function, not a module' seems awfully terse when what I actually mean is '`::` isn't allowed here', though.

</details>

It looks a lot nicer now, it says

```
error: unresolved link to `f::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:13:6
   |
13 | /// [f::A]
   |      ^^^^
   |
   = note: `f` is a function, not a module or type, and cannot have associated items
```

3. ~~I'm also not very happy with the second note for this error:~~

<details>
```
error: unresolved link to `S::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:19:6
   |
19 | /// [S::A]
   |      ^^^^
   |
   = note: this link partially resolves to the struct `S`,
   = note: `S` has no field, variant, or associated item named `A`
```

but I'm not sure how better to word it.

I ended up going with 'no `A` in `S`' to match `rustc_resolve` but that seems terse as well.

</details>

This now says

```
error: unresolved link to `S::A`
  --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:17:6
   |
17 | /// [S::A]
   |      ^^^^
   |
   = note: the struct `S` has no field or associated item named `A`
```

which I think looks pretty good :)

4. This is minor, but it would be nice to say that `path` wasn't found instead of the full thing:
```
error: unresolved link to `path::to::nonexistent::module`
 --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:8:6
  |
8 | /// [path::to::nonexistent::module]
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

It will now look at most 3 paths up (so it reports `path::to` as not in scope), but it doesn't work with arbitrarily many paths.

</details>

~~I recommend only reviewing the last few commits - the first 7 are all from #74489.~~ Rebased so that only the relevant commits are shown. Let me know if I should squash the history some more.

r? `@estebank`

3 years agoAuto merge of #75021 - cuviper:array_chunks_mut, r=scottmcm
bors [Sat, 12 Sep 2020 03:59:46 +0000 (03:59 +0000)]
Auto merge of #75021 - cuviper:array_chunks_mut, r=scottmcm

Add `slice::array_chunks_mut`

This follows `array_chunks` from #74373 with a mutable version, `array_chunks_mut`. The implementation is identical apart from mutability. The new tests are adaptations of the `chunks_exact_mut` tests, plus an inference test like the one for `array_chunks`.

I reused the unstable feature `array_chunks` and tracking issue #74985, but I can separate that if desired.

r? `@withoutboats`
cc `@lcnr`

3 years agoAuto merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler
bors [Sat, 12 Sep 2020 02:13:28 +0000 (02:13 +0000)]
Auto merge of #74328 - yoshuawuyts:stabilize-future-readiness-fns, r=sfackler

Stabilize core::future::{pending,ready}

This PR stabilizes `core::future::{pending,ready}`, tracking issue https://github.com/rust-lang/rust/issues/70921.

## Motivation

These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake).

It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize.

## Implementation notes

This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in https://github.com/rust-lang/rust/pull/70834. So all this PR does is remove the feature gate.

3 years agoAuto merge of #73951 - pickfire:liballoc-intoiter, r=Mark-Simulacrum
bors [Fri, 11 Sep 2020 23:52:03 +0000 (23:52 +0000)]
Auto merge of #73951 - pickfire:liballoc-intoiter, r=Mark-Simulacrum

Liballoc intoiter refactor

3 years agobetter diag when const ranges are used in patterns
Gus Wynn [Tue, 1 Sep 2020 22:53:04 +0000 (15:53 -0700)]
better diag when const ranges are used in patterns

3 years agoAuto merge of #73761 - rijenkii:master, r=KodrAus
bors [Fri, 11 Sep 2020 21:54:31 +0000 (21:54 +0000)]
Auto merge of #73761 - rijenkii:master, r=KodrAus

Add `peek` and `peek_from` to `UnixStream` and `UnixDatagram`

This is my first PR, so I'm sure I've done some things wrong.

This PR:
  * adds `peek` function to `UnixStream`;
  * adds `peek` and `peek_from` to `UnixDatagram`;
  * moves `UnixDatagram::recv_from` implementation to a private function `recv_from_flags`, as `peek_from` uses the same code, just with different flags.

I've taken the documentation from `TcpStream` and `UdpStream`, so it may or may not make sense (I'm bad with english words).
Also, I'm not sure what I should write in the `unstable` attribute, so I've made up the name and set the issue to "none".

Closes #68565.

3 years agoAdd missing examples on binary core traits
Guillaume Gomez [Fri, 11 Sep 2020 21:43:37 +0000 (23:43 +0200)]
Add missing examples on binary core traits

3 years agoAuto merge of #76499 - guswynn:priv_des, r=petrochenkov
bors [Fri, 11 Sep 2020 20:01:31 +0000 (20:01 +0000)]
Auto merge of #76499 - guswynn:priv_des, r=petrochenkov

Give better diagnostic when using a private tuple struct constructor

Fixes #75907

Some notes:
1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach
2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns
3. this does not yet deal with #75906, but I believe it will be similar
4. let me know if you want more tests
5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)

3 years agoName the current module
Joshua Nelson [Fri, 11 Sep 2020 18:00:40 +0000 (14:00 -0400)]
Name the current module

'not in scope' -> 'not in `module`'

3 years agoGive better diagnostic when using a private tuple struct constructor
Gus Wynn [Tue, 8 Sep 2020 22:14:09 +0000 (15:14 -0700)]
Give better diagnostic when using a private tuple struct constructor

3 years agoAuto merge of #76415 - Mark-Simulacrum:bootstrap-cross-compilation, r=alexcrichton
bors [Fri, 11 Sep 2020 18:10:44 +0000 (18:10 +0000)]
Auto merge of #76415 - Mark-Simulacrum:bootstrap-cross-compilation, r=alexcrichton

rustbuild: avoid trying to inversely cross-compile for build triple from host triples

This changes rustbuild's cross compilation logic to better match what users expect,
particularly, avoiding trying to inverse cross-compile for the build triple from host triples.
That is, if build=A, host=B, target=B, we do not want to try and compile for A from B.
Indeed, the only "known to run" triple when cross-compiling is the build triple A.
When testing for a particular target we need to be able to run binaries compiled for
that target though.

The last commit also modifies the default set of host/target triples to avoid producing
needless artifacts for the build triple:

The new behavior is to respect --host and --target when passed as the *only*
configured triples (no triples are implicitly added). The default for --host is
the build triple, and the default for --target is the host triple(s), either
configured or the default build triple.

Fixes #76333

r? `@alexcrichton` if possible, otherwise we'll need to hunt down a reviewer

3 years agoRemove unnecessary clone
Joshua Nelson [Fri, 11 Sep 2020 17:49:45 +0000 (13:49 -0400)]
Remove unnecessary clone

3 years agoUse `span_label` instead of `note`
Joshua Nelson [Fri, 11 Sep 2020 17:42:56 +0000 (13:42 -0400)]
Use `span_label` instead of `note`

This puts the error message closer to the link, making it easier to see
what went wrong.

3 years agobox ResolutionFailures on the heap
Joshua Nelson [Fri, 11 Sep 2020 17:29:55 +0000 (13:29 -0400)]
box ResolutionFailures on the heap

This decreases the size of the `Result`s being returned,
improving performance in the common case.

3 years agoIgnore unnecessary unsafe warnings
Thomas de Zeeuw [Fri, 11 Sep 2020 17:12:06 +0000 (19:12 +0200)]
Ignore unnecessary unsafe warnings

This is a work-around for a libc issue:
https://github.com/rust-lang/libc/issues/1888.

3 years agoAdd `peek` and `peek_from` to `UnixStream` and `UnixDatagram`
rijenkii [Fri, 21 Aug 2020 12:50:53 +0000 (19:50 +0700)]
Add `peek` and `peek_from` to `UnixStream` and `UnixDatagram`

3 years agoStop implicitly appending triples to config.toml hosts and targets
Mark Rousskov [Sun, 6 Sep 2020 16:57:13 +0000 (12:57 -0400)]
Stop implicitly appending triples to config.toml hosts and targets

Previously, the CLI --target/--host definitions and configured options differed
in their effect: when setting these on the CLI, only the passed triples would be
compiled for, while in config.toml we would also compile for the build triple
and any host triples. This is needlessly confusing; users expect --target and
--host to be identical to editing the configuration file.

The new behavior is to respect --host and --target when passed as the *only*
configured triples (no triples are implicitly added). The default for --host is
the build triple, and the default for --target is the host triple(s), either
configured or the default build triple.

3 years agoVerify we compile std without involving a b host compiler
Mark Rousskov [Sun, 6 Sep 2020 16:41:28 +0000 (12:41 -0400)]
Verify we compile std without involving a b host compiler

3 years agoRemove host parameter from step configurations
Mark Rousskov [Sun, 6 Sep 2020 16:24:22 +0000 (12:24 -0400)]
Remove host parameter from step configurations

rustc is a natively cross-compiling compiler, and generally none of our steps
should care whether they are using a compiler built of triple A or B, just the
--target directive being passed to the running compiler. e.g., when building for
some target C, you don't generally want to build two stds: one with a host A
compiler and the other with a host B compiler. Just one std is sufficient.

3 years agoAddress review comments
carbotaniuman [Fri, 11 Sep 2020 12:25:28 +0000 (07:25 -0500)]
Address review comments

3 years agoAuto merge of #76573 - Mark-Simulacrum:bootstrap-with-external-llvm, r=alexcrichton
bors [Fri, 11 Sep 2020 11:16:33 +0000 (11:16 +0000)]
Auto merge of #76573 - Mark-Simulacrum:bootstrap-with-external-llvm, r=alexcrichton

Only copy LLVM into rust-dev with internal LLVM

This avoids needing to figure out where to locate each of the components with an
external LLVM. This component isn't manifested for rustup consumption and
generally shouldn't matter for anyone except Rust's CI, so it is fine for it to not be
complete elsewhere.

Fixes #76572.

r? `@alexcrichton`

3 years agoAdd revisions to const generic type-dependent UI tests.
Hameer Abbasi [Fri, 11 Sep 2020 09:48:44 +0000 (11:48 +0200)]
Add revisions to const generic type-dependent UI tests.

3 years agoAdd revisions to const generic const_evaluatable_checked tests.
Hameer Abbasi [Fri, 11 Sep 2020 09:42:32 +0000 (11:42 +0200)]
Add revisions to const generic const_evaluatable_checked tests.

3 years agoAuto merge of #75611 - JulianKnodt:cg_enum_err, r=lcnr
bors [Fri, 11 Sep 2020 08:40:07 +0000 (08:40 +0000)]
Auto merge of #75611 - JulianKnodt:cg_enum_err, r=lcnr

Add help note when using type in place of const

This adds a small help note when it might be possible that wrapping a parameter in braces might resolve the issue of having a type where a const was expected.

Currently, I am displaying the `HirId`, and I'm not particularly sure where to get the currently displayed path(?).

r? `@lcnr`

3 years agoAuto merge of #76381 - petrochenkov:nomingwcomp, r=Mark-Simulacrum
bors [Fri, 11 Sep 2020 06:36:43 +0000 (06:36 +0000)]
Auto merge of #76381 - petrochenkov:nomingwcomp, r=Mark-Simulacrum

rustbuild: Do not use `rust-mingw` component when bootstrapping windows-gnu targets

Addresses https://github.com/rust-lang/rust/pull/76326#issuecomment-687273473 (ancient `x86_64-w64-mingw32-gcc` is selected as a linker wrapper, which is not usable in `use_lld=true` mode).

Perhaps the comment about incompatible mingw was true in the past, but many things changed since then.
With this change I was able to build everything successfully locally using a newer mingw toolchain, if it passes through the older toolchain on CI, then it should be good, I think.

3 years agoAuto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov
bors [Fri, 11 Sep 2020 02:35:01 +0000 (02:35 +0000)]
Auto merge of #75800 - Aaron1011:feature/full-nt-tokens, r=petrochenkov

Attach tokens to all AST types used in `Nonterminal`

We perform token capturing when we have outer attributes (for nonterminals that support attributes - e.g. `Stmt`), or when we parse a `Nonterminal` for a `macro_rules!` argument. The full list of `Nonterminals` affected by this PR is:

* `NtBlock`
* `NtStmt`
* `NtTy`
* `NtMeta`
* `NtPath`
* `NtVis`
* `NtLiteral`

Of these nonterminals, only `NtStmt` and `NtLiteral` (which is actually just an `Expr`), support outer attributes - the rest only ever have token capturing perform when they match a `macro_rules!` argument.

This makes progress towards solving https://github.com/rust-lang/rust/issues/43081 - we now collect tokens for everything that might need them. However, we still need to handle `#[cfg]`, inner attributes, and misc pretty-printing issues (e.g. #75734)

I've separated the changes into (mostly) independent commits, which could be split into individual PRs for each `Nonterminal` variant. The purpose of having them all in one PR is to do a single Crater run for all of them.

Most of the changes in this PR are trivial (adding `tokens: None` everywhere we construct the various AST structs). The significant changes are:

* `ast::Visibility` is changed from `type Visibility = Spanned<VisibilityKind>` to a `struct Visibility { kind, span, tokens }`.
* `maybe_collect_tokens` is made generic, and used for both `ast::Expr` and `ast::Stmt`.
* Some of the statement-parsing functions are refactored so that we can capture the trailing semicolon.
* `Nonterminal` and `Expr` both grew by 8 bytes, as some of the structs which are stored inline (rather than behind a `P`) now have an `Option<TokenStream>` field. Hopefully the performance impact of doing this is negligible.

3 years agoUpdate `std::os` module documentation.
Christiaan Dirkx [Fri, 11 Sep 2020 02:05:19 +0000 (04:05 +0200)]
Update `std::os` module documentation.

Adds missing descriptions for the modules std::os::linux::fs and std::os::windows::io.
Also adds punctuation for consistency with other descriptions.

3 years agoAuto merge of #74437 - ssomers:btree_no_root_in_noderef, r=Mark-Simulacrum
bors [Thu, 10 Sep 2020 23:29:57 +0000 (23:29 +0000)]
Auto merge of #74437 - ssomers:btree_no_root_in_noderef, r=Mark-Simulacrum

BTreeMap: move up reference to map's root from NodeRef

Since the introduction of `NodeRef` years ago, it also contained a mutable reference to the owner of the root node of the tree (somewhat disguised as *const). Its intent is to be used only when the rest of the `NodeRef` is no longer needed. Moving this to where it's actually used, thought me 2 things:
- Some sort of "postponed mutable reference" is required in most places that it is/was used, and that's exactly where we also need to store a reference to the length (number of elements) of the tree, for the same reason. The length reference can be a normal reference, because the tree code does not care about tree length (just length per node).
- It's downright obfuscation in `from_sorted_iter` (transplanted to #75329)
- It's one of the reasons for the scary notice on `reborrow_mut`, the other one being addressed in #73971.

This does repeat the raw pointer code in a few places, but it could be bundled up with the length reference.

r? `@Mark-Simulacrum`

3 years agoFully integrate token collection for additional AST structs
Aaron Hill [Sat, 22 Aug 2020 02:11:41 +0000 (22:11 -0400)]
Fully integrate token collection for additional AST structs

This commit contains miscellaneous changes that don't fit into any of
the other commits in this PR

3 years agoAttach tokens to `ast::Stmt`
Aaron Hill [Thu, 10 Sep 2020 20:59:30 +0000 (16:59 -0400)]
Attach tokens to `ast::Stmt`

We currently only attach tokens when parsing a `:stmt` matcher for a
`macro_rules!` macro. Proc-macro attributes on statements are still
unstable, and need additional work.

3 years agoAttach `TokenStream` to `ast::Visibility`
Aaron Hill [Fri, 21 Aug 2020 23:11:00 +0000 (19:11 -0400)]
Attach `TokenStream` to `ast::Visibility`

A `Visibility` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher

3 years agoAttach `TokenStream` to `ast::Path`
Aaron Hill [Fri, 21 Aug 2020 22:51:23 +0000 (18:51 -0400)]
Attach `TokenStream` to `ast::Path`

3 years agoAttach tokens to `NtMeta` (`ast::AttrItem`)
Aaron Hill [Fri, 21 Aug 2020 22:37:34 +0000 (18:37 -0400)]
Attach tokens to `NtMeta` (`ast::AttrItem`)

An `AttrItem` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher

3 years agoCollect tokens when handling `:literal` matcher
Aaron Hill [Fri, 21 Aug 2020 22:28:47 +0000 (18:28 -0400)]
Collect tokens when handling `:literal` matcher

An `NtLiteral` just wraps an `Expr`, so we don't need to add a new `tokens`
field to an AST struct.

3 years agoAttach `TokenStream` to `ast::Ty`
Aaron Hill [Fri, 21 Aug 2020 22:18:04 +0000 (18:18 -0400)]
Attach `TokenStream` to `ast::Ty`

A `Ty` does not have outer attributes, so we only capture tokens
when parsing a `macro_rules!` matcher

3 years agoAttach `TokenStream` to `ast::Block`
Aaron Hill [Fri, 21 Aug 2020 21:52:52 +0000 (17:52 -0400)]
Attach `TokenStream` to `ast::Block`

A `Block` does not have outer attributes, so we only capture tokens when
parsing a `macro_rules!` matcher

3 years agoAuto merge of #76574 - flip1995:clippyup, r=Manishearth
bors [Thu, 10 Sep 2020 21:25:55 +0000 (21:25 +0000)]
Auto merge of #76574 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy update

r? `@Manishearth`

3 years agoAuto merge of #76582 - tmandry:rollup-lwwc93b, r=tmandry
bors [Thu, 10 Sep 2020 19:23:11 +0000 (19:23 +0000)]
Auto merge of #76582 - tmandry:rollup-lwwc93b, r=tmandry

Rollup of 11 pull requests

Successful merges:

 - #75857 (Syntactically permit unsafety on mods)
 - #76289 (Add docs about crate level documentation support)
 - #76514 (Add revisions to const generic issue UI tests.)
 - #76524 (typeck: don't suggest inaccessible private fields)
 - #76548 (Validate removal of AscribeUserType, FakeRead, and Shallow borrow)
 - #76555 (Reword `trivial_casts` lint in rustc book to better explain what it does.)
 - #76559 (add the `const_evaluatable_checked` feature)
 - #76563 (small typo fix in rustc_parse docs)
 - #76565 (take reference to Place directly instead of taking reference to Box<Place>)
 - #76567 (use push(char) to add chars (single-char &strs) to strings instead of push_str(&str))
 - #76568 (Add missing examples on core traits' method)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76568 - GuillaumeGomez:add-missing-examples, r=jyn514
Tyler Mandry [Thu, 10 Sep 2020 19:20:15 +0000 (12:20 -0700)]
Rollup merge of #76568 - GuillaumeGomez:add-missing-examples, r=jyn514

Add missing examples on core traits' method

Linked to #76450.

r? @jyn514

3 years agoRollup merge of #76567 - matthiaskrgr:clone_on_copy, r=varkor
Tyler Mandry [Thu, 10 Sep 2020 19:20:12 +0000 (12:20 -0700)]
Rollup merge of #76567 - matthiaskrgr:clone_on_copy, r=varkor

use push(char) to add chars (single-char &strs) to strings instead of push_str(&str)

3 years agoRollup merge of #76565 - matthiaskrgr:box_place, r=oli-obk
Tyler Mandry [Thu, 10 Sep 2020 19:20:11 +0000 (12:20 -0700)]
Rollup merge of #76565 - matthiaskrgr:box_place, r=oli-obk

take reference to Place directly instead of taking reference to Box<Place>

clippy::borrowed_box

3 years agoRollup merge of #76563 - yokodake:patch-1, r=jonas-schievink
Tyler Mandry [Thu, 10 Sep 2020 19:20:09 +0000 (12:20 -0700)]
Rollup merge of #76563 - yokodake:patch-1, r=jonas-schievink

small typo fix in rustc_parse docs

small typo in rustc_parse::new_parser_from_file's documentation

I'm not sure a PR is the way to do this though.

3 years agoRollup merge of #76559 - lcnr:const-evaluatable, r=oli-obk
Tyler Mandry [Thu, 10 Sep 2020 19:20:07 +0000 (12:20 -0700)]
Rollup merge of #76559 - lcnr:const-evaluatable, r=oli-obk

add the `const_evaluatable_checked` feature

Implements a rather small subset of https://github.com/rust-lang/compiler-team/issues/340

Unlike the MCP, this does not try to compare different constant, but instead only adds the constants found in where clauses
to the predicates of a function. This PR adds the feature gate `const_evaluatable_checked`, without which nothing should change.

r? @oli-obk @eddyb

3 years agoRollup merge of #76555 - alilleybrinker:reword_trivial_casts_lint_doc, r=steveklabnik
Tyler Mandry [Thu, 10 Sep 2020 19:20:06 +0000 (12:20 -0700)]
Rollup merge of #76555 - alilleybrinker:reword_trivial_casts_lint_doc, r=steveklabnik

Reword `trivial_casts` lint in rustc book to better explain what it does.

The current description of the trivial casts lint under the "allowed
by default" listing in the rustc book indicates the lint is for casts
which may be removed, which is less clear than saying it's for casts
which may be replaced by coercion (which is the wording used by the
error message included in the doc).

This commit changes the wording slightly to better describe what the
lint does.

This issue bit me in some recent code where I was attempting to
convert a `Vec<SomeType>` to a `Vec<SomeTraitObject>`, and
hit my project-wide `#![deny(trivial_casts)]` with
`map(|o| Box::new(o) as TraitObject)`. I'd read the book docs for
`trivial_casts` and was surprised by the error, as I took it to mean
the cast ought to be removed (rather than replaced by ascription
in this case). Removing the cast meant other code didn't compile,
and I then found issues like #23742 and realized my misunderstanding.

3 years agoRollup merge of #76548 - tmiasko:validate, r=davidtwco
Tyler Mandry [Thu, 10 Sep 2020 19:20:04 +0000 (12:20 -0700)]
Rollup merge of #76548 - tmiasko:validate, r=davidtwco

Validate removal of AscribeUserType, FakeRead, and Shallow borrow

Those statements are removed by CleanupNonCodegenStatements pass
in drop lowering phase, and should not occur afterwards.

3 years agoRollup merge of #76524 - davidtwco:issue-76077-inaccessible-private-fields, r=estebank
Tyler Mandry [Thu, 10 Sep 2020 19:20:02 +0000 (12:20 -0700)]
Rollup merge of #76524 - davidtwco:issue-76077-inaccessible-private-fields, r=estebank

typeck: don't suggest inaccessible private fields

Fixes #76077.

This PR adjusts the missing field diagnostic logic in typeck so that when none of the missing fields in a struct expr are accessible then the error is less confusing.

r? @estebank

3 years agoRollup merge of #76514 - hameerabbasi:const-generics-revs, r=lcnr
Tyler Mandry [Thu, 10 Sep 2020 19:20:01 +0000 (12:20 -0700)]
Rollup merge of #76514 - hameerabbasi:const-generics-revs, r=lcnr

Add revisions to const generic issue UI tests.

Fixes #75279.

I have gotten into the flow, so I can do more of these if requested. I'm looking for feedback as to whether my work is on the right track so far.

3 years agoRollup merge of #76289 - arijit79:master, r=jyn514
Tyler Mandry [Thu, 10 Sep 2020 19:19:59 +0000 (12:19 -0700)]
Rollup merge of #76289 - arijit79:master, r=jyn514

Add docs about crate level documentation support

Wrote information about how to write documentation on the crate level in rhe rustdoc book

3 years agoRollup merge of #75857 - dtolnay:unsafe, r=nagisa
Tyler Mandry [Thu, 10 Sep 2020 19:19:57 +0000 (12:19 -0700)]
Rollup merge of #75857 - dtolnay:unsafe, r=nagisa

Syntactically permit unsafety on mods

Similar to https://github.com/rust-lang/rust/pull/66183; we will accept these constructs syntactically but reject with a semantic check after macro expansion if a proc macro hasn't replaced it with something else meaningful to Rust.

```rust
#[mymacro]
unsafe mod m {
    ...
}

#[mymacro]
unsafe extern "C++" {
    ...
}
```

The intention is that this might be used as a kind of "item-level unsafe" in attribute macro DSLs -- holding things which are unsafe to declare but potentially safe to use. For example I look forward to using this in https://github.com/dtolnay/cxx.

In the absence of a procedural macro rewriting them to something else, they'll continue to be rejected at compile time though with a better error message than before.

### Before:

```console
error: expected item, found keyword `unsafe`
 --> src/main.rs:1:1
  |
1 | unsafe mod m {
  | ^^^^^^ expected item
```

### After:

```console
error: module cannot be declared unsafe
 --> src/main.rs:1:1
  |
1 | unsafe mod m {
  | ^^^^^^

error: extern block cannot be declared unsafe
 --> src/main.rs:4:1
  |
4 | unsafe extern "C++" {
  | ^^^^^^
```

Closes #68048.

3 years agotypeck/pat: inaccessible private fields
David Wood [Thu, 10 Sep 2020 11:32:45 +0000 (12:32 +0100)]
typeck/pat: inaccessible private fields

This commit adjusts the missing field diagnostic logic for struct
patterns in typeck to improve the diagnostic when the missing fields are
inaccessible.

Signed-off-by: David Wood <david@davidtw.co>
3 years agotypeck/expr: inaccessible private fields
David Wood [Wed, 9 Sep 2020 14:42:37 +0000 (15:42 +0100)]
typeck/expr: inaccessible private fields

This commit adjusts the missing field diagnostic logic for struct
expressions in typeck to improve the diagnostic when the missing
fields are inaccessible.

Signed-off-by: David Wood <david@davidtw.co>
3 years agoAuto merge of #76564 - pietroalbini:ci-avoid-wasting-10-minutes, r=Mark-Simulacrum
bors [Thu, 10 Sep 2020 16:42:00 +0000 (16:42 +0000)]
Auto merge of #76564 - pietroalbini:ci-avoid-wasting-10-minutes, r=Mark-Simulacrum

ci: avoid moving the build directory on GHA

While waiting for a PR job to start testing my code, I noticed the symlink-build-dir step took 10 minutes to complete, so I investigated what caused that.

It seems like something changed in the build environment between version 20200901.1 (where the step took 45 seconds) and version 20200908.1 (where the step took 10 minutes). At the time of writing this commit, the rust-lang organization is on vertsion 20200908.1, while the rust-lang-ci organization is at version 20200901.1 (and is not affected by this yet).

There is no need for this step anymore on GHA, as our XL builders got an increase in the root paritition size, so this commit removes the code that moved stuff around on GHA (while keeping it on Azure).

For the record, at the time of writing this, the disk situation is:

```
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       667G   60G  607G   9% /
/dev/sdb1       110G  4.1G  101G   4% /mnt
```

r? `@Mark-Simulacrum`

3 years agoOnly copy LLVM into rust-dev with internal LLVM
Mark Rousskov [Thu, 10 Sep 2020 15:44:28 +0000 (11:44 -0400)]
Only copy LLVM into rust-dev with internal LLVM

This avoids needing to figure out where to locate each of the components with an
external LLVM.

3 years agoMerge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup
flip1995 [Thu, 10 Sep 2020 15:47:07 +0000 (17:47 +0200)]
Merge commit '5034d47f721ff4c3a3ff2aca9ef2ef3e1d067f9f' into clippyup

3 years agoAuto merge of #5980 - matsujika:create-dir, r=flip1995
bors [Thu, 10 Sep 2020 14:34:22 +0000 (14:34 +0000)]
Auto merge of #5980 - matsujika:create-dir, r=flip1995

Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none

3 years agoAdd docs about crate level documentation support
arijit79 [Thu, 3 Sep 2020 14:38:15 +0000 (20:08 +0530)]
Add docs about crate level documentation support

3 years agoUpdate libc in Cargo.lock
Thomas de Zeeuw [Thu, 10 Sep 2020 12:37:50 +0000 (14:37 +0200)]
Update libc in Cargo.lock

3 years agoUse IOV_MAX and UIO_MAXIOV constants in limit vectored I/O
Thomas de Zeeuw [Thu, 10 Sep 2020 09:35:25 +0000 (11:35 +0200)]
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.

3 years agoAuto merge of #5931 - montrivo:unit-arg, r=flip1995
bors [Thu, 10 Sep 2020 14:11:27 +0000 (14:11 +0000)]
Auto merge of #5931 - montrivo:unit-arg, r=flip1995

improve the suggestion of the lint `unit-arg`

Fixes #5823
Fixes #6015

Changes
```
help: move the expression in front of the call...
  |
3 |     g();
  |
help: ...and use a unit literal instead
  |
3 |     o.map_or((), |i| f(i))
  |
```
into
```
help: move the expression in front of the call and replace it with the unit literal `()`
  |
3 |     g();
  |     o.map_or((), |i| f(i))
  |
```
changelog: improve the suggestion of the lint `unit-arg`

3 years agoSyntactically permit unsafety on mods
David Tolnay [Sun, 23 Aug 2020 10:42:19 +0000 (03:42 -0700)]
Syntactically permit unsafety on mods

3 years agoAuto merge of #6023 - matthiaskrgr:box, r=flip1995
bors [Thu, 10 Sep 2020 13:49:50 +0000 (13:49 +0000)]
Auto merge of #6023 - matthiaskrgr:box, r=flip1995

link to the Box docs in related lint documentation.

changelog: link to the box docs in lint docs

3 years agoAuto merge of #6027 - flip1995:rustup, r=flip1995
bors [Thu, 10 Sep 2020 13:25:39 +0000 (13:25 +0000)]
Auto merge of #6027 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoCleanup of rustup
flip1995 [Thu, 10 Sep 2020 12:18:05 +0000 (14:18 +0200)]
Cleanup of rustup

3 years agoAdd missing examples on core traits' method
Guillaume Gomez [Thu, 10 Sep 2020 12:11:25 +0000 (14:11 +0200)]
Add missing examples on core traits' method

3 years agouse push(char) instead of push_str(&str) to add single chars to strings
Matthias Krüger [Thu, 10 Sep 2020 11:57:40 +0000 (13:57 +0200)]
use push(char) instead of push_str(&str) to add single chars to strings

clippy::single-char-push-str

3 years agodon't clone types that are copy (clippy::clone_on_copy)
Matthias Krüger [Thu, 10 Sep 2020 11:20:33 +0000 (13:20 +0200)]
don't clone types that are copy (clippy::clone_on_copy)

3 years agouse String::from instead of format!() macro to craft string clippy::useless_format
Matthias Krüger [Thu, 10 Sep 2020 11:16:35 +0000 (13:16 +0200)]
use String::from instead of format!() macro to craft string clippy::useless_format

3 years agotake reference to Place directly instead of taking reference to Box<Place>
Matthias Krüger [Thu, 10 Sep 2020 11:08:28 +0000 (13:08 +0200)]
take reference to Place directly instead of taking reference to Box<Place>

clippy::borrowed_box

3 years agoci: avoid moving the build directory on GHA
Pietro Albini [Thu, 10 Sep 2020 10:54:29 +0000 (12:54 +0200)]
ci: avoid moving the build directory on GHA

While waiting for a PR job to start testing my code, I noticed the
symlink-build-dir step took 10 minutes to complete, so I investigated
what caused that.

It seems like something changed in the build environment between version
20200901.1 (where the step took 45 seconds) and version 20200908.1
(where the step took 10 minutes). At the time of writing this commit,
the rust-lang organization is on vertsion 20200908.1, while the
rust-lang-ci organization is at version 20200901.1 (and is not affected
by this yet).

There is no need for this step anymore on GHA, as our XL builders got an
increase in the root paritition size, so this commit removes the code
that moved stuff around on GHA (while keeping it on Azure).

For the record, at the time of writing this, the disk situation is:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       667G   60G  607G   9% /
/dev/sdb1       110G  4.1G  101G   4% /mnt

3 years agoAuto merge of #76378 - petrochenkov:lldtest, r=Mark-Simulacrum
bors [Thu, 10 Sep 2020 10:06:44 +0000 (10:06 +0000)]
Auto merge of #76378 - petrochenkov:lldtest, r=Mark-Simulacrum

rustbuild: Build tests with LLD if `use-lld = true` was passed

Addresses https://github.com/rust-lang/rust/pull/76127#discussion_r479932392.

Our test suite is generally ready to run with an explicitly specified linker (https://github.com/rust-lang/rust/pull/45191),
 so LLD specified with `use-lld = true` works as well.

Only 4 tests fail (on `x86_64-pc-windows-msvc`):
```
ui/panic-runtime/lto-unwind.rs
run-make-fulldeps/debug-assertions
run-make-fulldeps/foreign-exceptions
run-make-fulldeps/test-harness
```
All of them are legitimate issues with LLD (or at least with combination Rust+LLD) and manifest in segfaults on access to TLS (https://github.com/rust-lang/rust/pull/76127#issuecomment-683473325). UPD: These issues are caused by https://github.com/rust-lang/rust/issues/72145 and appear because I had `-Ctarget-cpu=native` set.

UPD: Further commits build tests with LLD for non-MSVC targets and propagate LLD to more places when `use-lld` is enabled.

3 years agosmall typo fix in rustc_parse docs
Nanami [Thu, 10 Sep 2020 09:56:11 +0000 (11:56 +0200)]
small typo fix in rustc_parse docs

3 years agoAuto merge of #76291 - matklad:spacing, r=petrochenkov
bors [Thu, 10 Sep 2020 08:07:48 +0000 (08:07 +0000)]
Auto merge of #76291 - matklad:spacing, r=petrochenkov

Rename IsJoint -> Spacing

Builds on #76286 and might conflict with #76285

r? `@petrochenkov`

3 years agoAuto merge of #6024 - matthiaskrgr:unit_type, r=phansch
bors [Thu, 10 Sep 2020 07:49:07 +0000 (07:49 +0000)]
Auto merge of #6024 - matthiaskrgr:unit_type, r=phansch

print the unit type `()` in related lint messages.

changelog: print the unit type `()` in related lint messages

3 years agofix tidy, small cleanup
Bastian Kauschke [Thu, 10 Sep 2020 07:48:02 +0000 (09:48 +0200)]
fix tidy, small cleanup

3 years agoAdd revisions to const generic UI tests.
Hameer Abbasi [Thu, 10 Sep 2020 07:30:05 +0000 (09:30 +0200)]
Add revisions to const generic UI tests.

3 years agoAdd revisions to const generic default UI tests.
Hameer Abbasi [Thu, 10 Sep 2020 07:18:40 +0000 (09:18 +0200)]
Add revisions to const generic default UI tests.

3 years agoRespond to review comments.
Hameer Abbasi [Thu, 10 Sep 2020 07:04:14 +0000 (09:04 +0200)]
Respond to review comments.

3 years agoimplement `const_evaluatable_checked` feature MVP
Bastian Kauschke [Thu, 10 Sep 2020 06:52:02 +0000 (08:52 +0200)]
implement `const_evaluatable_checked` feature MVP

3 years agoAuto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
bors [Thu, 10 Sep 2020 05:54:26 +0000 (05:54 +0000)]
Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk

Add CONST_ITEM_MUTATION lint

Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.

3 years agoAuto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk
bors [Thu, 10 Sep 2020 05:54:26 +0000 (05:54 +0000)]
Auto merge of #75573 - Aaron1011:feature/const-mutation-lint, r=oli-obk

Add CONST_ITEM_MUTATION lint

Fixes #74053
Fixes #55721

This PR adds a new lint `CONST_ITEM_MUTATION`.
Given an item `const FOO: SomeType = ..`, this lint fires on:

* Attempting to write directly to a field (`FOO.field = some_val`) or
  array entry (`FOO.array_field[0] = val`)
* Taking a mutable reference to the `const` item (`&mut FOO`), including
  through an autoderef `FOO.some_mut_self_method()`

The lint message explains that since each use of a constant creates a
new temporary, the original `const` item will not be modified.

3 years agoAuto merge of #76558 - tmandry:rollup-bskim2r, r=tmandry
bors [Thu, 10 Sep 2020 04:03:28 +0000 (04:03 +0000)]
Auto merge of #76558 - tmandry:rollup-bskim2r, r=tmandry

Rollup of 7 pull requests

Successful merges:

 - #74787 (Move `rustllvm` into `compiler/rustc_llvm`)
 - #76458 (Add drain_filter method to HashMap and HashSet)
 - #76472 (rustbuild: don't set PYTHON_EXECUTABLE and WITH_POLLY cmake vars since they are no longer supported by llvm)
 - #76497 (Use intra-doc links in `core::ptr`)
 - #76500 (Add -Zgraphviz_dark_mode and monospace font fix)
 - #76543 (Document btree's unwrap_unchecked)
 - #76556 (Revert #76285)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #76556 - tmandry:revert-76285, r=tmandry
Tyler Mandry [Thu, 10 Sep 2020 04:02:38 +0000 (21:02 -0700)]
Rollup merge of #76556 - tmandry:revert-76285, r=tmandry

Revert #76285

Fixes #76399. Reverting because the issue is P-critical and there are no PRs up to fix it.

r? @Mark-Simulacrum
cc @matklad @dtolnay

3 years agoRollup merge of #76543 - ssomers:btree_cleanup_4, r=Mark-Simulacrum
Tyler Mandry [Thu, 10 Sep 2020 04:02:36 +0000 (21:02 -0700)]
Rollup merge of #76543 - ssomers:btree_cleanup_4, r=Mark-Simulacrum

Document btree's unwrap_unchecked

#74693's second wind

3 years agoRollup merge of #76500 - richkadel:mir-graphviz-dark, r=tmandry
Tyler Mandry [Thu, 10 Sep 2020 04:02:35 +0000 (21:02 -0700)]
Rollup merge of #76500 - richkadel:mir-graphviz-dark, r=tmandry

Add -Zgraphviz_dark_mode and monospace font fix

Many developers use a dark theme with editors and IDEs, but this
typically doesn't extend to graphviz output.

When I bring up a MIR graphviz document, the white background is
strikingly bright. This new option changes the colors used for graphviz
output to work better in dark-themed UIs.

<img width="1305" alt="Screen Shot 2020-09-09 at 3 00 31 PM" src="https://user-images.githubusercontent.com/3827298/92659478-4b9bff00-f2ad-11ea-8894-b40d3a873cb9.png">

Also fixed the monospace font for common graphviz renders (e.g., VS Code extensions), as described in https://github.com/rust-lang/rust/pull/76500#issuecomment-689837948

**Before:**
<img width="943" alt="Screen Shot 2020-09-09 at 2 48 44 PM" src="https://user-images.githubusercontent.com/3827298/92658939-47231680-f2ac-11ea-97ac-96727e4dd622.png">

**Now with fix:**
<img width="943" alt="Screen Shot 2020-09-09 at 2 49 02 PM" src="https://user-images.githubusercontent.com/3827298/92658959-51451500-f2ac-11ea-9aae-de982d466d6a.png">

3 years agoRollup merge of #76497 - camelid:intra-doc-links-for-core-ptr, r=jyn514
Tyler Mandry [Thu, 10 Sep 2020 04:02:33 +0000 (21:02 -0700)]
Rollup merge of #76497 - camelid:intra-doc-links-for-core-ptr, r=jyn514

Use intra-doc links in `core::ptr`

Part of #75080.

The only link that I did not change is a link to a function on the
`pointer` primitive because intra-doc links for the `pointer` primitive
don't work yet (see #63351).

---

@rustbot modify labels: A-intra-doc-links T-doc

3 years agoRollup merge of #76472 - matthiaskrgr:llvm_cmake_vars, r=Mark-Simulacrum
Tyler Mandry [Thu, 10 Sep 2020 04:02:32 +0000 (21:02 -0700)]
Rollup merge of #76472 - matthiaskrgr:llvm_cmake_vars, r=Mark-Simulacrum

rustbuild: don't set PYTHON_EXECUTABLE and WITH_POLLY cmake vars since they are no longer supported by llvm

This resolves

CMake Warning:
  Manually-specified variables were not used by the project:

    PYTHON_EXECUTABLE
    WITH_POLLY

3 years agoRollup merge of #76458 - mbrubeck:hash_drain_filter, r=Amanieu
Tyler Mandry [Thu, 10 Sep 2020 04:02:27 +0000 (21:02 -0700)]
Rollup merge of #76458 - mbrubeck:hash_drain_filter, r=Amanieu

Add drain_filter method to HashMap and HashSet

Add `HashMap::drain_filter` and `HashSet::drain_filter`, implementing part of rust-lang/rfcs#2140.  These new methods are unstable.  The tracking issue is #59618.

The added iterators behave the same as `BTreeMap::drain_filter` and `BTreeSet::drain_filter`, except their iteration order is arbitrary.  The unit tests are adapted from `alloc::collections::btree`.

This branch rewrites `HashSet` to be a wrapper around `hashbrown::HashSet` rather than `std::collections::HashMap`.
 (Both are themselves wrappers around `hashbrown::HashMap`, so the in-memory representation is the same either way.)  This lets `std` re-use more iterator code from `hashbrown`.  Without this change, we would need to duplicate much more code to implement `HashSet::drain_filter`.

This branch also updates the `hashbrown` crate to version 0.9.0.  Aside from changes related to the `DrainFilter` iterators, this version only changes features that are not used in libstd or rustc.  And it updates `indexmap` to version 1.6.0, whose only change is compatibility with `hashbrown` 0.9.0.