]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoImprove SGX RWLock initializer test
Jethro Beekman [Thu, 3 Sep 2020 08:13:32 +0000 (10:13 +0200)]
Improve SGX RWLock initializer test

3 years agoAuto merge of #76235 - jyn514:std-intra-links, r=poliorcetics
bors [Thu, 3 Sep 2020 05:53:48 +0000 (05:53 +0000)]
Auto merge of #76235 - jyn514:std-intra-links, r=poliorcetics

Convert many files to intra-doc links

Helps with https://github.com/rust-lang/rust/issues/75080
r? @poliorcetics
I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)

3 years agoAuto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
bors [Thu, 3 Sep 2020 02:15:16 +0000 (02:15 +0000)]
Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum

Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi

partial fix for #73904

There are still more that was not applied in [mod.rs]( https://github.com/rust-lang/rust/blob/38fab2ea92a48980219989817201bf2094ae826a/library/std/src/sys/wasi/mod.rs) and that is due to its using files from `../unsupported`

like:
```
#[path = "../unsupported/cmath.rs"]
pub mod cmath;
```

3 years agoApplied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi
Amjad Alsharafi [Thu, 27 Aug 2020 02:43:58 +0000 (10:43 +0800)]
Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi

All refactoring needed was only in `alloc.rs`, changed part of the code
in `alloc` method to satisfy the SAFETY statement

3 years agoAuto merge of #76265 - Dylan-DPC:rollup-j3i509l, r=Dylan-DPC
bors [Thu, 3 Sep 2020 00:24:50 +0000 (00:24 +0000)]
Auto merge of #76265 - Dylan-DPC:rollup-j3i509l, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #75150 (Add a note for Ipv4Addr::to_ipv6_compatible)
 - #76120 (Add `[T; N]::as_[mut_]slice`)
 - #76142 (Make all methods of `std::net::Ipv4Addr` const)
 - #76164 (Link to slice pattern in array docs)
 - #76167 (Replace MinGW library hack with heuristic controlling link mode)
 - #76204 (Rename and expose LoopState as ControlFlow)
 - #76238 (Move to intra-doc links for library/core/src/iter/traits/iterator.rs)
 - #76242 (Read: adjust a FIXME reference)
 - #76243 (Fix typos in vec try_reserve(_exact) docs)
 - #76245 (inliner: Avoid query cycles when optimizing generators)
 - #76255 (Update books)
 - #76261 (Use intra-doc links in `core::marker`)

Failed merges:

r? @ghost

3 years agoRollup merge of #76261 - camelid:intra-doc-links-for-core-marker, r=jyn514
Dylan DPC [Thu, 3 Sep 2020 00:22:18 +0000 (02:22 +0200)]
Rollup merge of #76261 - camelid:intra-doc-links-for-core-marker, r=jyn514

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

Part of #75080.

Also cleaned up a few things.

---

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

3 years agoRollup merge of #76255 - ehuss:update-books, r=ehuss
Dylan DPC [Thu, 3 Sep 2020 00:22:16 +0000 (02:22 +0200)]
Rollup merge of #76255 - ehuss:update-books, r=ehuss

Update books

## reference

4 commits in 1b6c4b0afab97c0230433466c97167bbbe8445f6..25391dba46262f882fa846beefaff54a966a8fa5
2020-08-18 17:04:28 -0700 to 2020-09-02 07:22:55 -0700
- clarify when reading uninititalized memory is allowed (rust-lang-nursery/reference#852)
- Update patterns chapter, add rest patterns. (rust-lang-nursery/reference#876)
- Improve Type-Coersion Documentation (rust-lang-nursery/reference#843)
- Added variable back into example. (rust-lang-nursery/reference#880)

## book

3 commits in c0a6a61b8205da14ac955425f74258ffd8ee065d..e5ed97128302d5fa45dbac0e64426bc7649a558c
2020-08-14 14:21:49 -0500 to 2020-08-31 12:53:40 -0500
- Fix type mismatch in listing 10-5 (rust-lang/book#2441)
- Update ppendix-06-translation.md (rust-lang/book#2437)
- Correct no-listing-10-result-in-tests: Take tests module out of the main function (rust-lang/book#2430)

## rust-by-example

3 commits in 80a10e22140e28392b99d24ed02f4c6d8cb770a0..19f0a0372af497b34369cf182d9d16156cab2969
2020-08-08 09:56:46 -0300 to 2020-08-26 09:38:48 -0300
- prefer `length` over `size` when talking about number of elements vs. bytesize (rust-lang/rust-by-example#1372)
- Split out variable shadowing into a separate example (rust-lang/rust-by-example#1370)
- Update extern crate related sections (rust-lang/rust-by-example#1369)

## edition-guide

1 commits in bd6e4a9f59c5c1545f572266af77f5c7a5bad6d1..81f16863014de60b53de401d71ff904d163ee030
2020-07-12 17:37:08 -0500 to 2020-08-27 13:56:31 -0700
- Fix a small typo. (rust-lang/edition-guide#218)

3 years agoRollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morse
Dylan DPC [Thu, 3 Sep 2020 00:22:14 +0000 (02:22 +0200)]
Rollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morse

inliner: Avoid query cycles when optimizing generators

The HIR Id trick is insufficient to prevent query cycles when optimizing
generators, since merely requesting a layout of a generator also
computes its `optimized_mir`.

Make no attempts to inline functions into generators within the same
crate to avoid query cycles.

Fixes #76181.

3 years agoRollup merge of #76243 - ama0:patch-1, r=jonas-schievink
Dylan DPC [Thu, 3 Sep 2020 00:22:13 +0000 (02:22 +0200)]
Rollup merge of #76243 - ama0:patch-1, r=jonas-schievink

Fix typos in vec try_reserve(_exact) docs

`try_reserve` and `try_reserve_exact` docs refer to calling `reserve` and `reserve_exact`.
`try_reserve_exact` example uses `try_reserve` method instead of `try_reserve_exact`.

3 years agoRollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Dylan DPC [Thu, 3 Sep 2020 00:22:11 +0000 (02:22 +0200)]
Rollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC

Read: adjust a FIXME reference

There's already another reference to https://github.com/rust-lang/rust/issues/42788 for basically the same problem, so lets reuse it here:
https://github.com/rust-lang/rust/blob/5e208efaa850efaa97495e81c49cf0f5767e8f49/library/std/src/io/mod.rs#L369-L376

r? @Dylan-DPC

3 years agoRollup merge of #76238 - denisvasilik:intra-doc-links-core-iterator, r=jyn514
Dylan DPC [Thu, 3 Sep 2020 00:22:10 +0000 (02:22 +0200)]
Rollup merge of #76238 - denisvasilik:intra-doc-links-core-iterator, r=jyn514

Move to intra-doc links for library/core/src/iter/traits/iterator.rs

Helps with #75080.

@jyn514 We're almost finished with this issue. Thanks for mentoring. If you have other topics to work on just let me know, I will be around in Discord.

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

Known issues:

* Link from `core` to `std` (#74481):

    [`OsStr`]
    [`String`]
    [`VecDeque<T>`]

3 years agoRollup merge of #76204 - NoraCodes:nora/control_flow_enum, r=scottmcm
Dylan DPC [Thu, 3 Sep 2020 00:22:07 +0000 (02:22 +0200)]
Rollup merge of #76204 - NoraCodes:nora/control_flow_enum, r=scottmcm

Rename and expose LoopState as ControlFlow

Basic PR for #75744. Addresses everything there except for documentation; lots of examples are probably a good idea.

3 years agoRollup merge of #76167 - mati865:mingw-self-contained-heuristic, r=petrochenkov
Dylan DPC [Thu, 3 Sep 2020 00:22:06 +0000 (02:22 +0200)]
Rollup merge of #76167 - mati865:mingw-self-contained-heuristic, r=petrochenkov

Replace MinGW library hack with heuristic controlling link mode

Depends on https://github.com/rust-lang/rust/pull/76158
Closes https://github.com/rust-lang/rust/issues/68887

3 years agoRollup merge of #76164 - lzutao:slice-array, r=ehuss
Dylan DPC [Thu, 3 Sep 2020 00:22:04 +0000 (02:22 +0200)]
Rollup merge of #76164 - lzutao:slice-array, r=ehuss

Link to slice pattern in array docs

Fix a todo in https://github.com/rust-lang/reference/issues/739#issuecomment-578408449

3 years agoRollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse
Dylan DPC [Thu, 3 Sep 2020 00:22:02 +0000 (02:22 +0200)]
Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse

Make all methods of `std::net::Ipv4Addr` const

Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_global` (unstable)
 - `is_shared` (unstable)
 - `is_ietf_protocol_assignment` (unstable)
 - `is_benchmarking` (unstable)
 - `is_reserved` (unstable)
 - `is_multicast`
 - `is_broadcast`
 - `is_documentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This would make all methods of `Ipv6Addr` const.

Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation.

Part of #76205

3 years agoRollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum
Dylan DPC [Thu, 3 Sep 2020 00:22:00 +0000 (02:22 +0200)]
Rollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum

Add `[T; N]::as_[mut_]slice`

Part of me trying to populate arrays with a couple of basic useful methods, like slices already have. The ability to add methods to arrays were added in #75212.  Tracking issue: #76118

This adds:

```rust
impl<T, const N: usize> [T; N] {
    pub fn as_slice(&self) -> &[T];
    pub fn as_mut_slice(&mut self) -> &mut [T];
}
```

These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.

3 years agoRollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt
Dylan DPC [Thu, 3 Sep 2020 00:21:58 +0000 (02:21 +0200)]
Rollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt

Add a note for Ipv4Addr::to_ipv6_compatible

Previous discussion: #75019

> I think adding a comment saying "This isn't typically the method you want; these addresses don't typically function on modern systems. Use `to_ipv6_mapped` instead." would be a good first step, whether this method gets marked as deprecated or not.

_Originally posted by @joshtriplett in https://github.com/rust-lang/rust/pull/75150#issuecomment-680267745_

3 years agoAdd back missing link
Camelid [Wed, 2 Sep 2020 22:48:35 +0000 (15:48 -0700)]
Add back missing link

3 years agoUse intra-doc links in `core::marker`
Camelid [Wed, 2 Sep 2020 22:22:40 +0000 (15:22 -0700)]
Use intra-doc links in `core::marker`

3 years agoAuto merge of #76233 - cuviper:unhasher, r=Mark-Simulacrum
bors [Wed, 2 Sep 2020 22:16:22 +0000 (22:16 +0000)]
Auto merge of #76233 - cuviper:unhasher, r=Mark-Simulacrum

Avoid rehashing Fingerprint as a map key

This introduces a no-op `Unhasher` for map keys that are already hash-
like, for example `Fingerprint` and its wrapper `DefPathHash`. For these
we can directly produce the `u64` hash for maps. The first use of this
is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.

cc #56308
r? @eddyb

3 years agoFix incorrect link in prelude
Joshua Nelson [Wed, 2 Sep 2020 21:36:56 +0000 (17:36 -0400)]
Fix incorrect link in prelude

3 years agoRevert change to MaybeUninit until rustdoc bugs are fixed
Joshua Nelson [Wed, 2 Sep 2020 12:46:02 +0000 (08:46 -0400)]
Revert change to MaybeUninit until rustdoc bugs are fixed

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

3 years agoConvert many files to intra-doc links
Joshua Nelson [Wed, 2 Sep 2020 03:39:16 +0000 (23:39 -0400)]
Convert many files to intra-doc links

- Use intra-doc links for `std::io` in `std::fs`
- Use intra-doc links for File::read in unix/ext/fs.rs
- Remove explicit intra-doc links for `true` in `net/addr.rs`
- Use intra-doc links in alloc/src/sync.rs
- Use intra-doc links in src/ascii.rs
- Switch to intra-doc links in alloc/rc.rs
- Use intra-doc links in core/pin.rs
- Use intra-doc links in std/prelude
- Use shorter links in `std/fs.rs`

  `io` is already in scope.

3 years agoAuto merge of #76160 - scileo:format-recovery, r=petrochenkov
bors [Wed, 2 Sep 2020 19:29:27 +0000 (19:29 +0000)]
Auto merge of #76160 - scileo:format-recovery, r=petrochenkov

Improve recovery on malformed format call

The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues.

r? @petrochenkov

3 years agoFormat ControlFlow changes with rustfmt
Leonora Tindall [Wed, 2 Sep 2020 19:12:21 +0000 (14:12 -0500)]
Format ControlFlow changes with rustfmt

3 years agoUpdate books
Eric Huss [Wed, 2 Sep 2020 18:10:36 +0000 (11:10 -0700)]
Update books

3 years agoAuto merge of #75960 - camelid:patch-6, r=jyn514
bors [Wed, 2 Sep 2020 17:35:46 +0000 (17:35 +0000)]
Auto merge of #75960 - camelid:patch-6, r=jyn514

Improve docs for the `const` keyword

@rustbot modify labels: T-doc

3 years agoRevert link removal of Some(T)
Denis Vasilik [Wed, 2 Sep 2020 17:11:19 +0000 (19:11 +0200)]
Revert link removal of Some(T)

3 years agoRevert link removal of
Denis Vasilik [Wed, 2 Sep 2020 17:07:32 +0000 (19:07 +0200)]
Revert link removal of

3 years agoRevert link removal
Denis Vasilik [Wed, 2 Sep 2020 16:51:53 +0000 (18:51 +0200)]
Revert  link removal

3 years agoRevert module level documentation link
Denis Vasilik [Wed, 2 Sep 2020 16:51:08 +0000 (18:51 +0200)]
Revert module level documentation link

3 years agoApply suggestions from review
Denis Vasilik [Wed, 2 Sep 2020 16:32:46 +0000 (18:32 +0200)]
Apply suggestions from review

3 years agoAuto merge of #76241 - RalfJung:flt2dec, r=Mark-Simulacrum
bors [Wed, 2 Sep 2020 15:23:08 +0000 (15:23 +0000)]
Auto merge of #76241 - RalfJung:flt2dec, r=Mark-Simulacrum

flt2dec: properly handle uninitialized memory

The float-to-str code currently uses uninitialized memory incorrectly (see https://github.com/rust-lang/rust/issues/76092). This PR fixes that.

Specifically, that code used `&mut [T]` as "out references", but it would be incorrect for the caller to actually pass uninitialized memory. So the PR changes this to `&mut [MaybeUninit<T>]`, and then functions return a `&[T]` to the part of the buffer that they initialized (some functions already did that, indirectly via `&Formatted`, others were adjusted to return that buffer instead of just the initialized length).

What I particularly like about this is that it moves `unsafe` to the right place: previously, the outermost caller had to use `unsafe` to assert that things are initialized; now it is the functions that do the actual initializing which have the corresponding `unsafe` block when they call `MaybeUninit::slice_get_ref` (renamed in https://github.com/rust-lang/rust/pull/76217 to `slice_assume_init_ref`).

Reviewers please be aware that I have no idea how any of this code actually works. My changes were purely mechanical and type-driven. The test suite passes so I guess I didn't screw up badly...

Cc @sfackler this is somewhat related to your RFC, and possibly some of this code could benefit from (a generalized version of) the API you describe there. But for now I think what I did is "good enough".

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

3 years agoadd a note for Ipv4Addr::to_ipv6_compatible
南浦月 [Wed, 2 Sep 2020 13:08:09 +0000 (21:08 +0800)]
add a note for Ipv4Addr::to_ipv6_compatible

3 years agoSame typos in vec_deque
Anton [Wed, 2 Sep 2020 12:09:42 +0000 (14:09 +0200)]
Same typos in vec_deque

3 years agoImprove recovery on malformed format call
Sasha [Mon, 31 Aug 2020 09:45:50 +0000 (11:45 +0200)]
Improve recovery on malformed format call

If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.

3 years agoFix typos in vec try_reserve(_exact) docs
Anton [Wed, 2 Sep 2020 11:12:44 +0000 (13:12 +0200)]
Fix typos in vec try_reserve(_exact) docs

`try_reserve` and `try_reserve_exact` docs refer to calling `reserve` and `reserve_exact`.
`try_reserve_exact` example uses `try_reserve` method instead of `try_reserve_exact`.

3 years agoflt2dec: properly handle uninitialized memory
Ralf Jung [Wed, 2 Sep 2020 10:18:07 +0000 (12:18 +0200)]
flt2dec: properly handle uninitialized memory

3 years agoRead: adjust a FIXME reference
Ralf Jung [Wed, 2 Sep 2020 10:34:15 +0000 (12:34 +0200)]
Read: adjust a FIXME reference

3 years agoAuto merge of #76216 - marmeladema:use-once-cell-from-std, r=matklad
bors [Wed, 2 Sep 2020 06:46:21 +0000 (06:46 +0000)]
Auto merge of #76216 - marmeladema:use-once-cell-from-std, r=matklad

compiler: use `OnceCell` from std

Fixes #76192

The only remaining direct use of `lazy_static` crate is in `src/bootstrap`  but I am not sure how I can remove that dependency for now.

r? @matklad

3 years agoUse intra-doc links for `MaybeUninit` in `boxed.rs`
Joshua Nelson [Wed, 2 Sep 2020 03:54:17 +0000 (23:54 -0400)]
Use intra-doc links for `MaybeUninit` in `boxed.rs`

3 years agoRemove explicit links to `true` and `false` in ip.rs
Joshua Nelson [Wed, 2 Sep 2020 03:33:44 +0000 (23:33 -0400)]
Remove explicit links to `true` and `false` in ip.rs

3 years agoAuto merge of #76170 - matklad:notrivia, r=petrochenkov
bors [Wed, 2 Sep 2020 03:19:38 +0000 (03:19 +0000)]
Auto merge of #76170 - matklad:notrivia, r=petrochenkov

Remove trivia tokens

r? @ghost

3 years agoImprove wording for const pointers
Camelid [Wed, 2 Sep 2020 02:44:20 +0000 (19:44 -0700)]
Improve wording for const pointers

3 years agoAuto merge of #76231 - tmandry:rollup-ilvs9fq, r=tmandry
bors [Wed, 2 Sep 2020 01:29:28 +0000 (01:29 +0000)]
Auto merge of #76231 - tmandry:rollup-ilvs9fq, r=tmandry

Rollup of 14 pull requests

Successful merges:

 - #74880 (Add trailing comma support to matches macro)
 - #76074 (Add new `-Z dump-mir-spanview` option)
 - #76088 (Add more examples to lexicographic cmp on Iterators.)
 - #76099 (Add info about `!` and `impl Trait`)
 - #76126 (Use "Fira Sans" for crate list font)
 - #76132 (Factor out StmtKind::MacCall fields into `MacCallStmt` struct)
 - #76143 (Give a better error message for duplicate built-in macros)
 - #76158 (Stabilise link-self-contained option)
 - #76201 (Move to intra-doc links for library/core/src/panic.rs)
 - #76206 (Make all methods of `std::net::Ipv6Addr` const)
 - #76207 (# Move to intra-doc links for library/core/src/clone.rs)
 - #76212 (Document lint missing_doc_code_examples is nightly-only)
 - #76218 (lexer: Tiny improvement to shebang detection)
 - #76221 (Clean up header in `iter` docs for `for` loops)

Failed merges:

r? @ghost

3 years agoAvoid rehashing Fingerprint as a map key
Josh Stone [Wed, 2 Sep 2020 01:27:02 +0000 (18:27 -0700)]
Avoid rehashing Fingerprint as a map key

This introduces a no-op `Unhasher` for map keys that are already hash-
like, for example `Fingerprint` and its wrapper `DefPathHash`. For these
we can directly produce the `u64` hash for maps. The first use of this
is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.

3 years agoRollup merge of #76221 - camelid:cleanup-iter-for, r=jyn514
Tyler Mandry [Wed, 2 Sep 2020 01:24:48 +0000 (18:24 -0700)]
Rollup merge of #76221 - camelid:cleanup-iter-for, r=jyn514

Clean up header in `iter` docs for `for` loops

@rustbot modify labels: T-doc

3 years agoRollup merge of #76218 - petrochenkov:shebang3, r=matklad
Tyler Mandry [Wed, 2 Sep 2020 01:24:46 +0000 (18:24 -0700)]
Rollup merge of #76218 - petrochenkov:shebang3, r=matklad

lexer: Tiny improvement to shebang detection

Lexer now discerns between regular comments and doc comments, so use that.
The change only affects the choice of reported errors.

3 years agoRollup merge of #76212 - JesHansen:fix-lint-doc, r=jyn514
Tyler Mandry [Wed, 2 Sep 2020 01:24:44 +0000 (18:24 -0700)]
Rollup merge of #76212 - JesHansen:fix-lint-doc, r=jyn514

Document lint missing_doc_code_examples is nightly-only

Closes #76194

3 years agoRollup merge of #76207 - denisvasilik:intra-doc-links-core-clone, r=jyn514
Tyler Mandry [Wed, 2 Sep 2020 01:24:43 +0000 (18:24 -0700)]
Rollup merge of #76207 - denisvasilik:intra-doc-links-core-clone, r=jyn514

# Move to intra-doc links for library/core/src/clone.rs

Helps with #75080.

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

3 years agoRollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morse
Tyler Mandry [Wed, 2 Sep 2020 01:24:41 +0000 (18:24 -0700)]
Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morse

Make all methods of `std::net::Ipv6Addr` const

Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature:
- `segments`
- `is_unspecified`
- `is_loopback`
- `is_global` (unstable)
- `is_unique_local`
- `is_unicast_link_local_strict`
- `is_documentation`
- `multicast_scope`
- `is_multicast`
- `to_ipv4_mapped`
- `to_ipv4`

This would make all methods of `Ipv6Addr` const.

Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`, all other methods did not require a change.

All these methods are dependent on `segments`, the current implementation of which requires unstable `const_fn_transmute` ([PR#75085](https://github.com/rust-lang/rust/pull/75085)).

Part of #76205

3 years agoRollup merge of #76201 - denisvasilik:intra-doc-links-core-panic, r=kennytm
Tyler Mandry [Wed, 2 Sep 2020 01:24:39 +0000 (18:24 -0700)]
Rollup merge of #76201 - denisvasilik:intra-doc-links-core-panic, r=kennytm

Move to intra-doc links for library/core/src/panic.rs

Helps with #75080.

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

Known issues:

* Link from `core` to `std` (#74481):

    [`set_hook`]
    [`String`]

3 years agoRollup merge of #76158 - mati865:self-contained-option, r=petrochenkov
Tyler Mandry [Wed, 2 Sep 2020 01:24:36 +0000 (18:24 -0700)]
Rollup merge of #76158 - mati865:self-contained-option, r=petrochenkov

Stabilise link-self-contained option

MCP has been accepted: https://github.com/rust-lang/compiler-team/issues/343

I'll add improved heuristic in next PR.

3 years agoRollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov
Tyler Mandry [Wed, 2 Sep 2020 01:24:35 +0000 (18:24 -0700)]
Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov

Give a better error message for duplicate built-in macros

Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug.

r? @petrochenkov

3 years agoRollup merge of #76132 - Aaron1011:mac-call-stmt, r=petrochenkov
Tyler Mandry [Wed, 2 Sep 2020 01:24:33 +0000 (18:24 -0700)]
Rollup merge of #76132 - Aaron1011:mac-call-stmt, r=petrochenkov

Factor out StmtKind::MacCall fields into `MacCallStmt` struct

In PR #76130, I add a fourth field, which makes using a tuple variant
somewhat unwieldy.

3 years agoRollup merge of #76126 - camelid:crate-list-font, r=GuillaumeGomez
Tyler Mandry [Wed, 2 Sep 2020 01:24:31 +0000 (18:24 -0700)]
Rollup merge of #76126 - camelid:crate-list-font, r=GuillaumeGomez

Use "Fira Sans" for crate list font

Fira Sans is what's used for module lists and other item lists.
Previously, the default body font, "Source Serif Pro", was used for
crate lists, which didn't visually match other item lists.

@rustbot modify labels: T-rustdoc

3 years agoRollup merge of #76099 - camelid:patch-8, r=jyn514
Tyler Mandry [Wed, 2 Sep 2020 01:24:29 +0000 (18:24 -0700)]
Rollup merge of #76099 - camelid:patch-8, r=jyn514

Add info about `!` and `impl Trait`

Fixes #76094.

@rustbot modify labels: T-doc C-enhancement

3 years agoRollup merge of #76088 - hbina:add_example, r=LukasKalbertodt
Tyler Mandry [Wed, 2 Sep 2020 01:24:27 +0000 (18:24 -0700)]
Rollup merge of #76088 - hbina:add_example, r=LukasKalbertodt

Add more examples to lexicographic cmp on Iterators.

Given two arrays of T1 and T2, the most important rule of lexicographical comparison is that two arrays
of equal length will be compared until the first difference occured.

The examples provided only focuses on the second rule that says that the
shorter array will be filled with some T2 that is less than every T1.
Which is only possible because of the first rule.

3 years agoRollup merge of #76074 - richkadel:llvm-coverage-map-gen-6b.5.1, r=wesleywiser
Tyler Mandry [Wed, 2 Sep 2020 01:24:25 +0000 (18:24 -0700)]
Rollup merge of #76074 - richkadel:llvm-coverage-map-gen-6b.5.1, r=wesleywiser

Add new `-Z dump-mir-spanview` option

Similar to `-Z dump-mir-graphviz`, this adds the option to write
HTML+CSS files that allow users to analyze the spans associated with MIR
elements (by individual statement, just terminator, or overall basic
block).

This PR was split out from PR #76004, and exposes an API for spanview
HTML+CSS files that is also used to analyze code regions chosen for
coverage instrumentation (in a follow-on PR).

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

r? @tmandry
FYI @wesleywiser

3 years agoRollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay
Tyler Mandry [Wed, 2 Sep 2020 01:24:23 +0000 (18:24 -0700)]
Rollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay

Add trailing comma support to matches macro

3 years agoMinor improvements
Camelid [Wed, 2 Sep 2020 00:38:16 +0000 (17:38 -0700)]
Minor improvements

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoinliner: Avoid query cycles when optimizing generators
Tomasz Miąsko [Wed, 2 Sep 2020 00:00:00 +0000 (00:00 +0000)]
inliner: Avoid query cycles when optimizing generators

The HIR Id trick is insufficient to prevent query cycles when optimizing
generators, since merely requesting a layout of a generator also
computes its `optimized_mir`.

Make no attempts to inline functions into generators within the same
crate to avoid query cycles.

3 years agoClean up header in `iter` docs for `for` loops
Camelid [Tue, 1 Sep 2020 22:48:39 +0000 (15:48 -0700)]
Clean up header in `iter` docs for `for` loops

3 years agoUse intra-doc links
Denis Vasilik [Tue, 1 Sep 2020 21:59:00 +0000 (23:59 +0200)]
Use intra-doc links

3 years agoMake all remaining methods of `std::net::Ipv4Addr` const
Christiaan Dirkx [Tue, 1 Sep 2020 21:55:17 +0000 (23:55 +0200)]
Make all remaining methods of `std::net::Ipv4Addr` const

Makes the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `is_global`
 - `is_reserved`
 - `is_broadcast`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This results in all methods of `Ipv4Addr` being const.

Also adds tests for these methods in a const context.

3 years agolexer: Tiny improvement to shebang detection
Vadim Petrochenkov [Tue, 1 Sep 2020 21:22:47 +0000 (00:22 +0300)]
lexer: Tiny improvement to shebang detection

Lexer now discerns between regular comments and doc comments, so use that.
The change only affects the choice of reported errors.

3 years agodriver: replace `lazy_static` by `SyncLazy` from std
marmeladema [Tue, 1 Sep 2020 20:49:36 +0000 (21:49 +0100)]
driver: replace `lazy_static` by `SyncLazy` from std

3 years agofeature: replace `lazy_static` by `SyncLazy` from std
marmeladema [Tue, 1 Sep 2020 20:42:21 +0000 (21:42 +0100)]
feature: replace `lazy_static` by `SyncLazy` from std

3 years agohir: replace `lazy_static` by `SyncLazy` from std
marmeladema [Tue, 1 Sep 2020 20:31:22 +0000 (21:31 +0100)]
hir: replace `lazy_static` by `SyncLazy` from std

3 years agodatastructures: replace `lazy_static` by `SyncLazy` from std
marmeladema [Sun, 30 Aug 2020 10:48:50 +0000 (11:48 +0100)]
datastructures: replace `lazy_static` by `SyncLazy` from std

3 years agointerface: use `OnceCell` from standard library
marmeladema [Sun, 30 Aug 2020 10:41:36 +0000 (11:41 +0100)]
interface: use `OnceCell` from standard library

3 years agoRename and expose LoopState as ControlFlow
Leonora Tindall [Tue, 1 Sep 2020 16:44:32 +0000 (11:44 -0500)]
Rename and expose LoopState as ControlFlow

3 years agoUse "Fira Sans" for crate list font
Camelid [Sun, 30 Aug 2020 20:45:17 +0000 (13:45 -0700)]
Use "Fira Sans" for crate list font

Fira Sans is what's used for module lists and other item lists.
Previously, the default body font, "Source Serif Pro", was used for
crate lists, which didn't visually match other item lists.

3 years agoAuto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkov
bors [Tue, 1 Sep 2020 20:03:55 +0000 (20:03 +0000)]
Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkov

Run cfg-stripping on generic parameters before invoking derive macros

Fixes #75930

This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute
on a generic paramter is unusual, and combining it with a proc-macro
derive is probably even more unusual. I don't expect this to cause any
breakage.

3 years agoAdd test for `Ipv4Addr` methods in a const context
Christiaan Dirkx [Tue, 1 Sep 2020 19:58:35 +0000 (21:58 +0200)]
Add test for `Ipv4Addr` methods in a const context

3 years agoAdd trailing newline to `ipv6.rs`
CDirkx [Tue, 1 Sep 2020 19:36:45 +0000 (21:36 +0200)]
Add trailing newline to `ipv6.rs`

3 years agoChange implementation of `Ipv6Addr::is_unspecified` and `is_loopback` from `matches...
CDirkx [Tue, 1 Sep 2020 19:05:26 +0000 (21:05 +0200)]
Change implementation of `Ipv6Addr::is_unspecified` and `is_loopback` from `matches!` to `u128` comparison

Done because `matches!` doesn't optimize well with array comparisons

3 years agoAdd test for `Ipv6Addr` methods in a const context
CDirkx [Tue, 1 Sep 2020 18:59:46 +0000 (20:59 +0200)]
Add test for `Ipv6Addr` methods in a const context

3 years agoDocument lint missing_doc_code_examples is nightly-only
Jes Bak Hansen [Tue, 1 Sep 2020 18:45:21 +0000 (20:45 +0200)]
Document lint missing_doc_code_examples is nightly-only

3 years agoAuto merge of #74559 - jonhoo:stabilize-vecdeque-make_contiguous, r=dtolnay
bors [Tue, 1 Sep 2020 18:02:37 +0000 (18:02 +0000)]
Auto merge of #74559 - jonhoo:stabilize-vecdeque-make_contiguous, r=dtolnay

Stabilize deque_make_contiguous

Closes #70929.

/cc @Amanieu

3 years agoImprove readability
Denis Vasilik [Tue, 1 Sep 2020 17:56:32 +0000 (19:56 +0200)]
Improve readability

3 years agoReplace MinGW library hack with heuristic controlling link mode
Mateusz Mikuła [Mon, 31 Aug 2020 16:21:58 +0000 (18:21 +0200)]
Replace MinGW library hack with heuristic controlling link mode

3 years agoMake methods unstable const under `const_ipv4`
CDirkx [Tue, 1 Sep 2020 17:50:01 +0000 (19:50 +0200)]
Make methods unstable const under `const_ipv4`

3 years agoUse intra-doc links
Denis Vasilik [Tue, 1 Sep 2020 17:20:15 +0000 (19:20 +0200)]
Use intra-doc links

3 years agoMake all methods of `std::net::Ipv6Addr` const
CDirkx [Tue, 1 Sep 2020 17:00:20 +0000 (19:00 +0200)]
Make all methods of `std::net::Ipv6Addr` const

Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature:
- `segments`
- `is_unspecified`
- `is_loopback`
- `is_global` (unstable)
- `is_unique_local`
- `is_unicast_link_local_strict`
- `is_documentation`
- `multicast_scope`
- `is_multicast`
- `to_ipv4_mapped`
- `to_ipv4`

Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`.

Part of #76205

3 years agoEnhance wording
Denis Vasilik [Tue, 1 Sep 2020 16:16:34 +0000 (18:16 +0200)]
Enhance wording

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #76197 - Mark-Simulacrum:no-llvm-no-ninja, r=pietroalbini
bors [Tue, 1 Sep 2020 15:42:29 +0000 (15:42 +0000)]
Auto merge of #76197 - Mark-Simulacrum:no-llvm-no-ninja, r=pietroalbini

Move ninja requirements to a dynamic check, when actually building

It isn't practical to determine whether we'll build LLVM very early in the
pipeline, so move the ninja checking to a dynamic check.

r? @pietroalbini -- this should fix nightlies

3 years agoUse intra-doc links
Denis Vasilik [Tue, 1 Sep 2020 15:35:56 +0000 (17:35 +0200)]
Use intra-doc links

3 years agoMove ninja requirements to a dynamic check, when actually building
Mark Rousskov [Tue, 1 Sep 2020 13:17:26 +0000 (09:17 -0400)]
Move ninja requirements to a dynamic check, when actually building

It isn't practical to determine whether we'll build LLVM very early in the
pipeline, so move the ninja checking to a dynamic check.

3 years agoWill land in 1.48, not 1.47
Jon Gjengset [Tue, 1 Sep 2020 13:50:32 +0000 (09:50 -0400)]
Will land in 1.48, not 1.47

3 years agoMerge branch 'master' into stabilize-vecdeque-make_contiguous
Jon Gjengset [Tue, 1 Sep 2020 13:49:42 +0000 (09:49 -0400)]
Merge branch 'master' into stabilize-vecdeque-make_contiguous

3 years agoAuto merge of #75529 - bugadani:bounds-check, r=nagisa
bors [Tue, 1 Sep 2020 13:36:52 +0000 (13:36 +0000)]
Auto merge of #75529 - bugadani:bounds-check, r=nagisa

Eliminate some other bound checks when index comes from an enum

#36962 introduced an assumption for the upper limit of the enum's value. This PR adds an assumption to the lower value as well.

I've modified the original codegen test to show that derived (in that case, adding 1) values also don't generate bounds checks.

However, this test is actually carefully crafted to not hit a bug: if the enum's variants are modified to 1 and 2 instead of 2 and 3, the test fails by adding a bounds check. I suppose this is an LLVM issue and #75525, while not exactly in this context should be tracking it.

I'm not at all confident if this patch can be accepted, or even if it _should_ be accepted in this state. But I'm curious about what others think :)

~Improves~ Should improve #13926 but does not close it because it's not exactly predictable, where bounds checks may pop up against the assumptions.

3 years agoGive a better error message for duplicate built-in macros
Joshua Nelson [Mon, 31 Aug 2020 04:04:01 +0000 (00:04 -0400)]
Give a better error message for duplicate built-in macros

Previously, this would say no such macro existed, but this was
misleading, since the macro _did_ exist, it was just already seen.

- Say where the macro was previously defined
- Add long-form error message

3 years agoAuto merge of #76155 - matklad:rust-analyzer-2020-08-31, r=matklad
bors [Tue, 1 Sep 2020 10:01:04 +0000 (10:01 +0000)]
Auto merge of #76155 - matklad:rust-analyzer-2020-08-31, r=matklad

:arrow_up: rust-analyzer

r? @ghost

3 years agoSimplify TokenTreesReader
Aleksey Kladov [Tue, 1 Sep 2020 09:36:04 +0000 (11:36 +0200)]
Simplify TokenTreesReader

This `joint_to_prev` bit of state is no longer needed.

3 years agoRemove trivia tokens
Aleksey Kladov [Tue, 1 Sep 2020 09:24:52 +0000 (11:24 +0200)]
Remove trivia tokens

3 years agoDon't emit trivia tokens
Aleksey Kladov [Mon, 31 Aug 2020 17:00:49 +0000 (19:00 +0200)]
Don't emit trivia tokens

3 years agoAuto merge of #76071 - khyperia:configurable_to_immediate, r=eddyb
bors [Tue, 1 Sep 2020 07:44:34 +0000 (07:44 +0000)]
Auto merge of #76071 - khyperia:configurable_to_immediate, r=eddyb

Make to_immediate/from_immediate configurable by backends

`librustc_codegen_ssa` has the concept of an immediate vs. memory type, and `librustc_codegen_llvm` uses this distinction to implement `bool`s being `i8` in memory, and `i1` in immediate contexts. However, some of that implementation leaked into `codegen_ssa` when converting to/from immediate values. So, move those methods into builder traits, so that behavior can be configured by backends.

This is useful if a backend is able to keep bools as bools, or, needs to do more trickery than just bools to bytes.

(Note that there's already a large amount of things abstracted with "immediate types" - this is just bringing this particular thing in line to be abstracted as well)

---

Pinging @eddyb since that's who I was talking about this change with when they suggested I submit a PR.

3 years agoAdd new `-Z dump-mir-spanview` option
Rich Kadel [Sat, 29 Aug 2020 17:55:46 +0000 (10:55 -0700)]
Add new `-Z dump-mir-spanview` option

Similar to `-Z dump-mir-graphviz`, this adds the option to write
HTML+CSS files that allow users to analyze the spans associated with MIR
elements (by individual statement, just terminator, or overall basic
block).

This PR was split out from PR #76004, and exposes an API for spanview
HTML+CSS files that is also used to analyze code regions chosen for
coverage instrumentation (in a follow-on PR).

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

3 years agoAuto merge of #76047 - Dylan-DPC:rename/maybe, r=RalfJung
bors [Tue, 1 Sep 2020 05:41:22 +0000 (05:41 +0000)]
Auto merge of #76047 - Dylan-DPC:rename/maybe, r=RalfJung

rename get_{ref, mut} to assume_init_{ref,mut} in Maybeuninit

References #63568

Rework with comments addressed from #66174

Have replaced most of the occurrences I've found, hopefully didn't miss out anything

r? @RalfJung

(thanks @danielhenrymantilla for the initial work on this)