fix: Move CoerceShared into ops

This commit is contained in:
Aapo Alasuutari
2025-09-15 20:32:06 +03:00
parent 35bae9df1d
commit c4a87eb62c
7 changed files with 20 additions and 15 deletions
-9
View File
@@ -1372,12 +1372,3 @@ pub trait CoercePointeeValidated {
pub trait Reborrow {
// Empty.
}
/// Allows reborrowable value to be reborrowed as shared, creating a copy of
/// that disables the source for writes for the lifetime of the copy.
#[lang = "coerce_shared"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait CoerceShared: Reborrow {
/// The type of this value when reborrowed as shared.
type Target: Copy;
}
+3
View File
@@ -149,6 +149,7 @@
mod index;
mod index_range;
mod range;
mod reborrow;
mod try_trait;
mod unsize;
@@ -189,6 +190,8 @@
pub use self::range::{OneSidedRange, OneSidedRangeBound};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
#[unstable(feature = "reborrow", issue = "145612")]
pub use self::reborrow::CoerceShared;
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
pub use self::try_trait::Residual;
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
+10
View File
@@ -0,0 +1,10 @@
use crate::marker::Reborrow;
/// Allows reborrowable value to be reborrowed as shared, creating a copy
/// that disables the source for writes for the lifetime of the copy.
#[lang = "coerce_shared"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait CoerceShared: Reborrow {
/// The type of this value when reborrowed as shared.
type Target: Copy;
}
@@ -1,3 +1,3 @@
use std::marker::CoerceShared; //~ ERROR use of unstable library feature `reborrow`
use std::ops::CoerceShared; //~ ERROR use of unstable library feature `reborrow`
fn main() {}
@@ -1,8 +1,8 @@
error[E0658]: use of unstable library feature `reborrow`
--> $DIR/feature-gate-reborrow-coerce-shared.rs:1:5
|
LL | use std::marker::CoerceShared;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | use std::ops::CoerceShared;
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #145612 <https://github.com/rust-lang/rust/issues/145612> for more information
= help: add `#![feature(reborrow)]` to the crate attributes to enable
@@ -1,5 +1,6 @@
#![feature(reborrow)]
use std::marker::{Reborrow, CoerceShared};
use std::marker::Reborrow;
use std::ops::CoerceShared;
struct CustomMut<'a, T>(&'a mut T);
impl<'a, T> Reborrow for CustomMut<'a, T> {}
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/custom_mut_coerce_shared.rs:23:12
--> $DIR/custom_mut_coerce_shared.rs:24:12
|
LL | method(a);
| ------ ^ expected `CustomRef<'_, ()>`, found `CustomMut<'_, ()>`
@@ -9,7 +9,7 @@ LL | method(a);
= note: expected struct `CustomRef<'_, ()>`
found struct `CustomMut<'_, ()>`
note: function defined here
--> $DIR/custom_mut_coerce_shared.rs:19:4
--> $DIR/custom_mut_coerce_shared.rs:20:4
|
LL | fn method(a: CustomRef<'_, ()>) {}
| ^^^^^^ --------------------