Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f5579e6
Support else-branch for move_guard
A4-Tacks Jan 22, 2026
da57703
Add selection test case
A4-Tacks Jan 22, 2026
2bae85e
Remove `derive(Copy)` on `ArrayWindows`
cuviper Jan 24, 2026
9052155
Manually `impl Clone for ArrayWindows`
cuviper Jan 24, 2026
08cd2ac
`impl FusedIterator for ArrayWindows`
cuviper Jan 24, 2026
8f7d556
`impl TrustedLen for ArrayWindows`
cuviper Jan 24, 2026
129d552
`impl TrustedRandomAccess for ArrayWindows`
cuviper Jan 24, 2026
8321b25
Add test case for select non-first branch
A4-Tacks Jan 26, 2026
5a568d5
fix linking of postcard test
Shourya742 Jan 27, 2026
c99fca1
feat: fallback let postfix completions in condition
A4-Tacks Jan 30, 2026
4e5b645
fix: Fix more glob issues
Veykril Jan 31, 2026
41577bc
refactor: Remove unused comments related to SyntaxErrorKind
Feb 1, 2026
edf20f0
Merge pull request #21561 from Veykril/push-xvymvmuvzuyn
Veykril Feb 2, 2026
c53d127
Merge pull request #21565 from abdul2801/master
Veykril Feb 2, 2026
c836e24
Cover more cases where we need parentheses in `&(impl Trait1 + Trait2)`
ChayimFriedman2 Feb 2, 2026
dbb9b62
internal: Clarify that CargoCheck applies to all check commands
Wilfred Jan 30, 2026
df2a3f8
internal: Document and rename DiagnosticsReceived variants
Wilfred Jan 30, 2026
93dece9
fix: Stale diagnostics with rust-project.json and rustc JSON
Wilfred Feb 2, 2026
301ff3f
Infer the expected len in `include_bytes!()`, to avoid mismatches
ChayimFriedman2 Feb 3, 2026
dc1ac63
Parse `try bikeshed T {}` syntax
goffrie Feb 2, 2026
07213f0
Add Residual, residual_into_try_type to minicore
goffrie Feb 2, 2026
383eb25
Implement homogeneous & heterogeneous try blocks
goffrie Feb 2, 2026
9415ddd
Remove unnecessary `unsafe(non_update_types)`
ChayimFriedman2 Feb 3, 2026
ed58edc
Merge pull request #21572 from goffrie/try
ChayimFriedman2 Feb 3, 2026
8e3c55b
Merge pull request #21576 from ChayimFriedman2/remove-non-update
ChayimFriedman2 Feb 3, 2026
2afde4e
Merge pull request #21557 from A4-Tacks/let-postfix-in-cond
ChayimFriedman2 Feb 3, 2026
492e302
Merge pull request #21508 from A4-Tacks/move-guard-else-if
ChayimFriedman2 Feb 3, 2026
3988689
Use `display_source_code()` in `ReferenceConversion`
ChayimFriedman2 Feb 3, 2026
b4f36ce
Prevent cycles when lowering from supertrait elaboration
ChayimFriedman2 Feb 3, 2026
4c3600c
Provide a cycle handler for `GenericPredicates`
ChayimFriedman2 Feb 3, 2026
b83b375
fix: Fix not complete `.not` in condition
A4-Tacks Jan 26, 2026
34ca201
fix: Truncate display version of commands consistently
Wilfred Feb 3, 2026
51abdca
docs: remove shell prompt symbols and fix code block languages
Act0r1 Feb 4, 2026
9ecd626
docs: additional improvements
Act0r1 Feb 4, 2026
ec6d039
Merge pull request #21526 from A4-Tacks/comp-not-in-cond
ChayimFriedman2 Feb 4, 2026
a72f7fe
docs: use triple backticks for pacman command
Act0r1 Feb 4, 2026
bdf8d3b
Set crt_static_allow_dylibs to true for Emscripten target
hoodmane Feb 4, 2026
0a4871c
Merge pull request #21585 from Act0r1/docs/improve-documentation
Veykril Feb 5, 2026
e21584e
Merge pull request #21580 from Wilfred/display_command_shortened
Veykril Feb 5, 2026
934eebd
Merge pull request #21579 from ChayimFriedman2/cycle
Veykril Feb 5, 2026
5300804
Merge pull request #21578 from ChayimFriedman2/reparse-unknown
Veykril Feb 5, 2026
82941ed
Merge pull request #21573 from ChayimFriedman2/include-bytes-len
Veykril Feb 5, 2026
a2b126b
Merge pull request #21569 from ChayimFriedman2/parens-multi-impl-trait
Veykril Feb 5, 2026
1a240d6
expand `define_reify_functions!`
cyrgani Feb 5, 2026
749d62b
remove `Closure` generics
cyrgani Feb 5, 2026
1a03742
simplify some other generics
cyrgani Feb 5, 2026
18996c6
make `with_api!` take explicit type paths
cyrgani Feb 5, 2026
a6062a8
use `mem::conjure_zst` directly
cyrgani Feb 5, 2026
74d2616
deduplicate `Tag` enum
cyrgani Feb 6, 2026
6fde77c
internal: Simplify binding hash computation in syntax highlighting
Veykril Feb 7, 2026
86cdf24
Merge pull request #21599 from Veykril/push-oqmszvwttzsz
Veykril Feb 7, 2026
3ee0286
internal: Remove `Edition::CURRENT_FIXME`
Veykril Jan 18, 2026
c91e70e
Merge pull request #21488 from Veykril/push-ptvulypwwmvz
Veykril Feb 7, 2026
63eefa9
Bump time from 0.3.44 to 0.3.47
dependabot[bot] Feb 7, 2026
c14eb7f
Merge pull request #21593 from rust-lang/dependabot/cargo/time-0.3.47
Veykril Feb 7, 2026
729f384
Bump salsa
Veykril Feb 7, 2026
84c2a53
Correctly implement client side request cancellation support
Veykril Jan 1, 2026
cee9cc6
Fix an ICE in the vtable iteration for a trait reference in const eva…
jakubadamw Feb 7, 2026
6af91c5
Move tests from tests/crashes to tests/ui now that they don't ICE
jakubadamw Feb 7, 2026
abc2fc0
Merge pull request #21380 from Veykril/push-nolvxuourwru
Veykril Feb 7, 2026
cfe2461
Merge pull request #21570 from Wilfred/clarify_check_struct
Veykril Feb 7, 2026
36058bf
Merge pull request #21571 from Wilfred/check_type_names
Veykril Feb 7, 2026
d0b3a0b
Add some conversion trait impls
Jules-Bertholet Feb 3, 2026
d8ff397
check stalled coroutine obligations eagerly
adwinwhite Feb 8, 2026
f394d1e
Fix lockfile
lnicola Feb 9, 2026
0e022db
Merge pull request #21607 from lnicola/fix-lockfile
lnicola Feb 9, 2026
5ad44f2
Merge pull request #21538 from Shourya742/2026-01-28-fix-linking-of-p…
lnicola Feb 9, 2026
f248395
bless tests
adwinwhite Feb 8, 2026
88c296a
std: introduce path normalize methods at top of std::path
xizheyin Feb 9, 2026
e04ae80
Rename `JobOwner` to `ActiveJobGuard`
Zalathar Feb 9, 2026
c475bda
Include `key_hash` in `ActiveJobGuard`
Zalathar Feb 9, 2026
2b22150
Port rustc_no_implicit_bounds attribute to parser.
Ozzy1423 Feb 4, 2026
43e5203
compiletest: `-Zunstable-options` for json targets
davidtwco Feb 6, 2026
40a264c
fix: rhs_span to rhs_span_new
cuiweixie Feb 9, 2026
903f9fc
Rollup merge of #152388 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Feb 9, 2026
144b77a
Rollup merge of #151613 - cuviper:array-windows-parity, r=Amanieu
matthiaskrgr Feb 9, 2026
5fa914c
Rollup merge of #152134 - hoodmane:emscripten-crt-static-allow-dylibs…
matthiaskrgr Feb 9, 2026
e2ddf5c
Rollup merge of #152166 - cyrgani:questionable-pm-cleanups, r=petroch…
matthiaskrgr Feb 9, 2026
19122c0
Rollup merge of #152236 - davidtwco:compiletest-destabilise-custom-ta…
matthiaskrgr Feb 9, 2026
8afd636
Rollup merge of #152287 - jakubadamw:issue-137190, r=petrochenkov
matthiaskrgr Feb 9, 2026
c15f4e0
Rollup merge of #142957 - xizheyin:142931, r=tgross35
matthiaskrgr Feb 9, 2026
2ce5f48
Rollup merge of #145504 - Jules-Bertholet:more_conversion_trait_impls…
matthiaskrgr Feb 9, 2026
c1f716a
Rollup merge of #152131 - Ozzy1423:attrs6, r=JonathanBrouwer
matthiaskrgr Feb 9, 2026
7ecefd0
Rollup merge of #152315 - cuiweixie:bugfix-span, r=jieyouxu
matthiaskrgr Feb 9, 2026
1f0e215
Rollup merge of #152327 - adwinwhite:fix-non-defining-use-ices-ready,…
matthiaskrgr Feb 9, 2026
2f16df1
Rollup merge of #152377 - Zalathar:active-job-guard, r=nnethercote
matthiaskrgr Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/crate_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcPreserveUbChecksParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPreserveUbChecks;
}

pub(crate) struct RustcNoImplicitBoundsParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcNoImplicitBoundsParser {
const PATH: &[Symbol] = &[sym::rustc_no_implicit_bounds];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNoImplicitBounds;
}
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ attribute_parsers!(
Single<WithoutArgs<RustcMainParser>>,
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
Single<WithoutArgs<RustcNoImplicitBoundsParser>>,
Single<WithoutArgs<RustcNonConstTraitMethodParser>>,
Single<WithoutArgs<RustcNounwindParser>>,
Single<WithoutArgs<RustcOffloadKernelParser>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ fn suggest_ampmut<'tcx>(
&& let Either::Left(rhs_stmt_new) = body.stmt_at(*assign)
&& let StatementKind::Assign(box (_, rvalue_new)) = &rhs_stmt_new.kind
&& let rhs_span_new = rhs_stmt_new.source_info.span
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span)
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span_new)
{
(rvalue, rhs_span, rhs_str) = (rvalue_new, rhs_span_new, rhs_str_new);
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ fn mir_borrowck(
let (input_body, _) = tcx.mir_promoted(def);
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));

// We should eagerly check stalled coroutine obligations from HIR typeck.
// Not doing so leads to silent normalization failures later, which will
// fail to register opaque types in the next solver.
tcx.check_coroutine_obligations(def)?;

let input_body: &Body<'_> = &input_body.borrow();
if let Some(guar) = input_body.tainted_by_errors {
debug!("Skipping borrowck because of tainted body");
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_no_implicit_autorefs]`
RustcNoImplicitAutorefs,

/// Represents `#[rustc_no_implicit_bounds]`
RustcNoImplicitBounds,

/// Represents `#[rustc_non_const_trait_method]`.
RustcNonConstTraitMethod,

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl AttributeKind {
RustcMustImplementOneOf { .. } => No,
RustcNeverReturnsNullPointer => Yes,
RustcNoImplicitAutorefs => Yes,
RustcNoImplicitBounds => No,
RustcNonConstTraitMethod => No, // should be reported via other queries like `constness`
RustcNounwind => No,
RustcObjcClass { .. } => No,
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::codes::*;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
use rustc_hir::PolyTraitRef;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_hir::{PolyTraitRef, find_attr};
use rustc_middle::bug;
use rustc_middle::ty::{
self as ty, IsSuggestable, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
TypeVisitor, Upcast,
};
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
use rustc_span::{ErrorGuaranteed, Ident, Span, kw};
use rustc_trait_selection::traits;
use smallvec::SmallVec;
use tracing::{debug, instrument};
Expand Down Expand Up @@ -170,7 +171,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx();

// Skip adding any default bounds if `#![rustc_no_implicit_bounds]`
if tcx.has_attr(CRATE_DEF_ID, sym::rustc_no_implicit_bounds) {
if find_attr!(tcx.get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcNoImplicitBounds) {
return;
}

Expand Down Expand Up @@ -284,7 +285,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
context: ImpliedBoundsContext<'tcx>,
) -> bool {
let collected = collect_bounds(hir_bounds, context, trait_def_id);
!self.tcx().has_attr(CRATE_DEF_ID, sym::rustc_no_implicit_bounds) && !collected.any()
!find_attr!(self.tcx().get_all_attrs(CRATE_DEF_ID), AttributeKind::RustcNoImplicitBounds)
&& !collected.any()
}

fn reject_duplicate_relaxed_bounds(&self, relaxed_bounds: SmallVec<[&PolyTraitRef<'_>; 1]>) {
Expand Down
18 changes: 7 additions & 11 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,18 +1116,14 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
{
tcx.ensure_ok().mir_drops_elaborated_and_const_checked(def_id);
}
if tcx.is_coroutine(def_id.to_def_id()) {
tcx.ensure_ok().mir_coroutine_witnesses(def_id);
let _ = tcx.ensure_ok().check_coroutine_obligations(
tcx.typeck_root_def_id(def_id.to_def_id()).expect_local(),
if tcx.is_coroutine(def_id.to_def_id())
&& (!tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()))
{
// Eagerly check the unsubstituted layout for cycles.
tcx.ensure_ok().layout_of(
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
);
if !tcx.is_async_drop_in_place_coroutine(def_id.to_def_id()) {
// Eagerly check the unsubstituted layout for cycles.
tcx.ensure_ok().layout_of(
ty::TypingEnv::post_analysis(tcx, def_id.to_def_id())
.as_query_input(tcx.type_of(def_id).instantiate_identity()),
);
}
}
});
});
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/ty/context/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub struct ImplicitCtxt<'a, 'tcx> {
/// The current `TyCtxt`.
pub tcx: TyCtxt<'tcx>,

/// The current query job, if any. This is updated by `JobOwner::start` in
/// `ty::query::plumbing` when executing a query.
/// The current query job, if any.
pub query: Option<QueryJobId>,

/// Used to prevent queries from calling too deeply.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::RustcMir(_)
| AttributeKind::RustcNeverReturnsNullPointer
| AttributeKind::RustcNoImplicitAutorefs
| AttributeKind::RustcNoImplicitBounds
| AttributeKind::RustcNonConstTraitMethod
| AttributeKind::RustcNounwind
| AttributeKind::RustcObjcClass { .. }
Expand Down Expand Up @@ -413,7 +414,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
// crate-level attrs, are checked below
| sym::feature
| sym::register_tool
| sym::rustc_no_implicit_bounds
| sym::test_runner,
..
] => {}
Expand Down
40 changes: 23 additions & 17 deletions compiler/rustc_query_impl/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ pub(crate) fn gather_active_jobs_inner<'tcx, K: Copy>(
Some(())
}

/// A type representing the responsibility to execute the job in the `job` field.
/// This will poison the relevant query if dropped.
struct JobOwner<'tcx, K>
/// Guard object representing the responsibility to execute a query job and
/// mark it as completed.
///
/// This will poison the relevant query key if it is dropped without calling
/// [`Self::complete`].
struct ActiveJobGuard<'tcx, K>
where
K: Eq + Hash + Copy,
{
state: &'tcx QueryState<'tcx, K>,
key: K,
key_hash: u64,
}

#[cold]
Expand Down Expand Up @@ -137,20 +141,19 @@ fn handle_cycle_error<'tcx, C: QueryCache, const FLAGS: QueryFlags>(
}
}

impl<'tcx, K> JobOwner<'tcx, K>
impl<'tcx, K> ActiveJobGuard<'tcx, K>
where
K: Eq + Hash + Copy,
{
/// Completes the query by updating the query cache with the `result`,
/// signals the waiter and forgets the JobOwner, so it won't poison the query
fn complete<C>(self, cache: &C, key_hash: u64, result: C::Value, dep_node_index: DepNodeIndex)
/// signals the waiter, and forgets the guard so it won't poison the query.
fn complete<C>(self, cache: &C, result: C::Value, dep_node_index: DepNodeIndex)
where
C: QueryCache<Key = K>,
{
let key = self.key;
let state = self.state;

// Forget ourself so our destructor won't poison the query
// Forget ourself so our destructor won't poison the query.
// (Extract fields by value first to make sure we don't leak anything.)
let Self { state, key, key_hash }: Self = self;
mem::forget(self);

// Mark as complete before we remove the job from the active state
Expand All @@ -174,19 +177,18 @@ where
}
}

impl<'tcx, K> Drop for JobOwner<'tcx, K>
impl<'tcx, K> Drop for ActiveJobGuard<'tcx, K>
where
K: Eq + Hash + Copy,
{
#[inline(never)]
#[cold]
fn drop(&mut self) {
// Poison the query so jobs waiting on it panic.
let state = self.state;
let Self { state, key, key_hash } = *self;
let job = {
let key_hash = sharded::make_hash(&self.key);
let mut shard = state.active.lock_shard_by_hash(key_hash);
match shard.find_entry(key_hash, equivalent_key(&self.key)) {
match shard.find_entry(key_hash, equivalent_key(&key)) {
Err(_) => panic!(),
Ok(occupied) => {
let ((key, value), vacant) = occupied.remove();
Expand Down Expand Up @@ -342,11 +344,13 @@ fn execute_job<'tcx, C: QueryCache, const FLAGS: QueryFlags, const INCR: bool>(
id: QueryJobId,
dep_node: Option<DepNode>,
) -> (C::Value, Option<DepNodeIndex>) {
// Use `JobOwner` so the query will be poisoned if executing it panics.
let job_owner = JobOwner { state, key };
// Set up a guard object that will automatically poison the query if a
// panic occurs while executing the query (or any intermediate plumbing).
let job_guard = ActiveJobGuard { state, key, key_hash };

debug_assert_eq!(qcx.tcx.dep_graph.is_fully_enabled(), INCR);

// Delegate to another function to actually execute the query job.
let (result, dep_node_index) = if INCR {
execute_job_incr(query, qcx, qcx.tcx.dep_graph.data().unwrap(), key, dep_node, id)
} else {
Expand Down Expand Up @@ -388,7 +392,9 @@ fn execute_job<'tcx, C: QueryCache, const FLAGS: QueryFlags, const INCR: bool>(
}
}
}
job_owner.complete(cache, key_hash, result, dep_node_index);

// Tell the guard to perform completion bookkeeping, and also to not poison the query.
job_guard.complete(cache, result, dep_node_index);

(result, Some(dep_node_index))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ pub(crate) fn target() -> Target {
pre_link_args,
post_link_args,
relocation_model: RelocModel::Pic,
// crt_static should always be true for an executable and always false
// for a shared library. There is no easy way to indicate this and it
// doesn't seem to matter much so we set crt_static_allows_dylibs to
// true and leave crt_static as true when linking dynamic libraries.
// wasi also sets crt_static_allows_dylibs: true so this is at least
// aligned between wasm targets.
crt_static_respected: true,
crt_static_default: true,
crt_static_allows_dylibs: true,
panic_strategy: PanicStrategy::Unwind,
no_default_libraries: false,
families: cvs!["unix", "wasm"],
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_trait_selection/src/traits/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_span::DUMMY_SP;
use smallvec::{SmallVec, smallvec};
use tracing::debug;

use crate::traits::{impossible_predicates, is_vtable_safe_method};
use crate::traits::is_vtable_safe_method;

#[derive(Clone, Debug)]
pub enum VtblSegment<'tcx> {
Expand Down Expand Up @@ -271,11 +271,7 @@ fn vtable_entries<'tcx>(
// do not hold for this particular set of type parameters.
// Note that this method could then never be called, so we
// do not want to try and codegen it, in that case (see #23435).
let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, args);
if impossible_predicates(
tcx,
predicates.map(|(predicate, _)| predicate).collect(),
) {
if tcx.instantiate_and_check_impossible_predicates((def_id, args)) {
debug!("vtable_entries: predicates do not hold");
return VtblEntry::Vacant;
}
Expand Down
24 changes: 24 additions & 0 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,30 @@ impl<T: CoerceUnsized<U>, U> CoerceUnsized<Cell<U>> for Cell<T> {}
#[unstable(feature = "dispatch_from_dyn", issue = "none")]
impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Cell<U>> for Cell<T> {}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsRef<[Cell<T>; N]> for Cell<[T; N]> {
#[inline]
fn as_ref(&self) -> &[Cell<T>; N] {
self.as_array_of_cells()
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsRef<[Cell<T>]> for Cell<[T; N]> {
#[inline]
fn as_ref(&self) -> &[Cell<T>] {
&*self.as_array_of_cells()
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T> AsRef<[Cell<T>]> for Cell<[T]> {
#[inline]
fn as_ref(&self) -> &[Cell<T>] {
self.as_slice_of_cells()
}
}

impl<T> Cell<[T]> {
/// Returns a `&[Cell<T>]` from a `&Cell<[T]>`
///
Expand Down
50 changes: 50 additions & 0 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,56 @@ impl<T, const N: usize> MaybeUninit<[T; N]> {
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> From<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]> {
#[inline]
fn from(arr: [MaybeUninit<T>; N]) -> Self {
arr.transpose()
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsRef<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]> {
#[inline]
fn as_ref(&self) -> &[MaybeUninit<T>; N] {
// SAFETY: T and MaybeUninit<T> have the same layout
unsafe { &*ptr::from_ref(self).cast() }
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsRef<[MaybeUninit<T>]> for MaybeUninit<[T; N]> {
#[inline]
fn as_ref(&self) -> &[MaybeUninit<T>] {
&*AsRef::<[MaybeUninit<T>; N]>::as_ref(self)
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsMut<[MaybeUninit<T>; N]> for MaybeUninit<[T; N]> {
#[inline]
fn as_mut(&mut self) -> &mut [MaybeUninit<T>; N] {
// SAFETY: T and MaybeUninit<T> have the same layout
unsafe { &mut *ptr::from_mut(self).cast() }
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> AsMut<[MaybeUninit<T>]> for MaybeUninit<[T; N]> {
#[inline]
fn as_mut(&mut self) -> &mut [MaybeUninit<T>] {
&mut *AsMut::<[MaybeUninit<T>; N]>::as_mut(self)
}
}

#[stable(feature = "more_conversion_trait_impls", since = "CURRENT_RUSTC_VERSION")]
impl<T, const N: usize> From<MaybeUninit<[T; N]>> for [MaybeUninit<T>; N] {
#[inline]
fn from(arr: MaybeUninit<[T; N]>) -> Self {
arr.transpose()
}
}

impl<T, const N: usize> [MaybeUninit<T>; N] {
/// Transposes a `[MaybeUninit<T>; N]` into a `MaybeUninit<[T; N]>`.
///
Expand Down
Loading
Loading