move core::hint::black_box under its own feature gate
The `black_box` function had its own RFC and is tracked separately from the `test` feature at https://github.com/rust-lang/rust/issues/64102. Let's reflect this in the feature gate.
To avoid breaking all the benchmarks, libtest's `test::black_box` is a wrapping definition, not a reexport -- this means it is still under the `test` feature gate.
Cautiously add IntoIterator for arrays by value
Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array.
Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later.
r? `@nikomatsakis`
cc `@LukasKalbertodt` `@rust-lang/libs`
Rework `init` and `cleanup`
This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`.
Full list of changes:
- new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros.
- `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`.
- <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
Calculate `span` info on-demand
- Add helper `attr_span` for common reused function
- Stop storing `Span`s on `Item` directly; calculate them on demand instead
- Special case modules, which have different spans depending on whether
you use inner or outer attributes
- Special case impls with fake IDs, which can have either dummy spans (for auto traits) or the DefId of the impl block (for blanket impls)
- Use a fake ID for primitives instead of the ID of the crate; this lets
`source()` know that it should use a dummy span instead of the span of
the crate.
This shrinks `Item` from 48 to 40 bytes.
Helps with https://github.com/rust-lang/rust/issues/76382.
Duration is used in std to represent a difference between two Instants.
As such, it has to at least contain that span of time in it. However,
Instant can vary by platform. Thus, we should explain the impl of
Duration::MAX is sensitive to these vagaries of the platform.
further split up const_fn feature flag
This continues the work on splitting up `const_fn` into separate feature flags:
* `const_fn_trait_bound` for `const fn` with trait bounds
* `const_fn_unsize` for unsizing coercions in `const fn` (looks like only `dyn` unsizing is still guarded here)
I don't know if there are even any things left that `const_fn` guards... at least libcore and liballoc do not need it any more.
`@oli-obk` are you currently able to do reviews?
Fixes: #83792
MIR `InstrumentCoverage` assumed the `FnSig` span was contained within a
single file, but this is not always the case. Some macro constructions
can result in a span that starts in one `SourceFile` and ends in a
different one.
The `FnSig` span is included in coverage results as long as that span is
in the same `SourceFile` and the same macro context, but by assuming the
`FnSig` span's `hi()` and `lo()` were in the same file, I took this for
granted, and checked only that the `FnSig` `hi()` was in the same
`SourceFile` as the `body_span`.
I actually drop the `hi()` though, and extend the `FnSig` span to the
`body_span.lo()`, so I really should have simply checked that the
`FnSig` span's `lo()` was in the `SourceFile` of the `body_span`.
Revert "rustdoc: Hide `#text` in doc-tests"
See discussion in #84502 - I'm worried that #84445 may cause a lot of breakages if this were to hit stable, so I think it's safer to revert and work on the known correct fix#84478.
Rollup of 8 pull requests
Successful merges:
- #83519 (Implement a lint that highlights all moves larger than a configured limit)
- #84105 (stabilize `core::array::{from_ref,from_mut}` in `1.53.0`)
- #84179 (Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}`)
- #84427 (Update Clippy)
- #84459 (rustdoc: Turn `JsonRenderer::mod_item_in` into `unreachable!()`)
- #84460 (rustdoc: Remove unnecessary `is_crate` field from doctree::Module and clean::Module)
- #84464 (rustdoc: Get rid of `clean::TypeKind`)
- #84518 (Clean up DOM strings)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
rustdoc: Remove unnecessary `is_crate` field from doctree::Module and clean::Module
It can be calculated on-demand even without a TyCtxt.
This also changed `json::conversions::from_item_kind` to take a whole item, which avoids
having to add more and more parameters.
Helps with https://github.com/rust-lang/rust/issues/76382.
r? ```@camelid```
rustdoc: Turn `JsonRenderer::mod_item_in` into `unreachable!()`
The JSON renderer no longer gets called on modules (since https://github.com/rust-lang/rust/pull/83055).
r? ``@aDotInTheVoid``
Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}`
Remove the field `_dont_send_or_sync_me: PhantomData<*mut ()>` in favor of an explicit implementation of `!Send` and `!Sync`.
Implement a lint that highlights all moves larger than a configured limit
Tracking issue: #83518
[MCP 420](https://github.com/rust-lang/compiler-team/issues/420) still ~blazing~ in progress
r? ```@pnkfelix```
The main open issue I see with this minimal impl of the feature is that the lint is immediately "stable" (so it can be named on stable), even if it is never executed on stable. I don't think we have the concept of unstable lint names or hiding lint names without an active feature gate, so that would be a bigger change.
Rollup of 10 pull requests
Successful merges:
- #83990 (implement `TrustedRandomAccess` for `Take` iterator adapter)
- #84250 (bootstrap: use bash on illumos to run install scripts)
- #84320 (Use details tag for trait implementors.)
- #84436 (Make a few functions private)
- #84453 (Document From implementations for Waker and RawWaker)
- #84458 (Remove unnecessary fields and parameters in rustdoc)
- #84485 (Add some associated type bounds tests)
- #84489 (Mention FusedIterator case in Iterator::fuse doc)
- #84492 (rustdoc: Remove unnecessary dummy span)
- #84496 (Add some specialization tests)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup