Skip to content

Commit e88fa08

Browse files
committed
move Reborrow to ops, fix fmt issues
1 parent c4a87eb commit e88fa08

13 files changed

+21
-25
lines changed

library/core/src/marker.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,11 +1364,3 @@ pub macro CoercePointee($item:item) {
13641364
pub trait CoercePointeeValidated {
13651365
/* compiler built-in */
13661366
}
1367-
1368-
/// Allows value to be reborrowed as exclusive, creating a copy of the value
1369-
/// that disables the source for reads and writes for the lifetime of the copy.
1370-
#[lang = "reborrow"]
1371-
#[unstable(feature = "reborrow", issue = "145612")]
1372-
pub trait Reborrow {
1373-
// Empty.
1374-
}

library/core/src/ops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub use self::range::{OneSidedRange, OneSidedRangeBound};
191191
#[stable(feature = "rust1", since = "1.0.0")]
192192
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
193193
#[unstable(feature = "reborrow", issue = "145612")]
194-
pub use self::reborrow::CoerceShared;
194+
pub use self::reborrow::{CoerceShared, Reborrow};
195195
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
196196
pub use self::try_trait::Residual;
197197
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]

library/core/src/ops/reborrow.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
use crate::marker::Reborrow;
1+
/// Allows value to be reborrowed as exclusive, creating a copy of the value
2+
/// that disables the source for reads and writes for the lifetime of the copy.
3+
#[lang = "reborrow"]
4+
#[unstable(feature = "reborrow", issue = "145612")]
5+
pub trait Reborrow {
6+
// Empty.
7+
}
28

39
/// Allows reborrowable value to be reborrowed as shared, creating a copy
410
/// that disables the source for writes for the lifetime of the copy.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
use std::marker::Reborrow; //~ ERROR use of unstable library feature `reborrow`
1+
use std::ops::Reborrow; //~ ERROR use of unstable library feature `reborrow`
22

33
fn main() {}

tests/ui/feature-gates/feature-gate-reborrow.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.rs:1:5
33
|
4-
LL | use std::marker::Reborrow;
5-
| ^^^^^^^^^^^^^^^^^^^^^
4+
LL | use std::ops::Reborrow;
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.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![feature(reborrow)]
2-
use std::marker::Reborrow;
2+
use std::ops::Reborrow;
33

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

tests/ui/reborrow/custom_mut_coerce_shared.rs

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

54
struct CustomMut<'a, T>(&'a mut T);
65
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:24:12
2+
--> $DIR/custom_mut_coerce_shared.rs:23: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:20:4
12+
--> $DIR/custom_mut_coerce_shared.rs:19:4
1313
|
1414
LL | fn method(a: CustomRef<'_, ()>) {}
1515
| ^^^^^^ --------------------

tests/ui/reborrow/option_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn method(a: Option<& mut ()>) {}
1+
fn method(a: Option<&mut ()>) {}
22

33
fn main() {
44
let a = Some(&mut ());

tests/ui/reborrow/option_mut.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | let _ = method(a);
1111
note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
1212
--> $DIR/option_mut.rs:1:14
1313
|
14-
LL | fn method(a: Option<& mut ()>) {}
15-
| ------ ^^^^^^^^^^^^^^^^ this parameter takes ownership of the value
14+
LL | fn method(a: Option<&mut ()>) {}
15+
| ------ ^^^^^^^^^^^^^^^ this parameter takes ownership of the value
1616
| |
1717
| in this function
1818

0 commit comments

Comments
 (0)