Skip to content

Commit c4a87eb

Browse files
committed
fix: Move CoerceShared into ops
1 parent 35bae9d commit c4a87eb

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

library/core/src/marker.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,12 +1372,3 @@ pub trait CoercePointeeValidated {
13721372
pub trait Reborrow {
13731373
// Empty.
13741374
}
1375-
1376-
/// Allows reborrowable value to be reborrowed as shared, creating a copy of
1377-
/// that disables the source for writes for the lifetime of the copy.
1378-
#[lang = "coerce_shared"]
1379-
#[unstable(feature = "reborrow", issue = "145612")]
1380-
pub trait CoerceShared: Reborrow {
1381-
/// The type of this value when reborrowed as shared.
1382-
type Target: Copy;
1383-
}

library/core/src/ops/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ mod function;
149149
mod index;
150150
mod index_range;
151151
mod range;
152+
mod reborrow;
152153
mod try_trait;
153154
mod unsize;
154155

@@ -189,6 +190,8 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
189190
pub use self::range::{OneSidedRange, OneSidedRangeBound};
190191
#[stable(feature = "rust1", since = "1.0.0")]
191192
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
193+
#[unstable(feature = "reborrow", issue = "145612")]
194+
pub use self::reborrow::CoerceShared;
192195
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
193196
pub use self::try_trait::Residual;
194197
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]

library/core/src/ops/reborrow.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use crate::marker::Reborrow;
2+
3+
/// Allows reborrowable value to be reborrowed as shared, creating a copy
4+
/// that disables the source for writes for the lifetime of the copy.
5+
#[lang = "coerce_shared"]
6+
#[unstable(feature = "reborrow", issue = "145612")]
7+
pub trait CoerceShared: Reborrow {
8+
/// The type of this value when reborrowed as shared.
9+
type Target: Copy;
10+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use std::marker::CoerceShared; //~ ERROR use of unstable library feature `reborrow`
1+
use std::ops::CoerceShared; //~ ERROR use of unstable library feature `reborrow`
22

33
fn main() {}

tests/ui/feature-gates/feature-gate-reborrow-coerce-shared.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: use of unstable library feature `reborrow`
22
--> $DIR/feature-gate-reborrow-coerce-shared.rs:1:5
33
|
4-
LL | use std::marker::CoerceShared;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | use std::ops::CoerceShared;
5+
| ^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: see issue #145612 <https://github.com/rust-lang/rust/issues/145612> for more information
88
= help: add `#![feature(reborrow)]` to the crate attributes to enable

tests/ui/reborrow/custom_mut_coerce_shared.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(reborrow)]
2-
use std::marker::{Reborrow, CoerceShared};
2+
use std::marker::Reborrow;
3+
use std::ops::CoerceShared;
34

45
struct CustomMut<'a, T>(&'a mut T);
56
impl<'a, T> Reborrow for CustomMut<'a, T> {}

tests/ui/reborrow/custom_mut_coerce_shared.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/custom_mut_coerce_shared.rs:23:12
2+
--> $DIR/custom_mut_coerce_shared.rs:24:12
33
|
44
LL | method(a);
55
| ------ ^ expected `CustomRef<'_, ()>`, found `CustomMut<'_, ()>`
@@ -9,7 +9,7 @@ LL | method(a);
99
= note: expected struct `CustomRef<'_, ()>`
1010
found struct `CustomMut<'_, ()>`
1111
note: function defined here
12-
--> $DIR/custom_mut_coerce_shared.rs:19:4
12+
--> $DIR/custom_mut_coerce_shared.rs:20:4
1313
|
1414
LL | fn method(a: CustomRef<'_, ()>) {}
1515
| ^^^^^^ --------------------

0 commit comments

Comments
 (0)