-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add docs to Box conversions #89199
Conversation
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. |
This comment has been minimized.
This comment has been minimized.
Thanks for the review @jyn514. I've incorporated those suggestions. |
@timClicks can you squash the commits? |
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 <[email protected]> Co-authored-by: Joshua Nelson <[email protected]>
…51430-document-from
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
Update Clippy r? `@Manishearth`
…=Mark-Simulacrum Revert "Stabilize `Iterator::intersperse()`" Reverts rust-lang#88548 First step in resolving rust-lang#88967
Update Miri Fixes rust-lang#89612. r? `@RalfJung`
Among other changes, documents whether allocations are necessary to complete the type conversion. Part of rust-lang#51430 Co-authored-by: Giacomo Stevanato <[email protected]> Co-authored-by: Joshua Nelson <[email protected]>
Co-authored-by: Giacomo Stevanato <[email protected]>
…51430-document-from
Oh wow - I've totally mucked this up. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Closing in favour of the new PR |
…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
…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
Part of #51430.