]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoAdd BinaryHeap::retain as suggested in #42849
arlo [Thu, 23 Apr 2020 19:07:50 +0000 (14:07 -0500)]
Add BinaryHeap::retain as suggested in #42849

4 years agoAuto merge of #71424 - Dylan-DPC:rollup-iunh61a, r=Dylan-DPC
bors [Wed, 22 Apr 2020 11:14:23 +0000 (11:14 +0000)]
Auto merge of #71424 - Dylan-DPC:rollup-iunh61a, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #70970 (Detect mistyped associated consts in `Instance::resolve`.)
 - #71203 (Correct await span for async-await error reporting)
 - #71214 (Add error code for inner doc error)
 - #71337 (Moving all rustdoc-ui tests to check-pass)
 - #71412 (Clarify unused_doc_comments note on macro invocations)
 - #71414 (More diagnostic items for Clippy usage)

Failed merges:

r? @ghost

4 years agoRollup merge of #71414 - phansch:more-diagnostic-items, r=Manishearth
Dylan DPC [Wed, 22 Apr 2020 10:18:39 +0000 (12:18 +0200)]
Rollup merge of #71414 - phansch:more-diagnostic-items, r=Manishearth

More diagnostic items for Clippy usage

This adds a couple of more diagnostic items to be used in Clippy.
I chose these particular ones because they were the types which we seem
to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))`
is needed, but it was also used for `Vec` and a few other types.

cc https://github.com/rust-lang/rust-clippy/issues/5393

r? @Manishearth

4 years agoRollup merge of #71412 - dtolnay:uselessdoc, r=Manishearth
Dylan DPC [Wed, 22 Apr 2020 10:18:38 +0000 (12:18 +0200)]
Rollup merge of #71412 - dtolnay:uselessdoc, r=Manishearth

Clarify unused_doc_comments note on macro invocations

The previous error message used to say:

<pre>
/// doc
^^^^^^^ rustdoc does not generate documentation for <b>macros</b>
</pre>

Obviously we do generate documentation for macros, such as https://docs.rs/bitflags/1.2.1/bitflags/macro.bitflags.html. It's only macro invocations that don't get their own docs. This PR updates the message to say "rustdoc does not generate documentation for <b>macro invocations</b>".

I observe that prior to #69084 this used to say "rustdoc does not generate documentation for **macro expansions**", as implemented originally in #57882. I don't have a preference between those but I made the commit before looking up the history.

r? @Manishearth
attn: @yaahc @euclio

4 years agoRollup merge of #71337 - Valloric:rustdoc-check-pass, r=GuillaumeGomez
Dylan DPC [Wed, 22 Apr 2020 10:18:36 +0000 (12:18 +0200)]
Rollup merge of #71337 - Valloric:rustdoc-check-pass, r=GuillaumeGomez

Moving all rustdoc-ui tests to check-pass

These were all build-pass before and don't seem to need it.

Helps with #62277

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/rust-lang/rust/71337)
<!-- Reviewable:end -->

4 years agoRollup merge of #71214 - GuillaumeGomez:add-error-code-inner-doc-error, r=Dylan-DPC
Dylan DPC [Wed, 22 Apr 2020 10:18:34 +0000 (12:18 +0200)]
Rollup merge of #71214 - GuillaumeGomez:add-error-code-inner-doc-error, r=Dylan-DPC

Add error code for inner doc error

r? @Dylan-DPC

cc @oli-obk

4 years agoRollup merge of #71203 - csmoe:issue-71137, r=csmoe
Dylan DPC [Wed, 22 Apr 2020 10:18:33 +0000 (12:18 +0200)]
Rollup merge of #71203 - csmoe:issue-71137, r=csmoe

Correct await span for async-await error reporting

Closes #71137
r? @tmandry

4 years agoRollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obk
Dylan DPC [Wed, 22 Apr 2020 10:18:31 +0000 (12:18 +0200)]
Rollup merge of #70970 - eddyb:trait-vs-impl-mismatch, r=oli-obk

Detect mistyped associated consts in `Instance::resolve`.

*Based on #71049 to prevent redundant/misleading downstream errors.*

Fixes #70942 by refusing to resolve an associated `const` if it doesn't have the same type in the `impl` that it does in the `trait` (which we assume had errored, and `delay_span_bug` guards against bugs).

4 years agoUpdate UI tests
Guillaume Gomez [Wed, 22 Apr 2020 09:09:57 +0000 (11:09 +0200)]
Update UI tests

4 years agoAdd error code to inner doc comment attribute error
Guillaume Gomez [Wed, 22 Apr 2020 09:08:50 +0000 (11:08 +0200)]
Add error code to inner doc comment attribute error

4 years agoAuto merge of #71323 - nnethercote:bitcode-in-rlib, r=alexcrichton
bors [Wed, 22 Apr 2020 07:52:42 +0000 (07:52 +0000)]
Auto merge of #71323 - nnethercote:bitcode-in-rlib, r=alexcrichton

Add `-Cbitcode-in-rlib`.

This is a cut-down version of #70458 that gets the compile-time wins.

r? @alexcrichton

4 years agoMore diagnostic items for Clippy usage
Philipp Hansch [Wed, 22 Apr 2020 05:47:31 +0000 (07:47 +0200)]
More diagnostic items for Clippy usage

This adds a couple of more diagnostic items to be used in Clippy.
I chose these particular ones because they were the types which we seem
to check for the most in Clippy. I'm not sure if the
`cfg_attr(not(test))` is needed, but it was also used for `Vec` and a
few other types.

4 years agoBuild libstd with `-Cbitcode-in-rlib=yes`.
Nicholas Nethercote [Sun, 19 Apr 2020 11:17:38 +0000 (21:17 +1000)]
Build libstd with `-Cbitcode-in-rlib=yes`.

So that the rlibs will work with both LTO and non-LTO builds.

4 years agoAdd a simple test.
Nicholas Nethercote [Mon, 20 Apr 2020 00:03:35 +0000 (10:03 +1000)]
Add a simple test.

4 years agoAdd a new option `-Cbitcode-in-rlib`.
Nicholas Nethercote [Sun, 19 Apr 2020 10:48:43 +0000 (20:48 +1000)]
Add a new option `-Cbitcode-in-rlib`.

It defaults to true, but Cargo will set this to false whenever it can to
reduce compile times.

4 years agoRemove an old in-progress comment from a previous PR.
Nicholas Nethercote [Sun, 19 Apr 2020 10:49:38 +0000 (20:49 +1000)]
Remove an old in-progress comment from a previous PR.

This comment wasn't supposed to have landed.

4 years agoClarify unused_doc_comments note on macro invocations
David Tolnay [Wed, 22 Apr 2020 04:09:24 +0000 (21:09 -0700)]
Clarify unused_doc_comments note on macro invocations

4 years agoAuto merge of #71410 - JohnTitor:rollup-vh6dut5, r=JohnTitor
bors [Wed, 22 Apr 2020 03:50:02 +0000 (03:50 +0000)]
Auto merge of #71410 - JohnTitor:rollup-vh6dut5, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #70998 (Suggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't return)
 - #71236 (Remove unused rustc_serialize::hex module)
 - #71366 (Use assoc int consts3)
 - #71372 (Fix #! (shebang) stripping account space issue)
 - #71384 (Fix stage0.txt version number comment)
 - #71390 (Fix incorrect description of E0690)
 - #71399 (Clean up E0554 explanation)

Failed merges:

r? @ghost

4 years agoadd test for correct await span
csmoe [Thu, 16 Apr 2020 15:14:11 +0000 (23:14 +0800)]
add test for correct await span

4 years agoRollup merge of #71399 - rust-lang:cleanup-e0554, r=Dylan-DPC
Yuki Okushi [Wed, 22 Apr 2020 01:34:12 +0000 (10:34 +0900)]
Rollup merge of #71399 - rust-lang:cleanup-e0554, r=Dylan-DPC

Clean up E0554 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71390 - aticu:master, r=Dylan-DPC
Yuki Okushi [Wed, 22 Apr 2020 01:34:10 +0000 (10:34 +0900)]
Rollup merge of #71390 - aticu:master, r=Dylan-DPC

Fix incorrect description of E0690

r? @steveklabnik

4 years agoRollup merge of #71384 - RalfJung:RalfJung-patch-1, r=Mark-Simulacrum
Yuki Okushi [Wed, 22 Apr 2020 01:34:09 +0000 (10:34 +0900)]
Rollup merge of #71384 - RalfJung:RalfJung-patch-1, r=Mark-Simulacrum

Fix stage0.txt version number comment

r? @Mark-Simulacrum

4 years agoRollup merge of #71372 - ayushmishra2005:shebang_stripping, r=estebank
Yuki Okushi [Wed, 22 Apr 2020 01:34:07 +0000 (10:34 +0900)]
Rollup merge of #71372 - ayushmishra2005:shebang_stripping, r=estebank

Fix #! (shebang) stripping account space issue

 #70528

4 years agoRollup merge of #71366 - faern:use-assoc-int-consts3, r=dtolnay
Yuki Okushi [Wed, 22 Apr 2020 01:34:06 +0000 (10:34 +0900)]
Rollup merge of #71366 - faern:use-assoc-int-consts3, r=dtolnay

Use assoc int consts3

Define module level int consts with associated constants instead of `min_value()` and `max_value()`. So the code become consistent with what the docs recommend etc. Seems natural.

Also remove the last usages of the int module constants from this repo (except src/test/ directory which I have still not really done anything in). Some places were missed in the previous PRs because the code uses `crate::<IntTy>` to reach the constants.

This is a continuation of #70857

r? @dtolnay

4 years agoRollup merge of #71236 - sinkuu:cleanup, r=nikomatsakis
Yuki Okushi [Wed, 22 Apr 2020 01:34:04 +0000 (10:34 +0900)]
Rollup merge of #71236 - sinkuu:cleanup, r=nikomatsakis

Remove unused rustc_serialize::hex module

* Remove unused `rustc_serialize::hex` module
* Cleanup `Cargo.toml`

4 years agoRollup merge of #70998 - estebank:suggest-impl-trait-empty-fn, r=varkor
Yuki Okushi [Wed, 22 Apr 2020 01:34:03 +0000 (10:34 +0900)]
Rollup merge of #70998 - estebank:suggest-impl-trait-empty-fn, r=varkor

Suggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't return

During development, a function could have a return type set that is a
bare trait object by accident. We already suggest using either a boxed
trait object or `impl Trait` if the return paths will allow it. We now
do so too when there are *no* return paths or they all resolve to `!`.
We still don't handle cases where the trait object is *not* the entirety
of the return type gracefully.

Closes #38376.

4 years agoAuto merge of #71402 - ehuss:update-cargo, r=ehuss
bors [Wed, 22 Apr 2020 00:50:49 +0000 (00:50 +0000)]
Auto merge of #71402 - ehuss:update-cargo, r=ehuss

Update cargo, rls

## cargo

17 commits in ebda5065ee8a1e46801380abcbac21a25bc7e755..8751eb3010d4cdb5329b5a6bd2b6d765c95b0dca
2020-04-16 14:28:43 +0000 to 2020-04-21 18:04:35 +0000
- Uplift windows gnu DLL import libraries. (rust-lang/cargo#8141)
- Add windows-gnu CI and fix tests (rust-lang/cargo#8139)
- Several updates to token/index handling. (rust-lang/cargo#7973)
- Add `resolver` opt-in for new feature resolver. (rust-lang/cargo#8129)
- Improve error message when running `cargo install .` (rust-lang/cargo#8137)
- fix mem replace unused (rust-lang/cargo#8138)
- Change `-Cembed-bitcode=no` use to `-Cbitcode-in-rlib=no`. (rust-lang/cargo#8134)
- Refactor BuildContext (rust-lang/cargo#8068)
- Rename allows_underscores to allows_dashes. (rust-lang/cargo#8135)
- Fixed a needless borrow. (rust-lang/cargo#8130)
- Add link to changelog in the Cargo book. (rust-lang/cargo#8126)
- Fix target for doc test cross compilation (rust-lang/cargo#8094)
- Add note about .cargo/config support. (rust-lang/cargo#8125)
- Fix pdb uplift when executable has dashes. (rust-lang/cargo#8123)
- Hint upgrading for future edition keys (rust-lang/cargo#8122)
- Use some fs shorthand functions. (rust-lang/cargo#8124)
- Update documentation to mention "config.toml" instead of "config" (rust-lang/cargo#8121)

## rls

1 commits in 2659cbf14bfb0929a16d7ce9b6858d0bb286ede7..7de2a1f299f8744ffe109139f9f1fdf28bfec909
2020-04-14 22:07:24 +0200 to 2020-04-19 22:41:55 +0000
- Update cargo (rust-lang-nursery/rls#1663)

4 years agoUpdate cargo, rls
Eric Huss [Tue, 21 Apr 2020 21:11:30 +0000 (14:11 -0700)]
Update cargo, rls

4 years agoClean up E0554 explanation
Guillaume Gomez [Tue, 21 Apr 2020 19:40:29 +0000 (21:40 +0200)]
Clean up E0554 explanation

4 years agoMinor refactoring
Ayush Kumar Mishra [Tue, 21 Apr 2020 16:59:20 +0000 (22:29 +0530)]
Minor refactoring

4 years agoFix incorrect description of E0690
aticu [Tue, 21 Apr 2020 16:13:58 +0000 (18:13 +0200)]
Fix incorrect description of E0690

4 years agoFix stage0.txt version number comment
Ralf Jung [Tue, 21 Apr 2020 13:56:49 +0000 (15:56 +0200)]
Fix stage0.txt version number comment

4 years agoFix formatting issue
Ayush Kumar Mishra [Tue, 21 Apr 2020 11:36:22 +0000 (17:06 +0530)]
Fix formatting issue

4 years agoRefactoring and added test-cases #70528
Ayush Kumar Mishra [Tue, 21 Apr 2020 11:18:58 +0000 (16:48 +0530)]
Refactoring and added test-cases #70528

4 years agoAuto merge of #71170 - spastorino:dyn-fnonce-alignment, r=nikomatsakis
bors [Tue, 21 Apr 2020 08:58:44 +0000 (08:58 +0000)]
Auto merge of #71170 - spastorino:dyn-fnonce-alignment, r=nikomatsakis

Make Box<dyn FnOnce> respect self alignment

Closes #68304

r? @eddyb @nikomatsakis

4 years agoFix #! (shebang) stripping account space issue #70528
Ayush Kumar Mishra [Tue, 21 Apr 2020 06:14:00 +0000 (11:44 +0530)]
Fix #! (shebang) stripping account space issue #70528

4 years agoAuto merge of #71267 - pnkfelix:issue-71248-dont-need-exports-all-green, r=nagisa
bors [Tue, 21 Apr 2020 04:35:17 +0000 (04:35 +0000)]
Auto merge of #71267 - pnkfelix:issue-71248-dont-need-exports-all-green, r=nagisa

attempt to recover perf by removing `exports_all_green`

attempt to recover perf by removing `exports_all_green` flag.

cc #71248

(My hypothesis is that my use of this flag was an overly conservative generalization of PR #67020.)

4 years agoAuto merge of #71367 - Dylan-DPC:rollup-ysj4olr, r=Dylan-DPC
bors [Tue, 21 Apr 2020 01:26:56 +0000 (01:26 +0000)]
Auto merge of #71367 - Dylan-DPC:rollup-ysj4olr, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #69362 (Stabilize most common subset of alloc_layout_extras)
 - #71174 (Check that main/start is not async)
 - #71285 (MIR: use HirId instead of NodeId to avoid cycles while inlining)
 - #71346 (Do not build tools if user do not want them)

Failed merges:

r? @ghost

4 years agoRollup merge of #71346 - mati865:rustbuild-tools, r=Mark-Simulacrum
Dylan DPC [Mon, 20 Apr 2020 22:30:58 +0000 (00:30 +0200)]
Rollup merge of #71346 - mati865:rustbuild-tools, r=Mark-Simulacrum

Do not build tools if user do not want them

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

4 years agoRollup merge of #71285 - ljedrz:mir_inline_span_for_optimized_mir, r=ecstatic-morse
Dylan DPC [Mon, 20 Apr 2020 22:30:57 +0000 (00:30 +0200)]
Rollup merge of #71285 - ljedrz:mir_inline_span_for_optimized_mir, r=ecstatic-morse

MIR: use HirId instead of NodeId to avoid cycles while inlining

I wanted to see if I could limit the number of uses of `NodeId` when `HirId` is available and I saw that some of the MIR `Inliner` code could use `Span` instead of `NodeId`, not unlike in https://github.com/rust-lang/rust/pull/71197.

~If I'm understanding the reason for not calling `optimized_mir` in incremental builds here correctly, this change could also allow us to do so.~

This change could affect performance, so if this approach makes sense, a perf run is probably a good idea.

4 years agoRollup merge of #71174 - Nokel81:fix-async-main-error, r=petrochenkov
Dylan DPC [Mon, 20 Apr 2020 22:30:55 +0000 (00:30 +0200)]
Rollup merge of #71174 - Nokel81:fix-async-main-error, r=petrochenkov

Check that main/start is not async

* Add new error code E0752
* Add span to hir::IsAsync::Yes
* Emit an error if main or the start function is marked as async
* Add two regression tests

This PR fixes #68523.

4 years agoRollup merge of #69362 - CAD97:alloc_layout_extras, r=Amanieu
Dylan DPC [Mon, 20 Apr 2020 22:30:53 +0000 (00:30 +0200)]
Rollup merge of #69362 - CAD97:alloc_layout_extras, r=Amanieu

Stabilize most common subset of alloc_layout_extras

Tracking issue: https://github.com/rust-lang/rust/issues/55724

Specifically, this stabilizes:

```rust
pub fn Layout::align_to(&self, align: usize) -> Result<Layout, LayoutErr>;
pub fn Layout::pad_to_align(&self) -> Layout;
pub fn Layout::extend(&self, next: Layout) -> Result<(Layout, usize), LayoutErr>;
pub fn Layout::array<T>(n: usize) -> Result<Layout, LayoutErr>;
```

Methods that are tracked by #55724 but are not stabilized here:

```rust
pub fn Layout::padding_needed_for(&self, align: usize) -> usize;
pub fn Layout::repeat(&self, n: usize) -> Result<(Layout, usize), LayoutErr>;
pub fn Layout::repeat_packed(&self, n: usize) -> Result<Layout, LayoutErr>;
pub fn Layout::extend_packed(&self, next: Layout) -> Result<Layout, LayoutErr>;
```

Combined, these stabilized functions allow code to construct and manipulate `repr(C)` layouts while letting the standard library handle correctness in the face of edge cases. For example use cases, consider the usage in [hashbrown](https://github.com/Amanieu/hashbrown/blob/2f2af1d/src/raw/mod.rs#L143), [crossbeam-skiplist](https://github.com/crossbeam-rs/crossbeam-skiplist/blob/master/src/base.rs#L99), [pointer-utils/slice-dst](https://github.com/CAD97/pointer-utils/blob/92aeefeed9399f28d1b1654b63f8dcbe1242d8d4/crates/slice-dst/src/layout_polyfill.rs), and of course the standard library itself.

Providing a higher-level API such as `Layout::repr_c<const N: usize>(fields: [Layout; N]) -> Result<(Layout, [usize; N]), LayoutErr>` is blocked on const generics, which are a ways off. Providing an API that doesn't provide offsets would be quite suboptimal, as the reason for calculating the layout like this rather than `Layout::new` is to get the field offsets.

The primary issue with the current API is having to call `.pad_to_align()` to match the layout of a `repr(C)` struct. However, I think this is not just a (failing? limitation?) of the API, but rather intrinsic complexity. While all Rust-defined types have size==stride, and probably will for the foreseeable future, there is no inherent reason why this is a limitation of all allocations. As such, the `Layout` manipulation APIs shouldn't impose this limitation, and instead the higher level api of `repr_c` (or just plain old using `Layout::new`) can make keeping it simple.

cc @matklad r? @rust-lang/libs

4 years agoFix show-const-contents rustdoc test
Linus Färnstrand [Mon, 20 Apr 2020 21:26:57 +0000 (23:26 +0200)]
Fix show-const-contents rustdoc test

4 years agoUse assoc float consts instead of module level
Linus Färnstrand [Thu, 16 Apr 2020 23:38:42 +0000 (01:38 +0200)]
Use assoc float consts instead of module level

4 years agoDefine module level int consts from assoc consts
Linus Färnstrand [Thu, 16 Apr 2020 22:44:19 +0000 (00:44 +0200)]
Define module level int consts from assoc consts

4 years agoStop accessing module level int consts via crate::<Ty>
Linus Färnstrand [Thu, 16 Apr 2020 22:43:04 +0000 (00:43 +0200)]
Stop accessing module level int consts via crate::<Ty>

4 years agoAuto merge of #71356 - Dylan-DPC:rollup-liockhk, r=Dylan-DPC
bors [Mon, 20 Apr 2020 19:11:28 +0000 (19:11 +0000)]
Auto merge of #71356 - Dylan-DPC:rollup-liockhk, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71250 (Replace big JS dict with JSON parsing)
 - #71270 (Fix `has_no_input_arg` check and rename it to `has_only_self_parameter`)
 - #71284 (fix -Zast-json to output correct JSON form)
 - #71328 (Stabilize PathBuf capacity methods)
 - #71334 (Update pattern docs.)

Failed merges:

r? @ghost

4 years agoDo not build tools if user do not want them
Mateusz Mikuła [Mon, 20 Apr 2020 10:39:12 +0000 (12:39 +0200)]
Do not build tools if user do not want them

4 years agoEnsure tail expression will have a `Ty` for E0746
Esteban Küber [Sat, 11 Apr 2020 18:31:54 +0000 (11:31 -0700)]
Ensure tail expression will have a `Ty` for E0746

When the return type is `!Sized` we look for all the returned
expressions in the body to fetch their types and provide a reasonable
suggestion. The tail expression of the body is normally evaluated after
checking whether the return type is `Sized`. Changing the order of the
evaluation produces undesirable knock down effects, so we detect the
specific case that newcomers are likely to encounter ,returning a single
bare trait object, and only in that case we evaluate the tail
expression's type so that the suggestion will be accurate.

4 years agoImprove Layout::extend docs
CAD97 [Mon, 20 Apr 2020 16:30:35 +0000 (12:30 -0400)]
Improve Layout::extend docs

4 years agoUpdate src/libcore/alloc/layout.rs
Christopher Durham [Mon, 20 Apr 2020 16:28:30 +0000 (12:28 -0400)]
Update src/libcore/alloc/layout.rs

Co-Authored-By: Amanieu d'Antras <amanieu@gmail.com>
4 years agoSuggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't return
Esteban Küber [Fri, 10 Apr 2020 17:19:47 +0000 (10:19 -0700)]
Suggest `-> impl Trait` and `-> Box<dyn Trait>` on fn that doesn't return

During development, a function could have a return type set that is a
bare trait object by accident. We already suggest using either a boxed
trait object or `impl Trait` if the return paths will allow it. We now
do so too when there are *no* return paths or they all resolve to `!`.
We still don't handle cases where the trait object is *not* the entirety
of the return type gracefully.

4 years agoRollup merge of #71334 - ehuss:pattern-docs, r=kennytm
Dylan DPC [Mon, 20 Apr 2020 16:07:12 +0000 (18:07 +0200)]
Rollup merge of #71334 - ehuss:pattern-docs, r=kennytm

Update pattern docs.

A few changes to help clarify string pattern usage:

* Add some examples and stability information in the `pattern` module.
* Fixes the links at https://doc.rust-lang.org/std/str/pattern/ because intra-doc-links don't work with re-exported modules (#65983 I think?).
* Consistently use the same phrasing for `str` methods taking a pattern.
    * Also mention that array of `char` is also accepted.

When `Pattern` is stabilized, the phrasing in the `str` methods can be updated to be more general to reflect the exact behavior. I'm reluctant to do this now because the stability story for `Pattern` is uncertain. It may perhaps look something like:

> The pattern can be any type that implements the [`Pattern`] trait. Notable examples are `&str`, [`char`], arrays of [`char`], or functions or closures that determines if a character matches. Additional libraries might provide more complex patterns like regular expressions.

This is complicated because methods like `trim_matches` have bounds, which for example don't support `str`, so those methods may need more elaboration.

4 years agoRollup merge of #71328 - Mark-Simulacrum:stabilize-pathbuf-capacity, r=sfackler
Dylan DPC [Mon, 20 Apr 2020 16:07:11 +0000 (18:07 +0200)]
Rollup merge of #71328 - Mark-Simulacrum:stabilize-pathbuf-capacity, r=sfackler

Stabilize PathBuf capacity methods

Closes https://github.com/rust-lang/rust/issues/58234.

Stabilization FCP finished in https://github.com/rust-lang/rust/issues/58234#issuecomment-616048777.

4 years agoRollup merge of #71284 - JOE1994:serialize_id, r=petrochenkov
Dylan DPC [Mon, 20 Apr 2020 16:07:09 +0000 (18:07 +0200)]
Rollup merge of #71284 - JOE1994:serialize_id, r=petrochenkov

fix -Zast-json to output correct JSON form

fixes #71086 (Reverts some of the changes made in #70215)

JSON output (from an empty library) after fix has something for **"id"** field
```shell
lonelyjoe@lonelyjoe-desktop:~/workspace/empty_lib/src$ rustc lib.rs -Zast-json
```
```json
{
   "module":{
      "inner":{
         "lo":0,
         "hi":94
      },
      "items":[
         {
            "attrs":[
               {
                  "kind":{
                     "variant":"Normal",
                     "fields":[
                        {
                           "path":{
                              "span":{
                                 "lo":0,
                                 "hi":0
                              },
                              "segments":[
                                 {
                                    "ident":{
                                       "name":"prelude_import",
                                       "span":{
                                          "lo":0,
                                          "hi":0
                                       }
                                    },
                                    "id":3,
                                    "args":null
                                 }
                              ]
                           },
                           "args":"Empty"
                        }
                     ]
                  },
                  "id":null,
                  "style":"Outer",
                  "span":{
                     "lo":0,
                     "hi":0
                  }
               }
            ],
            "id":4,
            "span":{
               "lo":0,
               "hi":0
            },
            "vis":{
               "node":"Inherited",
               "span":{
                  "lo":0,
                  "hi":0
               }
            },
            "ident":{
               "name":"",
               "span":{
                  "lo":0,
                  "hi":0
               }
            },
            "kind":{
               "variant":"Use",
               "fields":[
                  {
                     "prefix":{
                        "span":{
                           "lo":0,
                           "hi":0
                        },
                        "segments":[
                           {
                              "ident":{
                                 "name":"{{root}}",
                                 "span":{
                                    "lo":0,
                                    "hi":0
                                 }
                              },
                              "id":5,
                              "args":null
                           },
                           {
                              "ident":{
                                 "name":"std",
                                 "span":{
                                    "lo":0,
                                    "hi":0
                                 }
                              },
                              "id":6,
                              "args":null
                           },
                           {
                              "ident":{
                                 "name":"prelude",
                                 "span":{
                                    "lo":0,
                                    "hi":0
                                 }
                              },
                              "id":7,
                              "args":null
                           },
                           {
                              "ident":{
                                 "name":"v1",
                                 "span":{
                                    "lo":0,
                                    "hi":0
                                 }
                              },
                              "id":8,
                              "args":null
                           }
                        ]
                     },
                     "kind":"Glob",
                     "span":{
                        "lo":0,
                        "hi":0
                     }
                  }
               ]
            },
            "tokens":null
         },
         {
            "attrs":[
               {
                  "kind":{
                     "variant":"Normal",
                     "fields":[
                        {
                           "path":{
                              "span":{
                                 "lo":0,
                                 "hi":0
                              },
                              "segments":[
                                 {
                                    "ident":{
                                       "name":"macro_use",
                                       "span":{
                                          "lo":0,
                                          "hi":0
                                       }
                                    },
                                    "id":9,
                                    "args":null
                                 }
                              ]
                           },
                           "args":"Empty"
                        }
                     ]
                  },
                  "id":null,
                  "style":"Outer",
                  "span":{
                     "lo":0,
                     "hi":0
                  }
               }
            ],
            "id":10,
            "span":{
               "lo":0,
               "hi":0
            },
            "vis":{
               "node":"Inherited",
               "span":{
                  "lo":0,
                  "hi":0
               }
            },
            "ident":{
               "name":"std",
               "span":{
                  "lo":0,
                  "hi":0
               }
            },
            "kind":{
               "variant":"ExternCrate",
               "fields":[
                  null
               ]
            },
            "tokens":null
         }
      ],
      "inline":true
   },
   "attrs":[

   ],
   "span":{
      "lo":0,
      "hi":94
   },
   "proc_macros":[

   ]
}
```

4 years agoRollup merge of #71270 - Rustin-Liu:rustin-patch-has-self, r=estebank
Dylan DPC [Mon, 20 Apr 2020 16:07:07 +0000 (18:07 +0200)]
Rollup merge of #71270 - Rustin-Liu:rustin-patch-has-self, r=estebank

Fix `has_no_input_arg` check and rename it to `has_only_self_parameter`

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
Fixes https://github.com/rust-lang/rust/pull/70643#discussion_r401571789.

4 years agoRollup merge of #71250 - GuillaumeGomez:use-json-instead-of-js, r=kinnison
Dylan DPC [Mon, 20 Apr 2020 16:07:05 +0000 (18:07 +0200)]
Rollup merge of #71250 - GuillaumeGomez:use-json-instead-of-js, r=kinnison

Replace big JS dict with JSON parsing

Part of #56545.

@ollie27 suggested that using JSON instead of a JS dict might be faster, so I decided to test it. And the results far exceeded whatever expectations I had...

I used https://github.com/adamgreig/stm32ral for my tests. If you want to build it locally:

```bash
$ cargo doc --features doc --open
```

But I strongly recommend to do it with this PR. Some numbers:

 * Loading a page with the JSON search-index: less than 1 second
 * Loading a page with the JS search-index: crashed after 30 seconds

I think the results are clear enough...

r? @ollie27

cc @rust-lang/rustdoc

4 years agoExpand comment to justify not checking if all the exports are green.
Felix S. Klock II [Mon, 20 Apr 2020 14:33:27 +0000 (10:33 -0400)]
Expand comment to justify not checking if all the exports are green.

4 years agoCheck that main/start is not async
Sebastian Malton [Wed, 8 Apr 2020 19:39:02 +0000 (15:39 -0400)]
Check that main/start is not async

* Add new error code E0752
* Add span to hir::IsAsync::Yes
* Emit an error if main or the start function is marked as async
* Add two regression tests

Fix formatting errors and bless test outputs
* move tests to ui/async-await

fix test error text

remove span from IsAsync

4 years agoAuto merge of #70729 - nnethercote:a-big-options-clean-up, r=petrochenkov
bors [Mon, 20 Apr 2020 12:30:45 +0000 (12:30 +0000)]
Auto merge of #70729 - nnethercote:a-big-options-clean-up, r=petrochenkov

A big options clean-up

Lots of improvements here.

r? @Centril

4 years agotweak comments
Niko Matsakis [Mon, 20 Apr 2020 09:41:54 +0000 (09:41 +0000)]
tweak comments

4 years agoRemove unused ToHex/FromHex trait
Shotaro Yamada [Fri, 17 Apr 2020 04:24:24 +0000 (13:24 +0900)]
Remove unused ToHex/FromHex trait

4 years agoRemove unused dependencies
Shotaro Yamada [Fri, 17 Apr 2020 04:23:39 +0000 (13:23 +0900)]
Remove unused dependencies

4 years agoAuto merge of #71232 - eddyb:print-const-adts, r=oli-obk
bors [Mon, 20 Apr 2020 05:30:12 +0000 (05:30 +0000)]
Auto merge of #71232 - eddyb:print-const-adts, r=oli-obk

ty/print: pretty-print constant aggregates (arrays, tuples and ADTs).

Oddly enough, we don't have any UI tests showing this off in types, only `mir-opt` tests.
However, the pretty form should show up in the test output diff of #71018, if this PR is merged first.

<hr/>

Examples of before/after:
|`Option<bool>`|
|:-:|
|`{transmute(0x01): std::option::Option<bool>}`|
| :sparkles: ↓↓↓ :sparkles: |
|`std::option::Option::<bool>::Some(true)`|

| `RawVec<u32>` |
|:-:|
| `ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>`|
| :sparkles: ↓↓↓ :sparkles: |
|`alloc::raw_vec::RawVec::<u32> { ptr: std::ptr::Unique::<u32> { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData::<u32> }, cap: 0usize, alloc: std::alloc::Global }`|

<hr/>

This PR is a prerequisite for #61486, *sort of*, in that we need to be able to pretty-print values in order to even consider how we might mangle them.
We still don't have pretty-printing for constants of reference types, @oli-obk has the necessary support logic in a PR but I didn't want to interfere with that.

<hr/>

Each commit should be reviewed separately, as I've fixed a couple deficiencies along the way.

r? @oli-obk cc @rust-lang/wg-mir-opt @varkor @yodaldevoid

4 years agocheck '-Zast-json' & '-Zast-json-noexpand' to output legal JSON
JOE1994 [Mon, 20 Apr 2020 02:24:42 +0000 (22:24 -0400)]
check '-Zast-json' & '-Zast-json-noexpand' to output legal JSON

4 years agoAuto merge of #71007 - Amanieu:deprecate_asm, r=Mark-Simulacrum
bors [Mon, 20 Apr 2020 02:18:00 +0000 (02:18 +0000)]
Auto merge of #71007 - Amanieu:deprecate_asm, r=Mark-Simulacrum

Deprecate the asm! macro in favor of llvm_asm!

Since we will be changing the syntax of `asm!` soon, deprecate it and encourage people to use `llvm_asm!` instead (which preserves the old syntax). This will avoid breakage when `asm!` is changed.

RFC: https://github.com/rust-lang/rfcs/pull/2843

4 years agoStabilize PathBuf capacity methods
Mark Rousskov [Sun, 19 Apr 2020 15:59:19 +0000 (11:59 -0400)]
Stabilize PathBuf capacity methods

4 years agoUpdate pattern docs.
Eric Huss [Sun, 19 Apr 2020 21:17:32 +0000 (14:17 -0700)]
Update pattern docs.

4 years agoMoving all rustdoc-ui tests to check-pass
Val Markovic [Sun, 19 Apr 2020 23:40:53 +0000 (16:40 -0700)]
Moving all rustdoc-ui tests to check-pass

These were all build-pass before and don't seem to need it.

Helps with #62277

4 years agoAuto merge of #70598 - vakaras:add-threads-cr3, r=oli-obk,RalfJung
bors [Sun, 19 Apr 2020 23:02:06 +0000 (23:02 +0000)]
Auto merge of #70598 - vakaras:add-threads-cr3, r=oli-obk,RalfJung

Make the necessary changes to support concurrency in Miri.

This pull request makes the necessary changes to the Rust compiler to allow Miri to support concurrency:

1.  Move stack from the interpretation context (`InterpCx`) to machine, so that the machine can switch the stacks when it changes the thread being executed.
2.  Add the callbacks that allow the machine to generate fresh allocation ids for each thread local allocation and to translate them back to original allocations when needed. This allows the machine to ensure the property that allocation ids are unique, which allows using a simpler representation of the memory.

r? @oli-obk

cc @RalfJung

4 years agoAuto merge of #71331 - Dylan-DPC:rollup-5rn1isc, r=Dylan-DPC
bors [Sun, 19 Apr 2020 19:53:42 +0000 (19:53 +0000)]
Auto merge of #71331 - Dylan-DPC:rollup-5rn1isc, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #71026 (Fix false "never constructed" warnings for `Self::` variant paths)
 - #71310 (Do not show DefId in diagnostics)
 - #71317 (miri-unleash test for llvm_asm)
 - #71324 (Fix some tests failing in `--pass check` mode)

Failed merges:

r? @ghost

4 years agoMIR: use span instead of NodeId to determine if optimized_mir should be run
ljedrz [Sat, 18 Apr 2020 13:26:45 +0000 (15:26 +0200)]
MIR: use span instead of NodeId to determine if optimized_mir should be run

4 years agoRollup merge of #71324 - petrochenkov:passcheck2, r=RalfJung
Dylan DPC [Sun, 19 Apr 2020 19:11:29 +0000 (21:11 +0200)]
Rollup merge of #71324 - petrochenkov:passcheck2, r=RalfJung

Fix some tests failing in `--pass check` mode

r? @RalfJung

4 years agoRollup merge of #71317 - RalfJung:unleash-inline-asm, r=ecstatic-morse
Dylan DPC [Sun, 19 Apr 2020 19:11:28 +0000 (21:11 +0200)]
Rollup merge of #71317 - RalfJung:unleash-inline-asm, r=ecstatic-morse

miri-unleash test for llvm_asm

r? @oli-obk @ecstatic-morse

4 years agoRollup merge of #71310 - JohnTitor:dont-did, r=estebank
Dylan DPC [Sun, 19 Apr 2020 19:11:24 +0000 (21:11 +0200)]
Rollup merge of #71310 - JohnTitor:dont-did, r=estebank

Do not show DefId in diagnostics

Fixes #71222
r? @estebank cc @eddyb

4 years agoRollup merge of #71026 - seiyab:issue-64362-adhoc, r=varkor
Dylan DPC [Sun, 19 Apr 2020 19:11:22 +0000 (21:11 +0200)]
Rollup merge of #71026 - seiyab:issue-64362-adhoc, r=varkor

Fix false "never constructed" warnings for `Self::` variant paths

Closes #64362 .

4 years agoFix comment
Ralf Jung [Sun, 19 Apr 2020 18:21:26 +0000 (20:21 +0200)]
Fix comment

4 years agoAuto merge of #71231 - cuviper:rustc_or_patterns, r=Mark-Simulacrum
bors [Sun, 19 Apr 2020 16:43:02 +0000 (16:43 +0000)]
Auto merge of #71231 - cuviper:rustc_or_patterns, r=Mark-Simulacrum

Dogfood more or_patterns in the compiler

Another step toward the stabilization of `or_patterns`...

cc #54883 @Centril
r? @Mark-Simulacrum

4 years agofix decode logic for 'AttrId' to be symmetric with encode logic
JOE1994 [Sun, 19 Apr 2020 16:00:45 +0000 (12:00 -0400)]
fix decode logic for 'AttrId' to be symmetric with encode logic

4 years agoDogfood more or_patterns in the compiler
Josh Stone [Fri, 17 Apr 2020 00:38:52 +0000 (17:38 -0700)]
Dogfood more or_patterns in the compiler

4 years agoFix some tests failing in `--pass check` mode
Vadim Petrochenkov [Sun, 19 Apr 2020 13:06:00 +0000 (16:06 +0300)]
Fix some tests failing in `--pass check` mode

4 years agoAuto merge of #71326 - Dylan-DPC:rollup-hdlkdj5, r=Dylan-DPC
bors [Sun, 19 Apr 2020 13:24:05 +0000 (13:24 +0000)]
Auto merge of #71326 - Dylan-DPC:rollup-hdlkdj5, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #71107 (Address concerns of weak-into-raw)
 - #71188 (Fixed missing trait method suggests incorrect code (self parameter not named "self"). )
 - #71300 (Clarify when to use the tracking issue template)
 - #71315 (Add example in the alternative in std::mem::transmute docs)
 - #71319 (Clean up E0522 explanation)

Failed merges:

r? @ghost

4 years agoRollup merge of #71319 - GuillaumeGomez:cleanup-e0522, r=Dylan-DPC
Dylan DPC [Sun, 19 Apr 2020 13:12:42 +0000 (15:12 +0200)]
Rollup merge of #71319 - GuillaumeGomez:cleanup-e0522, r=Dylan-DPC

Clean up E0522 explanation

r? @Dylan-DPC

4 years agoRollup merge of #71315 - huangjiahua:update-documentation, r=Dylan-DPC
Dylan DPC [Sun, 19 Apr 2020 13:12:40 +0000 (15:12 +0200)]
Rollup merge of #71315 - huangjiahua:update-documentation, r=Dylan-DPC

Add example in the alternative in std::mem::transmute docs

It is safer to use `from_ne_bytes` to convert raw bytes to type like u32.  #71187

4 years agoRollup merge of #71300 - rust-lang:jonas-schievink-patch-1, r=XAMPPRocky
Dylan DPC [Sun, 19 Apr 2020 13:12:39 +0000 (15:12 +0200)]
Rollup merge of #71300 - rust-lang:jonas-schievink-patch-1, r=XAMPPRocky

Clarify when to use the tracking issue template

People tend to open this for feature requests. Let's see if this helps.

r? @XAMPPRocky

4 years agoRollup merge of #71188 - Duddino:fix, r=matthewjasper
Dylan DPC [Sun, 19 Apr 2020 13:12:38 +0000 (15:12 +0200)]
Rollup merge of #71188 - Duddino:fix, r=matthewjasper

Fixed missing trait method suggests incorrect code (self parameter not named "self").

fixes #71150

4 years agoRollup merge of #71107 - vorner:weak-into-raw-dangling, r=Amanieu
Dylan DPC [Sun, 19 Apr 2020 13:12:36 +0000 (15:12 +0200)]
Rollup merge of #71107 - vorner:weak-into-raw-dangling, r=Amanieu

Address concerns of weak-into-raw

This should address the standing concerns in https://github.com/rust-lang/rust/issues/60728#issuecomment-612525616.

I've still left the ability to create a new dangling pointer from `null`, as I feel like this is the natural behaviour to expect, but I'm fine removing that too. I've modified the documentation to allow the `as_ptr` or `into_ptr` to return whatever garbage in case of a dangling pointer. I've also removed the guarantee to be able to do `from_raw(as_ptr)` from the documentation (but it would still work right now).

I've renamed the method and added implementations for `Rc`/`Arc`.

I've also tried if I can just „enable“ unsized types. I believe the current interface is compatible with them. But the inner implementation will be a bit challenging ‒ I can't use the `data_offset` as is used by `Rc` or `Arc` because it AFAIK „touches“ (creates a reference to) the live value of `T` ‒ and in case of `Weak`, it might be completely bogus or already dead ‒ so that would be UB.

`./x.py test tidy` is completely mad on my own system all over the code base :-(. I'll just hope it goes through CI, or will fix as necessary.

Is it OK if I ask @Amanieu for review, as the concerns are from you?

~r @Amanieu

4 years agoFix false "never constructed" warnings for `Self::` variant paths
seiya [Sat, 11 Apr 2020 13:34:45 +0000 (22:34 +0900)]
Fix false "never constructed" warnings for `Self::` variant paths

4 years agotest for false "never constructed" warnings for `Self::` variant paths
jakubadamw [Sat, 11 Apr 2020 13:14:33 +0000 (22:14 +0900)]
test for false "never constructed" warnings for `Self::` variant paths

4 years agoClean up E0522 explanation
Guillaume Gomez [Sun, 19 Apr 2020 11:18:45 +0000 (13:18 +0200)]
Clean up E0522 explanation

4 years agomiri-unleash test for llvm_asm
Ralf Jung [Sun, 19 Apr 2020 10:05:28 +0000 (12:05 +0200)]
miri-unleash test for llvm_asm

4 years agoDisallow values for `-C no-*` and `-Z no-*` options again.
Nicholas Nethercote [Sun, 5 Apr 2020 23:29:19 +0000 (09:29 +1000)]
Disallow values for `-C no-*` and `-Z no-*` options again.

With the exception of `-C no-redzone`, because that could take a value
before this PR.

This partially undoes one of the earlier commits in this PR, which added
the ability to take a value to all boolean options that lacked it.

The help output for these options looks like this:
```
    -C         no-vectorize-slp=val -- disable LLVM's SLP vectorization pass
```
The "=val" part is a lie, but hopefully this will be fixed in the future.

4 years agoImprove codegen option docs.
Nicholas Nethercote [Fri, 3 Apr 2020 03:53:03 +0000 (14:53 +1100)]
Improve codegen option docs.

This commit:
- Adds "following values" indicators for all the options that are
  missing them.
- Tweaks some wording and punctuation for consistency.
- Rewords some things for clarity.
- Removes the `no-integrated-as` entry, because that option was removed
  in #70345.

4 years agoShow defaults in options descriptions.
Nicholas Nethercote [Thu, 2 Apr 2020 23:42:29 +0000 (10:42 +1100)]
Show defaults in options descriptions.

For all `-C` and `-Z` options that have them.

The commit also rewords a few options to make them clearer, mostly by
avoiding the word "don't".

It also removes the listed default for `-Cinline-threshold`, which is
incorrect -- that option doesn't have a static default.

4 years agoAuto merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper
bors [Sun, 19 Apr 2020 10:01:16 +0000 (10:01 +0000)]
Auto merge of #70015 - jonas-schievink:gen-needs-drop, r=matthewjasper

Make `needs_drop` less pessimistic on generators

Generators only have non-trivial drop logic when they may store (in upvars or across yields) a type that does.

This prevents generation of some unnecessary MIR in simple generators. There might be some impact on compile times, but this is probably limited in real-world applications.

~~This builds off of https://github.com/rust-lang/rust/pull/69814 since that contains some fixes that are made relevant by *this* PR (see https://github.com/rust-lang/rust/pull/69814#issuecomment-599147269).~~ (this has been merged)

4 years agoReplace uses of `parse_opt_*` with `parse_*` where possible.
Nicholas Nethercote [Thu, 2 Apr 2020 05:44:47 +0000 (16:44 +1100)]
Replace uses of `parse_opt_*` with `parse_*` where possible.

This lets us specify the default at the options declaration point,
instead of using `.unwrap(default)` or `None | Some(default)` at some
use point far away. It also makes the code more concise.

4 years agoMake option type descriptions non-optional.
Nicholas Nethercote [Fri, 3 Apr 2020 03:15:10 +0000 (14:15 +1100)]
Make option type descriptions non-optional.

Because all options now can take a value. This simplifies some code
quite a bit.

4 years agoTweak `parse_opt_uint`.
Nicholas Nethercote [Fri, 3 Apr 2020 03:02:44 +0000 (14:02 +1100)]
Tweak `parse_opt_uint`.

Don't set `slot` on failure, like all the other `parse_*` functions.

4 years agoFix the `-Zsanitizer_memory_track_origins` error message.
Nicholas Nethercote [Thu, 2 Apr 2020 04:58:07 +0000 (15:58 +1100)]
Fix the `-Zsanitizer_memory_track_origins` error message.

Currently, if you give a bogus value like
`-Zsanitizer-memory-track-origins=99` you get this incorrect error:
```
error: debugging option `sanitizer-memory-track-origins` takes no value
```
This commit fixes it so it gives this instead:
```
error: incorrect value `99` for debugging option `sanitizer-memory-track-origins` - 0, 1, or 2 was expected
```
The commit also makes `parse_sanitizer_memory_track_origins` more
readable.

4 years agoClean up the list of parser descriptions.
Nicholas Nethercote [Thu, 2 Apr 2020 05:06:08 +0000 (16:06 +1100)]
Clean up the list of parser descriptions.

Put identical ones next to each other, and avoid duplicated strings.