rust/compiler
bors 8a7ca936e6 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se
Partial stabilization of `once_cell`

This PR aims to stabilize a portion of the `once_cell` feature:

- `core::cell::OnceCell`
- `std::cell::OnceCell` (re-export of the above)
- `std::sync::OnceLock`

This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag.

Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue)

Future steps for separate PRs:
- ~~Add `#[inline]` to many methods~~ #105651
- Update cranelift usage of the `once_cell` crate
- Update rust-analyzer usage of the `once_cell` crate
- Update error messages discussing once_cell

## To be stabilized API summary

```rust
// core::cell (in core/cell/once.rs)

pub struct OnceCell<T> { .. }

impl<T> OnceCell<T> {
    pub const fn new() -> OnceCell<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceCell<T>;
impl<T: Debug> Debug for OnceCell<T>
impl<T> Default for OnceCell<T>;
impl<T> From<T> for OnceCell<T>;
impl<T: PartialEq> PartialEq for OnceCell<T>;
impl<T: Eq> Eq for OnceCell<T>;
```

```rust
// std::sync (in std/sync/once_lock.rs)

impl<T> OnceLock<T> {
    pub const fn new() -> OnceLock<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceLock<T>;
impl<T: Debug> Debug for OnceLock<T>;
impl<T> Default for OnceLock<T>;
impl<#[may_dangle] T> Drop for OnceLock<T>;
impl<T> From<T> for OnceLock<T>;
impl<T: PartialEq> PartialEq for OnceLock<T>
impl<T: Eq> Eq for OnceLock<T>;
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>;
unsafe impl<T: Send> Send for OnceLock<T>;
unsafe impl<T: Sync + Send> Sync for OnceLock<T>;
impl<T: UnwindSafe> UnwindSafe for OnceLock<T>;
```

No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate:

```rust
impl<T> OnceCell<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}

impl<T> OnceLock<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}
```

I am new to this process so would appreciate mentorship wherever needed.
2023-03-30 10:12:23 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Move mir::Fieldabi::FieldIdx 2023-03-28 22:22:37 -07:00
rustc_apfloat
rustc_arena
rustc_ast Fix mismatched punctuation in Debug impl of AttrId 2023-03-28 20:21:23 -07:00
rustc_ast_lowering Rollup merge of #109664 - m-ou-se:format-args-placeholder-span, r=oli-obk 2023-03-29 14:07:28 +05:30
rustc_ast_passes rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
rustc_ast_pretty Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
rustc_attr Bless tidy 2023-03-27 18:58:07 +00:00
rustc_baked_icu_data update ICU4X to 1.1.0 2023-02-04 22:28:59 +01:00
rustc_borrowck Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_builtin_macros Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors 2023-03-27 18:56:19 +02:00
rustc_codegen_cranelift Rollup merge of #109716 - scottmcm:field-to-fieldidx, r=oli-obk 2023-03-29 21:19:51 +02:00
rustc_codegen_gcc Use poison instead of undef 2023-03-16 15:07:04 +01:00
rustc_codegen_llvm Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_codegen_ssa Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_const_eval Rollup merge of #109700 - clubby789:tidy-fluent-escape, r=compiler-errors 2023-03-29 21:19:50 +02:00
rustc_data_structures Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_driver Remove unneeded extern crate 2023-02-02 07:47:39 +01:00
rustc_driver_impl Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_error_codes Rollup merge of #109565 - WaffleLapkin:better_docs_for_e0223, r=oli-obk 2023-03-28 07:01:08 +02:00
rustc_error_messages Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_errors Create AnnotationColumn struct to fix hard tab column numbers in errors 2023-03-28 09:18:55 -04:00
rustc_expand Separate find_*_stability. 2023-03-23 19:52:27 +00:00
rustc_feature Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz Fix uninlined_format_args for some compiler crates 2023-01-05 19:01:12 +01:00
rustc_hir Properly skip RPITITs from ModChild and give a name in AssocItem 2023-03-29 11:19:49 -03:00
rustc_hir_analysis Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_hir_pretty Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
rustc_hir_typeck Rollup merge of #109149 - mj10021:issue-108713-fix, r=compiler-errors,WaffleLapkin 2023-03-29 06:02:41 +02:00
rustc_incremental Check for escape sequences in Fluent resources 2023-03-29 18:34:29 +01:00
rustc_index Rename IndexVec::lastlast_index 2023-03-29 00:27:24 -07:00
rustc_infer Rollup merge of #109629 - aliemjay:remove-givens, r=lcnr 2023-03-28 12:51:14 +02:00
rustc_interface Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_lexer fix(lexer): not skipped whitespace warning for '\x0c' 2023-03-09 22:44:58 +08:00
rustc_lint Rollup merge of #109700 - clubby789:tidy-fluent-escape, r=compiler-errors 2023-03-29 21:19:50 +02:00
rustc_lint_defs Rollup merge of #108588 - ehuss:lint-docs-produces, r=eholk 2023-03-23 19:55:45 +01:00
rustc_llvm Auto merge of #109720 - Dylan-DPC:rollup-u564m8s, r=Dylan-DPC 2023-03-29 09:45:26 +00:00
rustc_log Rollup merge of #107895 - matthiaskrgr:cl, r=compiler-errors 2023-02-11 17:18:44 +01:00
rustc_macros Check for escape sequences in Fluent resources 2023-03-29 18:34:29 +01:00
rustc_metadata Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_middle Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_mir_build Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_mir_dataflow Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_mir_transform Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se 2023-03-30 10:12:23 +00:00
rustc_monomorphize Support TLS access into dylibs on Windows 2023-03-29 08:55:21 +02:00
rustc_parse Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors 2023-03-27 18:56:19 +02:00
rustc_parse_format Improve heuristics for format_args literal being suggestable 2023-03-14 13:20:39 +00:00
rustc_passes Separate find_*_stability. 2023-03-23 19:52:27 +00:00
rustc_plugin_impl expand: Pass ast::Crate by reference to AST transforming passes 2023-03-23 14:20:55 +04:00
rustc_privacy Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
rustc_query_impl Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_query_system Rollup merge of #108480 - Zoxc:rayon-tlv, r=cuviper 2023-03-28 12:51:12 +02:00
rustc_resolve Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors 2023-03-27 18:56:19 +02:00
rustc_serialize Update indexmap and rayon crates 2023-03-25 02:12:13 +01:00
rustc_session Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
rustc_smir Add Debug and Clone derives for stable mir datastructures 2023-03-16 16:17:25 +00:00
rustc_span Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstrieb 2023-03-28 15:18:16 +00:00
rustc_symbol_mangling Support TLS access into dylibs on Windows 2023-03-29 08:55:21 +02:00
rustc_target Auto merge of #108996 - pnkfelix:rollback-part-of-pr-104137-that-broke-wasm-linker-overriding, r=petrochenkov 2023-03-29 19:18:46 +00:00
rustc_trait_selection Rollup merge of #109675 - compiler-errors:object-heck, r=lcnr 2023-03-29 21:19:49 +02:00
rustc_traits Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
rustc_transmute rustc_middle: Remove trait DefIdTree 2023-03-02 23:46:44 +04:00
rustc_ty_utils Auto merge of #109499 - spastorino:new-rpitit-19, r=compiler-errors 2023-03-30 05:48:59 +00:00
rustc_type_ir Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00