Commit graph

150324 commits

Author SHA1 Message Date
Yuki Okushi
4463b08652
Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc
Add `io::Cursor::{remaining, remaining_slice, is_empty}`

Tracking issue: #86369

I came across an inconvenience when answering the following [Stack Overflow](https://stackoverflow.com/questions/67831170) question.
To get the remaining slice you have to call `buff.fill_buf().unwrap()`. Which in my opinion doesn't really tell you what is returned (in the context of Cursor). To improve readability and convenience when using Cursor i propose adding the method `remaining`.

The next thing i found inconvenient (unnecessary long) was detecting if the cursor reached the end. There are a few ways this can be achieved right now:
- `buff.fill_buf().unwrap().is_empty()`
- `buff.position() >= buff.get_ref().len()`
- `buff.bytes().next().is_none()`

Which all seem a bit unintuitive, hidden in trait documentations or just a bit long for such a simple task.
Therefor i propose another method called `is_empty`, maybe with another name, since this one may leave room for interpretation on what really is empty (the underlying slice, the remaining slice or maybe the position).

Since it seemed easier to create this PR instead of an RFC i did that, if an RFC is wanted, i can close this PR and write an RFC first.
2021-06-22 07:37:46 +09:00
Yuki Okushi
7f1a4a287f
Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor
Move `available_concurrency` implementation to `sys`

This splits out the platform-specific implementation of `available_concurrency` to the corresponding platforms under `sys`. No changes are made to the implementation.

Tidy didn't lint against this code being originally added outside of `sys` because of a bug (see #84677), this PR also reverts the exclusion that was introduced in that bugfix.

Tracking issue of `available_concurrency`: #74479
2021-06-22 07:37:46 +09:00
Yuki Okushi
d6e344d45d
Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=Amanieu
Revert SGX inline asm syntax

This was erroneously changed in #83387
2021-06-22 07:37:42 +09:00
Cameron Steffen
b07bb6d698 Fix unused_unsafe with compiler-generated unsafe 2021-06-21 17:25:45 -05:00
bors
4573a4a879 Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3
Add MIR pass to lower call to `core::slice::len` into `Len` operand

During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.

It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.

Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-21 22:24:13 +00:00
bors
406d4a9cc3 Auto merge of #86515 - JohnTitor:rollup-axzb4xh, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #86192 (Make OR_PATTERNS_BACK_COMPAT be a 2021 future-incompatible lint)
 - #86248 (Add a regression test for issue-85113)
 - #86274 (Spaces)
 - #86349 (Add regression test for issue #78632)
 - #86424 (rustfmt: load nested out-of-line mods correctly)
 - #86472 (Fix CI to fetch master on beta channel)
 - #86473 (Rustdoc: Account for const-unstable functions)
 - #86495 (Improve `proc_macro::{Punct, Spacing}` documentation)
 - #86503 (Fix rust.css fonts.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-21 19:36:04 +00:00
Niko Matsakis
aa3580baa6 introduce helper function 2021-06-21 14:36:25 -04:00
LeSeulArtichaut
4cd5affcf2 Fix handling of disambiguator suffixes for intra-doc links 2021-06-21 20:26:14 +02:00
Deadbeef
e66f241b80
Update #83739 with type of the item specified 2021-06-22 01:03:54 +08:00
Deadbeef
9b6c7ffa06
Updated tests to reflect specified types in E0121 2021-06-22 00:40:47 +08:00
Deadbeef
200fdaac77
Specify the kind of the item for E0121 2021-06-22 00:40:47 +08:00
Niko Matsakis
186c09ae83 add test for dyn collisions 2021-06-21 11:55:07 -04:00
Niko Matsakis
3dc47e2c09 do not run rustfix for future-prelude-collision-shadow 2021-06-21 11:22:17 -04:00
Smitty
b8a7bfb9f1 Reference issue test originated from 2021-06-21 11:17:30 -04:00
Yuki Okushi
599e8a7439
Rollup merge of #86503 - ehuss:rustc.css-fonts, r=jyn514,GuillaumeGomez
Fix rust.css fonts.

The `rust.css` file (used for all non-rustdoc and non-mdbook pages) has gotten out of sync with rustdoc's css. The two share the same fonts, so this updates them to match what rustdoc uses.

It would be ideal not to need this at all, but that's for another time.
2021-06-22 00:00:45 +09:00
Yuki Okushi
2fdc2eab76
Rollup merge of #86495 - r00ster91:patch-11, r=petrochenkov
Improve `proc_macro::{Punct, Spacing}` documentation

I noticed some misspellings and then thought I could improve it a bit overall.
2021-06-22 00:00:44 +09:00
Yuki Okushi
f3fe5c3ba1
Rollup merge of #86473 - fee1-dead:rustdoc-const-unstable, r=jyn514
Rustdoc: Account for const-unstable functions

Fixes #86464
2021-06-22 00:00:43 +09:00
Yuki Okushi
9c664b2321
Rollup merge of #86472 - Mark-Simulacrum:fix-ci-beta, r=pietroalbini
Fix CI to fetch master on beta channel

This forward-ports a fix from the beta channel (landing in #86413, hopefully) to master so that we don't need to apply it on each round of backports.

This bug also demonstrates that our channel-checking is a bit insufficient -- stable is checked, but beta has some of its own peculiarities currently and isn't checked. But this does not attempt to adjust for that; we likely can't afford to run both beta and stable channels by CI and the current state here seems OK for now.

r? `@pietroalbini`
2021-06-22 00:00:42 +09:00
Yuki Okushi
a81f55fb16
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
rustfmt: load nested out-of-line mods correctly

This should address https://github.com/rust-lang/rustfmt/issues/4874

r? `@Mark-Simulacrum`

Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
2021-06-22 00:00:41 +09:00
Yuki Okushi
aba0bed466
Rollup merge of #86349 - yerke:add-test-for-issue-78632, r=Mark-Simulacrum
Add regression test for issue #78632

Add regression test for issue #78632

Closes #78632

Took this test from #78632 (what was committed to glacier in https://github.com/rust-lang/rust/issues/78632#issuecomment-731843345).

Tested that the we get ICE on 1.52.1 on the playground (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b86d51fee4cded9d24b50d8ecbc48c6a).
2021-06-22 00:00:40 +09:00
Yuki Okushi
58e7411092
Rollup merge of #86274 - alexander-melentyev:spaces, r=bjorn3
Spaces
2021-06-22 00:00:38 +09:00
Yuki Okushi
ac410564f0
Rollup merge of #86248 - JohnTitor:issue-85113, r=Mark-Simulacrum
Add a regression test for issue-85113

Fixed by #86118, closes #85113
2021-06-22 00:00:37 +09:00
Yuki Okushi
3ee78b38fe
Rollup merge of #86192 - hi-rustin:rustin-patch-lint, r=nikomatsakis
Make OR_PATTERNS_BACK_COMPAT be a 2021 future-incompatible lint

close https://github.com/rust-lang/rust/issues/84869

r? `@nikomatsakis`
2021-06-22 00:00:36 +09:00
Michael Woerister
c3c4ab5ed2 Encode SourceFile source crate as StableCrateId in incr. comp. OnDiskCache. 2021-06-21 15:30:16 +02:00
Deadbeef
b57077bbf0
Readd unsafe keyword in tests 2021-06-21 20:42:57 +08:00
Deadbeef
f82fb308af
Update comment regarding staged_api 2021-06-21 20:21:37 +08:00
bors
6a5b97adb4 Auto merge of #86210 - ehuss:rustfix-update, r=Mark-Simulacrum
Rustfix update

This updates to rustfix 0.6.0. One of the key changes here is https://github.com/rust-lang/rustfix/pull/195 which changes rustfix to apply multi-part suggestions. One of the tests needs to updated because there are some overlapping suggestions which rustfix cannot handle. The solution is to only apply the machine-applicable suggestions to avoid the overlapping issue.

This also includes a minor change to compiletest to provide better error messages with rustfix.
2021-06-21 12:21:19 +00:00
Deadbeef
0d69a02c31
Removed/Updated some cases and simplified match 2021-06-21 20:15:27 +08:00
Michael Woerister
47327145e3 Disambiguate between SourceFiles from different crates even if they have the same path. 2021-06-21 13:38:46 +02:00
Michael Woerister
da5c911b5f Add regression test for #85955. 2021-06-21 13:38:46 +02:00
Deadbeef
c4396f476e
Added some tests for unsafe in const-dispay.rs 2021-06-21 19:17:07 +08:00
Deadbeef
5fb27bca6c
Check for const_unstable before printing const 2021-06-21 19:06:21 +08:00
bors
9d93819fa7 Auto merge of #86157 - jsha:tera, r=jyn514,GuillaumeGomez
Use Tera templates for rustdoc.

Replaces a format!() call in layout::render with a template
expansion. Introduces a `templates` field in SharedContext so parts
of rustdoc can share pre-rendered templates.

This currently builds in a copy of the single template available, like
with static files. However, future work can make this live-loadable with
a perma-unstable flag, to make rustdoc developers' work easier.

Part of #84419.

Demo at https://hoffman-andrews.com/rust/tera/std/string/struct.String.html.
2021-06-21 09:40:34 +00:00
Christiaan Dirkx
888418a079 Use Unsupported on platforms where available_concurrency is not implemented. 2021-06-21 11:31:07 +02:00
Christiaan Dirkx
05ec710c80 Remove tidy exception for available_concurrency 2021-06-21 11:28:53 +02:00
LeSeulArtichaut
dd90900cf4 Resolve type aliases to the type they point to in intra-doc links 2021-06-21 11:15:07 +02:00
Alexander Melentyev
e84c9aed6d Delete spaces 2021-06-21 12:11:37 +03:00
Christiaan Dirkx
9063edaf3b Move available_concurrency implementation to sys 2021-06-21 11:01:46 +02:00
bors
d789de67dc Auto merge of #85775 - adamrk:warn-unused-target-fields, r=nagisa
Emit warnings for unused fields in custom targets.

Add a warning which lists any fields in a custom target `json` file that aren't used. Currently unrecognized fields are ignored so, for example, a typo in the `json` will silently produce a target which isn't the one intended.
2021-06-21 06:56:51 +00:00
Jacob Hoffman-Andrews
cd0f93193c Use Tera templates for rustdoc.
Replaces a format!() call in layout::render with a template
expansion. Introduces a `templates` field in SharedContext so parts
of rustdoc can share pre-rendered templates.

This currently builds in a copy of the single template available, like
with static files. However, future work can make this live-loadable with
a perma-unstable flag, to make rustdoc developers' work easier.
2021-06-20 23:07:28 -07:00
bors
3824017f8e Auto merge of #86166 - tmiasko:no-alloca-for-zsts, r=nagisa
Do not emit alloca for ZST locals with multiple assignments

This extends 35566bfd7d to additionally stop emitting unnecessary allocas for zero sized locals that are assigned multiple times.

When rebuilding the standard library with `-Zbuild-std` this reduces the number of locals that require an allocation from 62315 to 61767.
2021-06-21 04:03:51 +00:00
bors
6a540bd40c Auto merge of #86502 - JohnTitor:rollup-wge0f3x, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #83739 (Account for bad placeholder errors on consts/statics with trait objects)
 - #85637 (document PartialEq, PartialOrd, Ord requirements more explicitly)
 - #86152 (Lazify is_really_default condition in the RustdocGUI bootstrap step)
 - #86156 (Fix a bug in the linkchecker)
 - #86427 (Updated release note)
 - #86452 (fix panic-safety in specialized Zip::next_back)
 - #86484 (Do not set depth to 0 in fully_expand_fragment)
 - #86491 (expand: Move some more derive logic to rustc_builtin_macros)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-21 01:16:15 +00:00
Eric Huss
008d4d6c11 Fix rust.css fonts. 2021-06-20 18:15:54 -07:00
Yuki Okushi
8b9e138ecd
Rollup merge of #86491 - petrochenkov:derefact, r=Aaron1011
expand: Move some more derive logic to rustc_builtin_macros

And cleanup some `unwrap`s in `cfg_eval`.

Refactorings extracted from https://github.com/rust-lang/rust/pull/83354 and https://github.com/rust-lang/rust/pull/86057.
r? ``@Aaron1011``
2021-06-21 09:42:19 +09:00
Yuki Okushi
e5ecded392
Rollup merge of #86484 - fee1-dead:builtin-macro-recursion, r=petrochenkov
Do not set depth to 0 in fully_expand_fragment

Fixes #84632.
2021-06-21 09:42:18 +09:00
Yuki Okushi
504c378159
Rollup merge of #86452 - the8472:fix-zip-drop-safety, r=m-ou-se
fix panic-safety in specialized Zip::next_back

This was unsound since a panic in a.next_back() would result in the
length not being updated which would then lead to the same element
being revisited in the side-effect preserving code.

fixes #86443
2021-06-21 09:42:17 +09:00
Yuki Okushi
13b0f1a29b
Rollup merge of #86427 - hi-rustin:rustin-patch-release-note, r=Mark-Simulacrum
Updated release note

close https://github.com/rust-lang/rust/issues/77098

base on https://github.com/rust-lang/rust/pull/78690
2021-06-21 09:42:16 +09:00
Yuki Okushi
e435e3259d
Rollup merge of #86156 - ehuss:linkchecker-fixes, r=Mark-Simulacrum
Fix a bug in the linkchecker

There was a small typo in the linkchecker (in #85652) that caused it to report a `#` fragment link error pointing to the wrong file (it was displaying the path to the source file, not the target of the link).

This also includes a few other changes:
- Fixes the tests due to some changes in the redirect handling in #84703.
- Adds the tests to rustbuild to run whenever the linkchecker itself is run.
- Updates the tests to validate more of the output (so that a mistake like this would have been caught).

Closes #86144
2021-06-21 09:42:15 +09:00
Yuki Okushi
e7a4f1e3fc
Rollup merge of #86152 - the8472:lazify-npm-queries, r=Mark-Simulacrum
Lazify is_really_default condition in the RustdocGUI bootstrap step

The `RustdocGUI::should_run` condition spawns `npm list` several times which adds up to seconds of wall-time.
Evaluate the condition lazily to to keep `./x.py test tidy` and similar short-running tasks fast.

Fixes #86147
2021-06-21 09:42:15 +09:00
Yuki Okushi
e6732e05e4
Rollup merge of #85637 - RalfJung:partial-ord, r=m-ou-se
document PartialEq, PartialOrd, Ord requirements more explicitly

This is the result of discussion in https://github.com/rust-lang/rust/issues/50230, in particular [this summary comment](https://github.com/rust-lang/rust/issues/50230#issuecomment-392819364).

Fixes https://github.com/rust-lang/rust/issues/50230.
2021-06-21 09:42:13 +09:00