]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoremove example that relied on non-public trait
The8472 [Sun, 17 Nov 2019 00:32:36 +0000 (01:32 +0100)]
remove example that relied on non-public trait

3 years agorecover vectorization
The8472 [Sat, 16 Nov 2019 21:31:23 +0000 (22:31 +0100)]
recover vectorization

switch to try_fold and segregate the drop handling to keep
collect::<Vec<u8>>() and similar optimizer-friendly

It comes at the cost of less accurate debug_asserts and code complexity

3 years agoupdate benches
The8472 [Sat, 16 Nov 2019 16:27:39 +0000 (17:27 +0100)]
update benches

3 years agosimplify pointer arithmetic
The8472 [Fri, 15 Nov 2019 20:02:54 +0000 (21:02 +0100)]
simplify pointer arithmetic

3 years agofix doc link
The8472 [Fri, 15 Nov 2019 20:01:13 +0000 (21:01 +0100)]
fix doc link

3 years agouse add instead of offset
The8472 [Fri, 15 Nov 2019 02:54:44 +0000 (03:54 +0100)]
use add instead of offset

3 years agoimplement drop handling
The8472 [Fri, 15 Nov 2019 01:37:55 +0000 (02:37 +0100)]
implement drop handling

3 years agoassert that SourceIter requirements have not been violated by the pipeline
The8472 [Fri, 15 Nov 2019 00:27:41 +0000 (01:27 +0100)]
assert that SourceIter requirements have not been violated by the pipeline

3 years agomark SourceIter as unsafe, document invariants
The8472 [Fri, 15 Nov 2019 00:18:30 +0000 (01:18 +0100)]
mark SourceIter as unsafe, document invariants

3 years agoin-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters
The8472 [Fri, 11 Oct 2019 18:43:25 +0000 (20:43 +0200)]
in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters

3 years agobench
The8472 [Fri, 18 Oct 2019 22:00:45 +0000 (00:00 +0200)]
bench

3 years agounrelated typo fix
The8472 [Fri, 11 Oct 2019 18:42:32 +0000 (20:42 +0200)]
unrelated typo fix

3 years agoRespect `-Z proc-macro-backtrace` flag for panics inside libproc_macro
Aaron Hill [Thu, 3 Sep 2020 16:11:18 +0000 (12:11 -0400)]
Respect `-Z proc-macro-backtrace` flag for panics inside libproc_macro

Fixes #76270

Previously, any panic occuring during a call to a libproc_macro method
(e.g. calling `Ident::new` with an invalid identifier) would always
cause an ICE message to be printed.

3 years agoAuto merge of #76283 - RalfJung:miri, r=RalfJung
bors [Thu, 3 Sep 2020 16:00:55 +0000 (16:00 +0000)]
Auto merge of #76283 - RalfJung:miri, r=RalfJung

update miri

Fixes https://github.com/rust-lang/rust/issues/76190
Cc @rust-lang/miri r? @ghost

3 years agoLink & primitive using relative link
Ivan Tham [Thu, 3 Sep 2020 15:02:27 +0000 (23:02 +0800)]
Link & primitive using relative link

3 years agodisplay_for -> suggestion_for
Joshua Nelson [Sat, 29 Aug 2020 19:13:28 +0000 (15:13 -0400)]
display_for -> suggestion_for

3 years agoRemove disambiguators from link text
Joshua Nelson [Mon, 6 Jul 2020 03:38:31 +0000 (23:38 -0400)]
Remove disambiguators from link text

Related to https://github.com/rust-lang/rust/issues/65354

- Pass through the replacement text to `markdown.rs`
- Add some tests
- Add a state machine that actually replaces the text when parsing Markdown

3 years agoRefactor RenderedLink into its own type
Joshua Nelson [Mon, 6 Jul 2020 03:05:18 +0000 (23:05 -0400)]
Refactor RenderedLink into its own type

3 years agoRefactor `ItemLink` into its own struct
Joshua Nelson [Mon, 6 Jul 2020 02:45:44 +0000 (22:45 -0400)]
Refactor `ItemLink` into its own struct

3 years agoRemove needless .to_owned() for link
Joshua Nelson [Mon, 6 Jul 2020 02:10:18 +0000 (22:10 -0400)]
Remove needless .to_owned() for link

3 years agoMove jointness censoring to proc_macro
Aleksey Kladov [Thu, 3 Sep 2020 13:22:07 +0000 (15:22 +0200)]
Move jointness censoring to proc_macro

Proc-macro API currently exposes jointness in `Punct` tokens. That is,
`+` in `+one` is **non** joint.

Our lexer produces jointness info for all tokens, so we need to censor
it *somewhere*

Previously we did this in a lexer, but it makes more sense to do this
in a proc-macro server.

3 years agorustc_lint: avoid trimmed paths for ty_find_init_error
Dan Aloni [Thu, 3 Sep 2020 11:33:55 +0000 (14:33 +0300)]
rustc_lint: avoid trimmed paths for ty_find_init_error

3 years agospecialization_graph: avoid trimmed paths for OverlapError
Dan Aloni [Thu, 3 Sep 2020 10:42:24 +0000 (13:42 +0300)]
specialization_graph: avoid trimmed paths for OverlapError

3 years agoupdate miri
Ralf Jung [Thu, 3 Sep 2020 10:41:27 +0000 (12:41 +0200)]
update miri

3 years agoTools, tests, and experimenting with MIR-derived coverage counters
Rich Kadel [Thu, 27 Aug 2020 21:13:04 +0000 (14:13 -0700)]
Tools, tests, and experimenting with MIR-derived coverage counters

Adds a new mir_dump output file in HTML/CSS to visualize code regions
and the MIR features that they came from (including overlapping spans).
See example below:

Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.

The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.

Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.

This PR replaces the bulk of PR #75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.

This PR depends on three of those other PRs: #76000, #76002, and

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

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

![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)

3 years agorustc_driver: have TrimmedDefPaths::GoodPath only for rustc
Dan Aloni [Thu, 3 Sep 2020 06:30:51 +0000 (09:30 +0300)]
rustc_driver: have TrimmedDefPaths::GoodPath only for rustc

`run_compiler` is used by clippy and other tools, which should not have
the trimmed paths feature enabled by default, until we see it works well
for them.

Would also be nice to rename `TimePassesCallbacks` however it's a
submodule change.

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 agoAvoid spurious print outs during dryrun
Mark Rousskov [Wed, 2 Sep 2020 20:00:47 +0000 (16:00 -0400)]
Avoid spurious print outs during dryrun

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 agopretty: trim paths of unique symbols
Dan Aloni [Wed, 2 Sep 2020 07:40:56 +0000 (10:40 +0300)]
pretty: trim paths of unique symbols

If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.

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 agoFold length constant in Rvalue::Repeat
Tomasz Miąsko [Wed, 2 Sep 2020 00:00:00 +0000 (00:00 +0000)]
Fold length constant in Rvalue::Repeat

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 agorustc_{errors,session}: add `delay_good_path_bug`
Dan Aloni [Sat, 22 Aug 2020 19:24:48 +0000 (22:24 +0300)]
rustc_{errors,session}: add `delay_good_path_bug`

The first use case of this detection of regression for trimmed paths
computation, that is in the case of rustc, which should be computed only
in case of errors or warnings.

Our current user of this method is deeply nested, being a side effect
from `Display` formatting on lots of rustc types. So taking only the
caller to the error message is not enough - we should collect the
traceback instead.

3 years agoFix some unwanted uses of Debug formatting on user-facing messages
Dan Aloni [Fri, 28 Aug 2020 10:38:43 +0000 (13:38 +0300)]
Fix some unwanted uses of Debug formatting on user-facing messages

While formatting for user diagnostics used `Display` for all most cases,
some small amount of cases used `Debug` instead.  Until now, `Display`
and `Debug` yielded the same output for many types. However, with path
trimming, we want to show a shorter path for the user, these cases need
fixing.

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