move Reborrow to ops, fix fmt issues

This commit is contained in:
Aapo Alasuutari 2025-09-27 01:11:01 +03:00
parent c4a87eb62c
commit e88fa086fb
13 changed files with 21 additions and 25 deletions

View file

@ -1364,11 +1364,3 @@ pub macro CoercePointee($item:item) {
pub trait CoercePointeeValidated {
/* compiler built-in */
}
/// Allows value to be reborrowed as exclusive, creating a copy of the value
/// that disables the source for reads and writes for the lifetime of the copy.
#[lang = "reborrow"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait Reborrow {
// Empty.
}

View file

@ -191,7 +191,7 @@ 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;
pub use self::reborrow::{CoerceShared, Reborrow};
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
pub use self::try_trait::Residual;
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]

View file

@ -1,4 +1,10 @@
use crate::marker::Reborrow;
/// Allows value to be reborrowed as exclusive, creating a copy of the value
/// that disables the source for reads and writes for the lifetime of the copy.
#[lang = "reborrow"]
#[unstable(feature = "reborrow", issue = "145612")]
pub trait Reborrow {
// Empty.
}
/// Allows reborrowable value to be reborrowed as shared, creating a copy
/// that disables the source for writes for the lifetime of the copy.

View file

@ -1,3 +1,3 @@
use std::marker::Reborrow; //~ ERROR use of unstable library feature `reborrow`
use std::ops::Reborrow; //~ ERROR use of unstable library feature `reborrow`
fn main() {}

View file

@ -1,8 +1,8 @@
error[E0658]: use of unstable library feature `reborrow`
--> $DIR/feature-gate-reborrow.rs:1:5
|
LL | use std::marker::Reborrow;
| ^^^^^^^^^^^^^^^^^^^^^
LL | use std::ops::Reborrow;
| ^^^^^^^^^^^^^^^^^^
|
= 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

View file

@ -1,5 +1,5 @@
#![feature(reborrow)]
use std::marker::Reborrow;
use std::ops::Reborrow;
struct CustomMut<'a, T>(&'a mut T);
impl<'a, T> Reborrow for CustomMut<'a, T> {}

View file

@ -1,6 +1,5 @@
#![feature(reborrow)]
use std::marker::Reborrow;
use std::ops::CoerceShared;
use std::ops::{CoerceShared, Reborrow};
struct CustomMut<'a, T>(&'a mut T);
impl<'a, T> Reborrow for CustomMut<'a, T> {}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/custom_mut_coerce_shared.rs:24:12
--> $DIR/custom_mut_coerce_shared.rs:23: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:20:4
--> $DIR/custom_mut_coerce_shared.rs:19:4
|
LL | fn method(a: CustomRef<'_, ()>) {}
| ^^^^^^ --------------------

View file

@ -1,4 +1,4 @@
fn method(a: Option<& mut ()>) {}
fn method(a: Option<&mut ()>) {}
fn main() {
let a = Some(&mut ());

View file

@ -11,8 +11,8 @@ LL | let _ = method(a);
note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
--> $DIR/option_mut.rs:1:14
|
LL | fn method(a: Option<& mut ()>) {}
| ------ ^^^^^^^^^^^^^^^^ this parameter takes ownership of the value
LL | fn method(a: Option<&mut ()>) {}
| ------ ^^^^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function

View file

@ -1,6 +1,6 @@
use std::pin::Pin;
fn method(a: Pin<& mut ()>) {}
fn method(a: Pin<&mut ()>) {}
fn main() {
let a = &mut ();

View file

@ -11,8 +11,8 @@ LL | let _ = method(a);
note: consider changing this parameter type in function `method` to borrow instead if owning the value isn't necessary
--> $DIR/pin_mut.rs:3:14
|
LL | fn method(a: Pin<& mut ()>) {}
| ------ ^^^^^^^^^^^^^ this parameter takes ownership of the value
LL | fn method(a: Pin<&mut ()>) {}
| ------ ^^^^^^^^^^^^ this parameter takes ownership of the value
| |
| in this function

View file

@ -10,5 +10,4 @@ fn main() {
//~| NOTE arguments to this function are incorrect
//~| NOTE types differ in mutability
//~| NOTE expected struct `Pin<&()>`
//~| NOTE found struct `Pin<&mut ()>`
}