Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs to Box conversions #89199

Closed
wants to merge 960 commits into from

Conversation

timClicks
Copy link
Contributor

Part of #51430.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2021
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
library/alloc/src/boxed.rs Outdated Show resolved Hide resolved
@timClicks
Copy link
Contributor Author

Thanks for the review @jyn514. I've incorporated those suggestions.

@m-ou-se
Copy link
Member

m-ou-se commented Sep 24, 2021

@timClicks can you squash the commits?

@jyn514 jyn514 added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2021
DevinR528 and others added 16 commits October 2, 2021 17:51
Make *const (), *mut () okay for FFI

Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples:

- `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new
- `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts

I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed:

```rust
extern "C" {
    fn demo(pc: *const (), pm: *mut ());
}
```

Prior to this PR, those pointers were not considered okay for an extern signature.

```console
warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:17
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                 ^^^^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider using a struct instead
  = note: tuples have unspecified layout

warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:32
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                                ^^^^^^^ not FFI-safe
  |
  = help: consider using a struct instead
  = note: tuples have unspecified layout
```
Make diangostic item naming consistent

Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.
…olnay

Optimize unnecessary check in Vec::retain

The function `vec::Vec::retain` only have two stages:

1. Nothing was deleted.
2. Some elements were deleted.

Here is an unnecessary check `if g.deleted_cnt > 0` in the loop, and it's difficult for compiler to optimize it. I split the loop into two stages manully and keep the code clean using const generics.

I write a special but common bench case for this optimization. I call retain on vec but keep all elements.

Before and after this optimization:

```
test vec::bench_retain_whole_100000                      ... bench:      84,803 ns/iter (+/- 17,314)
```

```
test vec::bench_retain_whole_100000                      ... bench:      42,638 ns/iter (+/- 16,910)
```

The result is expected, there are two `if`s before the optimization and one `if` after.
Among other changes, documents whether allocations are necessary
to complete the type conversion.

Part of rust-lang#51430

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>

Co-authored-by: Joshua Nelson <github@jyn.dev>
bors and others added 22 commits October 7, 2021 11:34
Array `.len()` MIR optimization pass

This pass kind-of works back the `[T; N].len()` call that at the moment is first coerced as `&[T; N]` -> `&[T]` and then uses `&[T].len()`. Depends on rust-lang#86383
Introduce `tcx.get_diagnostic_name`

Introduces a "reverse lookup" for diagnostic items. This is mainly intended for `@rust-lang/clippy` which often does a long series of `is_diagnostic_item` calls for the same `DefId`.

r? `@oli-obk`
Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers

closes rust-lang#89193
r? `@workingjubilee`
…matsakis

Add `deref_into_dyn_supertrait` lint.

Initial implementation of rust-lang#89460. Resolves rust-lang#89190.
Maybe also worth a beta backport if necessary.

r? `@nikomatsakis`
…ark-Simulacrum

Move items related to computing diffs to a separate file

Work towards rust-lang#89475.
…ler_t, r=nagisa

RustWrapper: adapt for LLVM API change

No functional changes intended.

The LLVM commit
llvm/llvm-project@e463b69
changed an argument of fatal_error_handler_t from std::string to char*.
This adapts RustWrapper accordingly.
Emit item no type error even if type inference fails

Fix rust-lang#89574

The stashed error should be emitted regardless whether ty references error or not.
…jyn514

Make cfg imply doc(cfg)

This is a reopening of rust-lang#79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):

 * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc.
 * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation.
 * I updated the version for the feature.

There is only one thing I couldn't figure out: [this comment](rust-lang#79341 (comment))

> I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different.

How/why should they differ?

EDIT: this part has been solved, the current code was fine, just needed a little simplification.

cc `@Nemo157`
r? `@jyn514`

Original PR description:

This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like:

```rust
#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;
```

By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
…owck-facts, r=oli-obk

Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts

`mir_borrowck` uses `with_opaque_type_inference` before calling `do_mir_borrowck`: https://github.com/rust-lang/rust/blob/0eabf25b90396dead0b2a1aaa275af18a1ae6008/compiler/rustc_borrowck/src/lib.rs#L132

However `get_body_with_borrowck_facts` does not. Therefore I get an ICE eg when calling this function on the bodies of an async function as described here: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20ICE.20when.20using.20get_body_with_borrowck_facts.20with.20async

This change fixes that bug.

r? `@nikomatsakis`
…laumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers )
 - rust-lang#89461 (Add `deref_into_dyn_supertrait` lint.)
 - rust-lang#89477 (Move items related to computing diffs to a separate file)
 - rust-lang#89559 (RustWrapper: adapt for LLVM API change)
 - rust-lang#89585 (Emit item no type error even if type inference fails)
 - rust-lang#89596 (Make cfg imply doc(cfg))
 - rust-lang#89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
…=Mark-Simulacrum

Revert "Stabilize `Iterator::intersperse()`"

Reverts rust-lang#88548

First step in resolving rust-lang#88967
Among other changes, documents whether allocations are necessary
to complete the type conversion.

Part of rust-lang#51430

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>

Co-authored-by: Joshua Nelson <github@jyn.dev>
Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
@timClicks
Copy link
Contributor Author

Oh wow - I've totally mucked this up.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
configure: rust.channel         := nightly
configure: rust.debug-assertions := True
configure: llvm.assertions      := True
configure: dist.missing-tools   := True
configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
configure: writing `config.toml` in current directory
configure: 
configure: run `python /checkout/x.py --help`
configure: 
---
* 352 features
some tidy checks failed


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/rust-tidy" "/checkout" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "/checkout/obj/build" "16"


Build completed unsuccessfully in 0:00:13

@timClicks
Copy link
Contributor Author

Closing in favour of the new PR

@timClicks timClicks closed this Oct 8, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 9, 2021
…ersions, r=m-ou-se

Add documentation to boxed conversions

Among other changes, documents whether allocations are necessary
to complete the type conversion.

Part of rust-lang#51430, supersedes rust-lang#89199
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 9, 2021
…ersions, r=m-ou-se

Add documentation to boxed conversions

Among other changes, documents whether allocations are necessary
to complete the type conversion.

Part of rust-lang#51430, supersedes rust-lang#89199
@timClicks timClicks deleted the 51430-document-from branch October 29, 2021 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.