Commit Graph

126477 Commits

Author SHA1 Message Date
Dylan DPC
10aa3d3f89
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`.
2020-09-03 02:22:00 +02:00
Dylan DPC
536b0c0c90
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_
2020-09-03 02:21:58 +02:00
bors
51f79b618d 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
2020-09-02 22:16:22 +00:00
bors
80fc9b0ecb 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
2020-09-02 19:29:27 +00:00
bors
a167485e27 Auto merge of #75960 - camelid:patch-6, r=jyn514
Improve docs for the `const` keyword

@rustbot modify labels: T-doc
2020-09-02 17:35:46 +00:00
bors
95815c9b2b 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.
2020-09-02 15:23:08 +00:00
南浦月
3b29913295 add a note for Ipv4Addr::to_ipv6_compatible 2020-09-02 21:08:09 +08:00
Sasha
3524c3ef43 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.
2020-09-02 13:18:19 +02:00
Ralf Jung
56129d39c0 flt2dec: properly handle uninitialized memory 2020-09-02 12:41:38 +02:00
bors
da897dfb6d 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
2020-09-02 06:46:21 +00:00
bors
b4acb11033 Auto merge of #76170 - matklad:notrivia, r=petrochenkov
Remove trivia tokens

r? @ghost
2020-09-02 03:19:38 +00:00
Camelid
ce904783d0
Improve wording for const pointers 2020-09-01 19:44:20 -07:00
bors
e36e4bd0f7 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
2020-09-02 01:29:28 +00:00
Josh Stone
469ca379d6 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>>`.
2020-09-01 18:27:02 -07:00
Tyler Mandry
4dd75f8049
Rollup merge of #76221 - camelid:cleanup-iter-for, r=jyn514
Clean up header in `iter` docs for `for` loops

@rustbot modify labels: T-doc
2020-09-01 18:24:48 -07:00
Tyler Mandry
56b5de2f29
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.
2020-09-01 18:24:46 -07:00
Tyler Mandry
c22de44a80
Rollup merge of #76212 - JesHansen:fix-lint-doc, r=jyn514
Document lint missing_doc_code_examples is nightly-only

Closes #76194
2020-09-01 18:24:44 -07:00
Tyler Mandry
7edc93b45c
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
2020-09-01 18:24:43 -07:00
Tyler Mandry
11ff32f9ec
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
2020-09-01 18:24:41 -07:00
Tyler Mandry
17fa7339e9
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`]
2020-09-01 18:24:39 -07:00
Tyler Mandry
4a6aa350c7
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.
2020-09-01 18:24:36 -07:00
Tyler Mandry
b01d0b1414
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
2020-09-01 18:24:35 -07:00
Tyler Mandry
738b8eadfd
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.
2020-09-01 18:24:33 -07:00
Tyler Mandry
9a055826f9
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
2020-09-01 18:24:31 -07:00
Tyler Mandry
34c8b7a92c
Rollup merge of #76099 - camelid:patch-8, r=jyn514
Add info about `!` and `impl Trait`

Fixes #76094.

@rustbot modify labels: T-doc C-enhancement
2020-09-01 18:24:29 -07:00
Tyler Mandry
7c1c7de85f
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.
2020-09-01 18:24:27 -07:00
Tyler Mandry
5f28831a40
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
2020-09-01 18:24:25 -07:00
Tyler Mandry
383da5e1e6
Rollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay
Add trailing comma support to matches macro
2020-09-01 18:24:23 -07:00
Camelid
54a4fd1eb9
Minor improvements
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-01 17:38:16 -07:00
Camelid
e5c17bff35 Clean up header in iter docs for for loops 2020-09-01 15:48:39 -07:00
Vadim Petrochenkov
b1491eacfc 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.
2020-09-02 00:40:19 +03:00
marmeladema
99c96c5bfe driver: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
73a7204983 feature: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
67b8f9491c hir: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
1b650d0fea datastructures: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
bd49eec3d7 interface: use OnceCell from standard library 2020-09-01 22:06:39 +01:00
Camelid
c86d249e94 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.
2020-09-01 13:41:56 -07:00
bors
130359cb05 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.
2020-09-01 20:03:55 +00:00
CDirkx
9afe97c932
Add trailing newline to ipv6.rs 2020-09-01 21:36:45 +02:00
CDirkx
a43dd4f401 Change implementation of Ipv6Addr::is_unspecified and is_loopback from matches! to u128 comparison
Done because `matches!` doesn't optimize well with array comparisons
2020-09-01 21:05:26 +02:00
CDirkx
cd08deff3c Add test for Ipv6Addr methods in a const context 2020-09-01 20:59:46 +02:00
Jes Bak Hansen
7eb4b1b4b9 Document lint missing_doc_code_examples is nightly-only 2020-09-01 20:45:21 +02:00
bors
eb9e7c357e Auto merge of #74559 - jonhoo:stabilize-vecdeque-make_contiguous, r=dtolnay
Stabilize deque_make_contiguous

Closes #70929.

/cc @Amanieu
2020-09-01 18:02:37 +00:00
Denis Vasilik
3510c56887 Improve readability 2020-09-01 19:56:32 +02:00
Denis Vasilik
e7d074392e Use intra-doc links 2020-09-01 19:20:15 +02:00
CDirkx
b31cc8f83e 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
2020-09-01 19:00:20 +02:00
Denis Vasilik
b639cb1e46
Enhance wording
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-01 18:16:34 +02:00
bors
58d5ce4929 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
2020-09-01 15:42:29 +00:00
Denis Vasilik
9c7fb6c447 Use intra-doc links 2020-09-01 17:35:56 +02:00
Mark Rousskov
d77c351c89 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.
2020-09-01 10:13:56 -04:00