authorbors <bors@rust-lang.org> 2026-05-24 06:29:32 UTC
committerbors <bors@rust-lang.org> 2026-05-24 06:29:32 UTC
log06b13d50ca813d84d93fcddbaaef069011b16fbb
tree49824ffbdc0299eb0cbfdda80ccbdbb3218157e6
parente1ff77d89857bfbf7ce8eefe09b450a7ed5c67ca
parent28436418fa73de65fe3c1b04d80451066223b87a

Auto merge of #156870 - JonathanBrouwer:rollup-PbM4nVA, r=JonathanBrouwer

Rollup of 6 pull requests Successful merges: - rust-lang/rust#156769 (Use print instead of po in debuginfo path test) - rust-lang/rust#156784 (Fix reborrow_info early return skipping field validation) - rust-lang/rust#156827 (float_literal_f32_fallback: Don't suggest invalid code) - rust-lang/rust#156828 (Add unstable Share trait) - rust-lang/rust#156830 (Add `#[doc(alias = "phi")]` for float `GOLDEN_RATIO` constants) - rust-lang/rust#156860 (Fix Pieter-Louis Schoeman mailmap entry)

35 files changed, 542 insertions(+), 14 deletions(-)

.mailmap+1
...@@ -569,6 +569,7 @@ Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de>...@@ -569,6 +569,7 @@ Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de>
569phosphorus <steepout@qq.com>569phosphorus <steepout@qq.com>
570Pierre Krieger <pierre.krieger1708@gmail.com>570Pierre Krieger <pierre.krieger1708@gmail.com>
571pierwill <pierwill@users.noreply.github.com> <19642016+pierwill@users.noreply.github.com>571pierwill <pierwill@users.noreply.github.com> <19642016+pierwill@users.noreply.github.com>
572Pieter-Louis Schoeman <pl.schoeman44@gmail.com> <127837395+P8L1@users.noreply.github.com>
572Pietro Albini <pietro@pietroalbini.org> <pietro@pietroalbini.io>573Pietro Albini <pietro@pietroalbini.org> <pietro@pietroalbini.io>
573Pietro Albini <pietro@pietroalbini.org> <pietro.albini@ferrous-systems.com>574Pietro Albini <pietro@pietroalbini.org> <pietro.albini@ferrous-systems.com>
574Pradyumna Rahul <prkinformed@gmail.com>575Pradyumna Rahul <prkinformed@gmail.com>
compiler/rustc_hir_analysis/src/coherence/builtin.rs+2-2
...@@ -563,8 +563,8 @@ pub(crate) fn reborrow_info<'tcx>(...@@ -563,8 +563,8 @@ pub(crate) fn reborrow_info<'tcx>(
563 )563 )
564 .is_ok()564 .is_ok()
565 {565 {
566 // Field implements Reborrow.566 // Field implements Reborrow, check remaining fields.
567 return Ok(());567 continue;
568 }568 }
569569
570 // Field does not implement Reborrow: it must be Copy.570 // Field does not implement Reborrow: it must be Copy.
compiler/rustc_hir_typeck/src/fallback.rs+7-1
...@@ -171,7 +171,13 @@ impl<'tcx> FnCtxt<'_, 'tcx> {...@@ -171,7 +171,13 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
171 .inspect(|vid| {171 .inspect(|vid| {
172 let origin = self.float_var_origin(*vid);172 let origin = self.float_var_origin(*vid);
173 // Show the entire literal in the suggestion to make it clearer.173 // Show the entire literal in the suggestion to make it clearer.
174 let literal = self.tcx.sess.source_map().span_to_snippet(origin.span).ok();174 let mut literal = self.tcx.sess.source_map().span_to_snippet(origin.span).ok();
175 // A `.` at the end of the literal is no longer necessary if `f32` is explicitly specified
176 if let Some(ref mut literal) = literal
177 && literal.ends_with('.')
178 {
179 literal.pop();
180 }
175 self.tcx.emit_node_span_lint(181 self.tcx.emit_node_span_lint(
176 FLOAT_LITERAL_F32_FALLBACK,182 FLOAT_LITERAL_F32_FALLBACK,
177 origin.lint_id.unwrap_or(CRATE_HIR_ID),183 origin.lint_id.unwrap_or(CRATE_HIR_ID),
library/alloc/src/lib.rs+1
...@@ -144,6 +144,7 @@...@@ -144,6 +144,7 @@
144#![feature(ptr_metadata)]144#![feature(ptr_metadata)]
145#![feature(rev_into_inner)]145#![feature(rev_into_inner)]
146#![feature(set_ptr_value)]146#![feature(set_ptr_value)]
147#![feature(share_trait)]
147#![feature(sized_type_properties)]148#![feature(sized_type_properties)]
148#![feature(slice_from_ptr_range)]149#![feature(slice_from_ptr_range)]
149#![feature(slice_index_methods)]150#![feature(slice_index_methods)]
library/alloc/src/rc.rs+4-1
...@@ -245,7 +245,7 @@ use core::any::Any;...@@ -245,7 +245,7 @@ use core::any::Any;
245use core::cell::{Cell, CloneFromCell};245use core::cell::{Cell, CloneFromCell};
246#[cfg(not(no_global_oom_handling))]246#[cfg(not(no_global_oom_handling))]
247use core::clone::TrivialClone;247use core::clone::TrivialClone;
248use core::clone::{CloneToUninit, UseCloned};248use core::clone::{CloneToUninit, Share, UseCloned};
249use core::cmp::Ordering;249use core::cmp::Ordering;
250use core::hash::{Hash, Hasher};250use core::hash::{Hash, Hasher};
251use core::intrinsics::abort;251use core::intrinsics::abort;
...@@ -2525,6 +2525,9 @@ impl<T: ?Sized, A: Allocator + Clone> Clone for Rc<T, A> {...@@ -2525,6 +2525,9 @@ impl<T: ?Sized, A: Allocator + Clone> Clone for Rc<T, A> {
2525#[unstable(feature = "ergonomic_clones", issue = "132290")]2525#[unstable(feature = "ergonomic_clones", issue = "132290")]
2526impl<T: ?Sized, A: Allocator + Clone> UseCloned for Rc<T, A> {}2526impl<T: ?Sized, A: Allocator + Clone> UseCloned for Rc<T, A> {}
25272527
2528#[unstable(feature = "share_trait", issue = "156756")]
2529impl<T: ?Sized, A: Allocator + Clone> Share for Rc<T, A> {}
2530
2528#[cfg(not(no_global_oom_handling))]2531#[cfg(not(no_global_oom_handling))]
2529#[stable(feature = "rust1", since = "1.0.0")]2532#[stable(feature = "rust1", since = "1.0.0")]
2530impl<T: Default> Default for Rc<T> {2533impl<T: Default> Default for Rc<T> {
library/alloc/src/sync.rs+4-1
...@@ -12,7 +12,7 @@ use core::any::Any;...@@ -12,7 +12,7 @@ use core::any::Any;
12use core::cell::CloneFromCell;12use core::cell::CloneFromCell;
13#[cfg(not(no_global_oom_handling))]13#[cfg(not(no_global_oom_handling))]
14use core::clone::TrivialClone;14use core::clone::TrivialClone;
15use core::clone::{CloneToUninit, UseCloned};15use core::clone::{CloneToUninit, Share, UseCloned};
16use core::cmp::Ordering;16use core::cmp::Ordering;
17use core::hash::{Hash, Hasher};17use core::hash::{Hash, Hasher};
18use core::intrinsics::abort;18use core::intrinsics::abort;
...@@ -2436,6 +2436,9 @@ impl<T: ?Sized, A: Allocator + Clone> Clone for Arc<T, A> {...@@ -2436,6 +2436,9 @@ impl<T: ?Sized, A: Allocator + Clone> Clone for Arc<T, A> {
2436#[unstable(feature = "ergonomic_clones", issue = "132290")]2436#[unstable(feature = "ergonomic_clones", issue = "132290")]
2437impl<T: ?Sized, A: Allocator + Clone> UseCloned for Arc<T, A> {}2437impl<T: ?Sized, A: Allocator + Clone> UseCloned for Arc<T, A> {}
24382438
2439#[unstable(feature = "share_trait", issue = "156756")]
2440impl<T: ?Sized, A: Allocator + Clone> Share for Arc<T, A> {}
2441
2439#[stable(feature = "rust1", since = "1.0.0")]2442#[stable(feature = "rust1", since = "1.0.0")]
2440impl<T: ?Sized, A: Allocator> Deref for Arc<T, A> {2443impl<T: ?Sized, A: Allocator> Deref for Arc<T, A> {
2441 type Target = T;2444 type Target = T;
library/core/src/clone.rs+88-1
...@@ -290,6 +290,90 @@ pub macro Clone($item:item) {...@@ -290,6 +290,90 @@ pub macro Clone($item:item) {
290 /* compiler built-in */290 /* compiler built-in */
291}291}
292292
293/// A trait for types whose [`Clone`] operation creates another alias to the same
294/// logical resource or shared state.
295///
296/// `Share` marks types where cloning creates another handle, reference, or alias
297/// to the same logical resource or shared state, rather than an independent owned
298/// value. The distinction is semantic, not cost-based: implementing `Share` does
299/// not merely mean that cloning is cheap, constant-time, allocation-free, or
300/// convenient.
301///
302/// Calling [`share`](Share::share) is equivalent to calling [`clone`](Clone::clone)
303/// for implementors, but communicates that the resulting value aliases the same
304/// underlying resource.
305///
306/// Shared references, `Rc<T>`, `Arc<T>`, `Sender<T>`, and `SyncSender<T>` are
307/// examples of types that can be shared this way. Types such as `Vec<T>`,
308/// `String`, and `Box<T>` are not `Share` even though they implement `Clone`,
309/// because cloning them creates another owned value rather than another handle
310/// to the same logical resource.
311///
312/// # Examples
313///
314/// ```
315/// #![feature(share_trait)]
316///
317/// use std::cell::Cell;
318/// use std::clone::Share;
319/// use std::rc::Rc;
320/// use std::sync::{
321/// Arc,
322/// atomic::{AtomicUsize, Ordering},
323/// };
324///
325/// let value = 1;
326/// let reference = &value;
327/// assert!(std::ptr::eq(reference, reference.share()));
328///
329/// let rc = Rc::new(Cell::new(2));
330/// let shared_rc = rc.share();
331/// assert!(Rc::ptr_eq(&rc, &shared_rc));
332/// shared_rc.set(3);
333/// assert_eq!(rc.get(), 3);
334///
335/// let arc = Arc::new(AtomicUsize::new(4));
336/// let shared_arc = arc.share();
337/// assert!(Arc::ptr_eq(&arc, &shared_arc));
338/// shared_arc.store(5, Ordering::Relaxed);
339/// assert_eq!(arc.load(Ordering::Relaxed), 5);
340/// ```
341///
342/// ```
343/// #![feature(share_trait)]
344///
345/// use std::clone::Share;
346/// use std::sync::mpsc::{channel, sync_channel};
347///
348/// let (sender, receiver) = channel();
349/// let shared_sender = sender.share();
350/// sender.send(1).unwrap();
351/// shared_sender.send(2).unwrap();
352///
353/// let mut received = [receiver.recv().unwrap(), receiver.recv().unwrap()];
354/// received.sort();
355/// assert_eq!(received, [1, 2]);
356///
357/// let (sync_sender, sync_receiver) = sync_channel(2);
358/// let shared_sync_sender = sync_sender.share();
359/// sync_sender.send(3).unwrap();
360/// shared_sync_sender.send(4).unwrap();
361///
362/// let mut received = [sync_receiver.recv().unwrap(), sync_receiver.recv().unwrap()];
363/// received.sort();
364/// assert_eq!(received, [3, 4]);
365/// ```
366#[unstable(feature = "share_trait", issue = "156756")]
367pub trait Share: Clone {
368 /// Creates another alias to the same underlying resource or shared state.
369 ///
370 /// This is equivalent to calling [`Clone::clone`].
371 #[unstable(feature = "share_trait", issue = "156756")]
372 fn share(&self) -> Self {
373 Clone::clone(self)
374 }
375}
376
293/// Trait for objects whose [`Clone`] impl is lightweight (e.g. reference-counted)377/// Trait for objects whose [`Clone`] impl is lightweight (e.g. reference-counted)
294///378///
295/// Cloning an object implementing this trait should in general:379/// Cloning an object implementing this trait should in general:
...@@ -601,7 +685,7 @@ unsafe impl CloneToUninit for crate::bstr::ByteStr {...@@ -601,7 +685,7 @@ unsafe impl CloneToUninit for crate::bstr::ByteStr {
601/// are implemented in `traits::SelectionContext::copy_clone_conditions()`685/// are implemented in `traits::SelectionContext::copy_clone_conditions()`
602/// in `rustc_trait_selection`.686/// in `rustc_trait_selection`.
603mod impls {687mod impls {
604 use super::TrivialClone;688 use super::{Share, TrivialClone};
605 use crate::marker::PointeeSized;689 use crate::marker::PointeeSized;
606690
607 macro_rules! impl_clone {691 macro_rules! impl_clone {
...@@ -689,6 +773,9 @@ mod impls {...@@ -689,6 +773,9 @@ mod impls {
689 #[rustc_const_unstable(feature = "const_clone", issue = "142757")]773 #[rustc_const_unstable(feature = "const_clone", issue = "142757")]
690 unsafe impl<T: PointeeSized> const TrivialClone for &T {}774 unsafe impl<T: PointeeSized> const TrivialClone for &T {}
691775
776 #[unstable(feature = "share_trait", issue = "156756")]
777 impl<T: PointeeSized> Share for &T {}
778
692 /// Shared references can be cloned, but mutable references *cannot*!779 /// Shared references can be cloned, but mutable references *cannot*!
693 #[stable(feature = "rust1", since = "1.0.0")]780 #[stable(feature = "rust1", since = "1.0.0")]
694 impl<T: PointeeSized> !Clone for &mut T {}781 impl<T: PointeeSized> !Clone for &mut T {}
library/core/src/num/f128.rs+1
...@@ -33,6 +33,7 @@ pub mod consts {...@@ -33,6 +33,7 @@ pub mod consts {
33 pub const TAU: f128 = 6.28318530717958647692528676655900576839433879875021164194989_f128;33 pub const TAU: f128 = 6.28318530717958647692528676655900576839433879875021164194989_f128;
3434
35 /// The golden ratio (φ)35 /// The golden ratio (φ)
36 #[doc(alias = "phi")]
36 #[unstable(feature = "f128", issue = "116909")]37 #[unstable(feature = "f128", issue = "116909")]
37 pub const GOLDEN_RATIO: f128 =38 pub const GOLDEN_RATIO: f128 =
38 1.61803398874989484820458683436563811772030917980576286213545_f128;39 1.61803398874989484820458683436563811772030917980576286213545_f128;
library/core/src/num/f16.rs+1
...@@ -35,6 +35,7 @@ pub mod consts {...@@ -35,6 +35,7 @@ pub mod consts {
35 pub const TAU: f16 = 6.28318530717958647692528676655900577_f16;35 pub const TAU: f16 = 6.28318530717958647692528676655900577_f16;
3636
37 /// The golden ratio (φ)37 /// The golden ratio (φ)
38 #[doc(alias = "phi")]
38 #[unstable(feature = "f16", issue = "116909")]39 #[unstable(feature = "f16", issue = "116909")]
39 pub const GOLDEN_RATIO: f16 = 1.618033988749894848204586834365638118_f16;40 pub const GOLDEN_RATIO: f16 = 1.618033988749894848204586834365638118_f16;
4041
library/core/src/num/f32.rs+1
...@@ -292,6 +292,7 @@ pub mod consts {...@@ -292,6 +292,7 @@ pub mod consts {
292 pub const TAU: f32 = 6.28318530717958647692528676655900577_f32;292 pub const TAU: f32 = 6.28318530717958647692528676655900577_f32;
293293
294 /// The golden ratio (φ)294 /// The golden ratio (φ)
295 #[doc(alias = "phi")]
295 #[stable(feature = "euler_gamma_golden_ratio", since = "1.94.0")]296 #[stable(feature = "euler_gamma_golden_ratio", since = "1.94.0")]
296 pub const GOLDEN_RATIO: f32 = 1.618033988749894848204586834365638118_f32;297 pub const GOLDEN_RATIO: f32 = 1.618033988749894848204586834365638118_f32;
297298
library/core/src/num/f64.rs+1
...@@ -292,6 +292,7 @@ pub mod consts {...@@ -292,6 +292,7 @@ pub mod consts {
292 pub const TAU: f64 = 6.28318530717958647692528676655900577_f64;292 pub const TAU: f64 = 6.28318530717958647692528676655900577_f64;
293293
294 /// The golden ratio (φ)294 /// The golden ratio (φ)
295 #[doc(alias = "phi")]
295 #[stable(feature = "euler_gamma_golden_ratio", since = "1.94.0")]296 #[stable(feature = "euler_gamma_golden_ratio", since = "1.94.0")]
296 pub const GOLDEN_RATIO: f64 = 1.618033988749894848204586834365638118_f64;297 pub const GOLDEN_RATIO: f64 = 1.618033988749894848204586834365638118_f64;
297298
library/std/src/lib.rs+1
...@@ -369,6 +369,7 @@...@@ -369,6 +369,7 @@
369#![feature(random)]369#![feature(random)]
370#![feature(raw_os_error_ty)]370#![feature(raw_os_error_ty)]
371#![feature(seek_io_take_position)]371#![feature(seek_io_take_position)]
372#![feature(share_trait)]
372#![feature(slice_internals)]373#![feature(slice_internals)]
373#![feature(slice_ptr_get)]374#![feature(slice_ptr_get)]
374#![feature(slice_range)]375#![feature(slice_range)]
library/std/src/sync/mpsc.rs+8
...@@ -142,6 +142,8 @@...@@ -142,6 +142,8 @@
142// not exposed publicly, but if you are curious about the implementation,142// not exposed publicly, but if you are curious about the implementation,
143// that's where everything is.143// that's where everything is.
144144
145use core::clone::Share;
146
145use crate::sync::mpmc;147use crate::sync::mpmc;
146use crate::time::{Duration, Instant};148use crate::time::{Duration, Instant};
147use crate::{error, fmt};149use crate::{error, fmt};
...@@ -645,6 +647,9 @@ impl<T> Clone for Sender<T> {...@@ -645,6 +647,9 @@ impl<T> Clone for Sender<T> {
645 }647 }
646}648}
647649
650#[unstable(feature = "share_trait", issue = "156756")]
651impl<T> Share for Sender<T> {}
652
648#[stable(feature = "mpsc_debug", since = "1.8.0")]653#[stable(feature = "mpsc_debug", since = "1.8.0")]
649impl<T> fmt::Debug for Sender<T> {654impl<T> fmt::Debug for Sender<T> {
650 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {655 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
...@@ -774,6 +779,9 @@ impl<T> Clone for SyncSender<T> {...@@ -774,6 +779,9 @@ impl<T> Clone for SyncSender<T> {
774 }779 }
775}780}
776781
782#[unstable(feature = "share_trait", issue = "156756")]
783impl<T> Share for SyncSender<T> {}
784
777#[stable(feature = "mpsc_debug", since = "1.8.0")]785#[stable(feature = "mpsc_debug", since = "1.8.0")]
778impl<T> fmt::Debug for SyncSender<T> {786impl<T> fmt::Debug for SyncSender<T> {
779 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {787 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
tests/debuginfo/path.rs-4
...@@ -8,12 +8,8 @@...@@ -8,12 +8,8 @@
88
9//@ lldb-command:print pathbuf9//@ lldb-command:print pathbuf
10//@ lldb-check:[...] "/some/path" { inner = "/some/path" { inner = { inner = size=10 { [0] = '/' [1] = 's' [2] = 'o' [3] = 'm' [4] = 'e' [5] = '/' [6] = 'p' [7] = 'a' [8] = 't' [9] = 'h' } } } }10//@ lldb-check:[...] "/some/path" { inner = "/some/path" { inner = { inner = size=10 { [0] = '/' [1] = 's' [2] = 'o' [3] = 'm' [4] = 'e' [5] = '/' [6] = 'p' [7] = 'a' [8] = 't' [9] = 'h' } } } }
11//@ lldb-command:po pathbuf
12//@ lldb-check:"/some/path"
13//@ lldb-command:print path11//@ lldb-command:print path
14//@ lldb-check:[...] "/some/path" { data_ptr = [...] length = 10 }12//@ lldb-check:[...] "/some/path" { data_ptr = [...] length = 10 }
15//@ lldb-command:po path
16//@ lldb-check:"/some/path"
1713
18use std::path::Path;14use std::path::Path;
1915
tests/ui/README.md+4
...@@ -1244,6 +1244,10 @@ In this directory, multiple crates are compiled, but some of them have `inline`...@@ -1244,6 +1244,10 @@ In this directory, multiple crates are compiled, but some of them have `inline`
12441244
1245Tests on name shadowing.1245Tests on name shadowing.
12461246
1247## `tests/ui/share-trait`
1248
1249Tests for the unstable `Share` trait.
1250
1247## `tests/ui/shell-argfiles/`: `-Z shell-argfiles` command line flag1251## `tests/ui/shell-argfiles/`: `-Z shell-argfiles` command line flag
12481252
1249The `-Zshell-argfiles` compiler flag allows argfiles to be parsed using POSIX "shell-style" quoting. When enabled, the compiler will use shlex to parse the arguments from argfiles specified with `@shell:<path>`.1253The `-Zshell-argfiles` compiler flag allows argfiles to be parsed using POSIX "shell-style" quoting. When enabled, the compiler will use shlex to parse the arguments from argfiles specified with `@shell:<path>`.
tests/ui/float/f32-into-f32.next-solver.fixed+3
...@@ -15,6 +15,9 @@ fn main() {...@@ -15,6 +15,9 @@ fn main() {
15 foo(1e5_f32);15 foo(1e5_f32);
16 //~^ WARN falling back to `f32`16 //~^ WARN falling back to `f32`
17 //~| WARN this was previously accepted17 //~| WARN this was previously accepted
18 foo(0_f32);
19 //~^ WARN falling back to `f32`
20 //~| WARN this was previously accepted
18 foo(4f32); // no warning21 foo(4f32); // no warning
19 let x = -4.0_f32;22 let x = -4.0_f32;
20 //~^ WARN falling back to `f32`23 //~^ WARN falling back to `f32`
tests/ui/float/f32-into-f32.next-solver.stderr+11-2
...@@ -27,7 +27,16 @@ LL | foo(1e5);...@@ -27,7 +27,16 @@ LL | foo(1e5);
27 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>27 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
2828
29warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied29warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied
30 --> $DIR/f32-into-f32.rs:19:1430 --> $DIR/f32-into-f32.rs:18:9
31 |
32LL | foo(0.);
33 | ^^ help: explicitly specify the type as `f32`: `0_f32`
34 |
35 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
37
38warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied
39 --> $DIR/f32-into-f32.rs:22:14
31 |40 |
32LL | let x = -4.0;41LL | let x = -4.0;
33 | ^^^ help: explicitly specify the type as `f32`: `4.0_f32`42 | ^^^ help: explicitly specify the type as `f32`: `4.0_f32`
...@@ -35,5 +44,5 @@ LL | let x = -4.0;...@@ -35,5 +44,5 @@ LL | let x = -4.0;
35 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!44 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>45 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
3746
38warning: 4 warnings emitted47warning: 5 warnings emitted
3948
tests/ui/float/f32-into-f32.old-solver.fixed+3
...@@ -15,6 +15,9 @@ fn main() {...@@ -15,6 +15,9 @@ fn main() {
15 foo(1e5_f32);15 foo(1e5_f32);
16 //~^ WARN falling back to `f32`16 //~^ WARN falling back to `f32`
17 //~| WARN this was previously accepted17 //~| WARN this was previously accepted
18 foo(0_f32);
19 //~^ WARN falling back to `f32`
20 //~| WARN this was previously accepted
18 foo(4f32); // no warning21 foo(4f32); // no warning
19 let x = -4.0_f32;22 let x = -4.0_f32;
20 //~^ WARN falling back to `f32`23 //~^ WARN falling back to `f32`
tests/ui/float/f32-into-f32.old-solver.stderr+11-2
...@@ -27,7 +27,16 @@ LL | foo(1e5);...@@ -27,7 +27,16 @@ LL | foo(1e5);
27 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>27 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
2828
29warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied29warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied
30 --> $DIR/f32-into-f32.rs:19:1430 --> $DIR/f32-into-f32.rs:18:9
31 |
32LL | foo(0.);
33 | ^^ help: explicitly specify the type as `f32`: `0_f32`
34 |
35 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
37
38warning: falling back to `f32` as the trait bound `f32: From<f64>` is not satisfied
39 --> $DIR/f32-into-f32.rs:22:14
31 |40 |
32LL | let x = -4.0;41LL | let x = -4.0;
33 | ^^^ help: explicitly specify the type as `f32`: `4.0_f32`42 | ^^^ help: explicitly specify the type as `f32`: `4.0_f32`
...@@ -35,5 +44,5 @@ LL | let x = -4.0;...@@ -35,5 +44,5 @@ LL | let x = -4.0;
35 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!44 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>45 = note: for more information, see issue #154024 <https://github.com/rust-lang/rust/issues/154024>
3746
38warning: 4 warnings emitted47warning: 5 warnings emitted
3948
tests/ui/float/f32-into-f32.rs+3
...@@ -15,6 +15,9 @@ fn main() {...@@ -15,6 +15,9 @@ fn main() {
15 foo(1e5);15 foo(1e5);
16 //~^ WARN falling back to `f32`16 //~^ WARN falling back to `f32`
17 //~| WARN this was previously accepted17 //~| WARN this was previously accepted
18 foo(0.);
19 //~^ WARN falling back to `f32`
20 //~| WARN this was previously accepted
18 foo(4f32); // no warning21 foo(4f32); // no warning
19 let x = -4.0;22 let x = -4.0;
20 //~^ WARN falling back to `f32`23 //~^ WARN falling back to `f32`
tests/ui/reborrow/reborrow_multi_field_validation.rs created+15
...@@ -0,0 +1,15 @@
1#![feature(reborrow)]
2
3use std::marker::Reborrow;
4
5// Regression test: `reborrow_info` must validate ALL data fields,
6// not just stop at the first Reborrow field.
7
8struct Bad<'a> {
9 first: &'a mut i32,
10 second: String, //~ ERROR the trait bound `String: Copy` is not satisfied
11}
12
13impl<'a> Reborrow for Bad<'a> {}
14
15fn main() {}
tests/ui/reborrow/reborrow_multi_field_validation.stderr created+9
...@@ -0,0 +1,9 @@
1error[E0277]: the trait bound `String: Copy` is not satisfied
2 --> $DIR/reborrow_multi_field_validation.rs:10:5
3 |
4LL | second: String,
5 | ^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
6
7error: aborting due to 1 previous error
8
9For more information about this error, try `rustc --explain E0277`.
tests/ui/share-trait/share-trait-arc.rs created+31
...@@ -0,0 +1,31 @@
1//@ run-pass
2
3#![feature(share_trait)]
4
5use std::clone::Share;
6use std::sync::{Arc, Mutex};
7
8trait Value {
9 fn get(&self) -> i32;
10}
11
12impl Value for Mutex<i32> {
13 fn get(&self) -> i32 {
14 *self.lock().unwrap()
15 }
16}
17
18fn main() {
19 let value = Arc::new(Mutex::new(1));
20 let shared = value.share();
21
22 assert!(Arc::ptr_eq(&value, &shared));
23 *shared.lock().unwrap() = 2;
24 assert_eq!(*value.lock().unwrap(), 2);
25
26 let dyn_value: Arc<dyn Value + Send + Sync> = Arc::new(Mutex::new(3));
27 let shared_dyn_value = dyn_value.share();
28
29 assert!(Arc::ptr_eq(&dyn_value, &shared_dyn_value));
30 assert_eq!(shared_dyn_value.get(), 3);
31}
tests/ui/share-trait/share-trait-mpsc-sender.rs created+19
...@@ -0,0 +1,19 @@
1//@ run-pass
2
3#![feature(share_trait)]
4
5use std::clone::Share;
6use std::sync::mpsc::channel;
7
8fn main() {
9 let (sender, receiver) = channel();
10 let shared_sender = sender.share();
11
12 sender.send(1).unwrap();
13 shared_sender.send(2).unwrap();
14
15 let mut received = [receiver.recv().unwrap(), receiver.recv().unwrap()];
16 received.sort();
17
18 assert_eq!(received, [1, 2]);
19}
tests/ui/share-trait/share-trait-mpsc-sync-sender.rs created+19
...@@ -0,0 +1,19 @@
1//@ run-pass
2
3#![feature(share_trait)]
4
5use std::clone::Share;
6use std::sync::mpsc::sync_channel;
7
8fn main() {
9 let (sender, receiver) = sync_channel(2);
10 let shared_sender = sender.share();
11
12 sender.send(1).unwrap();
13 shared_sender.send(2).unwrap();
14
15 let mut received = [receiver.recv().unwrap(), receiver.recv().unwrap()];
16 received.sort();
17
18 assert_eq!(received, [1, 2]);
19}
tests/ui/share-trait/share-trait-no-feature.rs created+20
...@@ -0,0 +1,20 @@
1use std::clone::Share;
2//~^ ERROR use of unstable library feature `share_trait`
3
4#[derive(Clone)]
5struct Alias;
6
7impl Share for Alias {}
8//~^ ERROR use of unstable library feature `share_trait`
9
10fn share_generic<T: Share>(value: &T) -> T {
11 //~^ ERROR use of unstable library feature `share_trait`
12 value.share()
13 //~^ ERROR use of unstable library feature `share_trait`
14}
15
16fn main() {
17 let value = Alias;
18 let _ = Share::share(&value);
19 //~^ ERROR use of unstable library feature `share_trait`
20}
tests/ui/share-trait/share-trait-no-feature.stderr created+53
...@@ -0,0 +1,53 @@
1error[E0658]: use of unstable library feature `share_trait`
2 --> $DIR/share-trait-no-feature.rs:1:5
3 |
4LL | use std::clone::Share;
5 | ^^^^^^^^^^^^^^^^^
6 |
7 = note: see issue #156756 <https://github.com/rust-lang/rust/issues/156756> for more information
8 = help: add `#![feature(share_trait)]` to the crate attributes to enable
9 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
11error[E0658]: use of unstable library feature `share_trait`
12 --> $DIR/share-trait-no-feature.rs:7:6
13 |
14LL | impl Share for Alias {}
15 | ^^^^^
16 |
17 = note: see issue #156756 <https://github.com/rust-lang/rust/issues/156756> for more information
18 = help: add `#![feature(share_trait)]` to the crate attributes to enable
19 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20
21error[E0658]: use of unstable library feature `share_trait`
22 --> $DIR/share-trait-no-feature.rs:10:21
23 |
24LL | fn share_generic<T: Share>(value: &T) -> T {
25 | ^^^^^
26 |
27 = note: see issue #156756 <https://github.com/rust-lang/rust/issues/156756> for more information
28 = help: add `#![feature(share_trait)]` to the crate attributes to enable
29 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30
31error[E0658]: use of unstable library feature `share_trait`
32 --> $DIR/share-trait-no-feature.rs:18:13
33 |
34LL | let _ = Share::share(&value);
35 | ^^^^^^^^^^^^
36 |
37 = note: see issue #156756 <https://github.com/rust-lang/rust/issues/156756> for more information
38 = help: add `#![feature(share_trait)]` to the crate attributes to enable
39 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40
41error[E0658]: use of unstable library feature `share_trait`
42 --> $DIR/share-trait-no-feature.rs:12:11
43 |
44LL | value.share()
45 | ^^^^^
46 |
47 = note: see issue #156756 <https://github.com/rust-lang/rust/issues/156756> for more information
48 = help: add `#![feature(share_trait)]` to the crate attributes to enable
49 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
50
51error: aborting due to 5 previous errors
52
53For more information about this error, try `rustc --explain E0658`.
tests/ui/share-trait/share-trait-non-implementors.rs created+19
...@@ -0,0 +1,19 @@
1#![feature(share_trait)]
2
3use std::clone::Share;
4
5fn require_share<T: Share>() {}
6
7fn main() {
8 require_share::<&mut i32>();
9 //~^ ERROR the trait bound `&mut i32: Share` is not satisfied
10
11 require_share::<String>();
12 //~^ ERROR the trait bound `String: Share` is not satisfied
13
14 require_share::<Vec<i32>>();
15 //~^ ERROR the trait bound `Vec<i32>: Share` is not satisfied
16
17 require_share::<Box<i32>>();
18 //~^ ERROR the trait bound `Box<i32>: Share` is not satisfied
19}
tests/ui/share-trait/share-trait-non-implementors.stderr created+76
...@@ -0,0 +1,76 @@
1error[E0277]: the trait bound `&mut i32: Share` is not satisfied
2 --> $DIR/share-trait-non-implementors.rs:8:21
3 |
4LL | require_share::<&mut i32>();
5 | ^^^^^^^^ the nightly-only, unstable trait `Share` is not implemented for `&mut i32`
6 |
7 = help: the following other types implement trait `Share`:
8 &T
9 Arc<T, A>
10 Rc<T, A>
11 SyncSender<T>
12 std::sync::mpsc::Sender<T>
13 = note: `Share` is implemented for `&i32`, but not for `&mut i32`
14note: required by a bound in `require_share`
15 --> $DIR/share-trait-non-implementors.rs:5:21
16 |
17LL | fn require_share<T: Share>() {}
18 | ^^^^^ required by this bound in `require_share`
19
20error[E0277]: the trait bound `String: Share` is not satisfied
21 --> $DIR/share-trait-non-implementors.rs:11:21
22 |
23LL | require_share::<String>();
24 | ^^^^^^ the nightly-only, unstable trait `Share` is not implemented for `String`
25 |
26 = help: the following other types implement trait `Share`:
27 &T
28 Arc<T, A>
29 Rc<T, A>
30 SyncSender<T>
31 std::sync::mpsc::Sender<T>
32note: required by a bound in `require_share`
33 --> $DIR/share-trait-non-implementors.rs:5:21
34 |
35LL | fn require_share<T: Share>() {}
36 | ^^^^^ required by this bound in `require_share`
37
38error[E0277]: the trait bound `Vec<i32>: Share` is not satisfied
39 --> $DIR/share-trait-non-implementors.rs:14:21
40 |
41LL | require_share::<Vec<i32>>();
42 | ^^^^^^^^ the nightly-only, unstable trait `Share` is not implemented for `Vec<i32>`
43 |
44 = help: the following other types implement trait `Share`:
45 &T
46 Arc<T, A>
47 Rc<T, A>
48 SyncSender<T>
49 std::sync::mpsc::Sender<T>
50note: required by a bound in `require_share`
51 --> $DIR/share-trait-non-implementors.rs:5:21
52 |
53LL | fn require_share<T: Share>() {}
54 | ^^^^^ required by this bound in `require_share`
55
56error[E0277]: the trait bound `Box<i32>: Share` is not satisfied
57 --> $DIR/share-trait-non-implementors.rs:17:21
58 |
59LL | require_share::<Box<i32>>();
60 | ^^^^^^^^ the nightly-only, unstable trait `Share` is not implemented for `Box<i32>`
61 |
62 = help: the following other types implement trait `Share`:
63 &T
64 Arc<T, A>
65 Rc<T, A>
66 SyncSender<T>
67 std::sync::mpsc::Sender<T>
68note: required by a bound in `require_share`
69 --> $DIR/share-trait-non-implementors.rs:5:21
70 |
71LL | fn require_share<T: Share>() {}
72 | ^^^^^ required by this bound in `require_share`
73
74error: aborting due to 4 previous errors
75
76For more information about this error, try `rustc --explain E0277`.
tests/ui/share-trait/share-trait-not-in-prelude.rs created+9
...@@ -0,0 +1,9 @@
1#![feature(share_trait)]
2
3#[derive(Clone)]
4struct Alias;
5
6impl Share for Alias {}
7//~^ ERROR cannot find trait `Share` in this scope
8
9fn main() {}
tests/ui/share-trait/share-trait-not-in-prelude.stderr created+14
...@@ -0,0 +1,14 @@
1error[E0405]: cannot find trait `Share` in this scope
2 --> $DIR/share-trait-not-in-prelude.rs:6:6
3 |
4LL | impl Share for Alias {}
5 | ^^^^^ not found in this scope
6 |
7help: consider importing this trait
8 |
9LL + use std::clone::Share;
10 |
11
12error: aborting due to 1 previous error
13
14For more information about this error, try `rustc --explain E0405`.
tests/ui/share-trait/share-trait-rc.rs created+32
...@@ -0,0 +1,32 @@
1//@ run-pass
2
3#![feature(share_trait)]
4
5use std::cell::Cell;
6use std::clone::Share;
7use std::rc::Rc;
8
9trait Value {
10 fn get(&self) -> i32;
11}
12
13impl Value for Cell<i32> {
14 fn get(&self) -> i32 {
15 Cell::get(self)
16 }
17}
18
19fn main() {
20 let value = Rc::new(Cell::new(1));
21 let shared = value.share();
22
23 assert!(Rc::ptr_eq(&value, &shared));
24 shared.set(2);
25 assert_eq!(value.get(), 2);
26
27 let dyn_value: Rc<dyn Value> = Rc::new(Cell::new(3));
28 let shared_dyn_value = dyn_value.share();
29
30 assert!(Rc::ptr_eq(&dyn_value, &shared_dyn_value));
31 assert_eq!(shared_dyn_value.get(), 3);
32}
tests/ui/share-trait/share-trait-requires-clone.rs created+10
...@@ -0,0 +1,10 @@
1#![feature(share_trait)]
2
3use std::clone::Share;
4
5struct NotClone;
6
7impl Share for NotClone {}
8//~^ ERROR the trait bound `NotClone: Clone` is not satisfied
9
10fn main() {}
tests/ui/share-trait/share-trait-requires-clone.stderr created+17
...@@ -0,0 +1,17 @@
1error[E0277]: the trait bound `NotClone: Clone` is not satisfied
2 --> $DIR/share-trait-requires-clone.rs:7:16
3 |
4LL | impl Share for NotClone {}
5 | ^^^^^^^^ the trait `Clone` is not implemented for `NotClone`
6 |
7note: required by a bound in `Share`
8 --> $SRC_DIR/core/src/clone.rs:LL:COL
9help: consider annotating `NotClone` with `#[derive(Clone)]`
10 |
11LL + #[derive(Clone)]
12LL | struct NotClone;
13 |
14
15error: aborting due to 1 previous error
16
17For more information about this error, try `rustc --explain E0277`.
tests/ui/share-trait/share-trait.rs created+44
...@@ -0,0 +1,44 @@
1//@ check-pass
2
3#![feature(share_trait)]
4
5extern crate core;
6
7use core::clone::Share;
8
9#[derive(Debug, PartialEq)]
10struct Alias(u8);
11
12impl Clone for Alias {
13 fn clone(&self) -> Self {
14 Alias(self.0 + 1)
15 }
16}
17
18impl Share for Alias {}
19
20fn share_generic<T: Share>(value: &T) -> T {
21 value.share()
22}
23
24fn main() {
25 let value = Alias(1);
26
27 assert_eq!(Share::share(&value), Alias(2));
28 assert_eq!(std::clone::Share::share(&value), Alias(2));
29 assert_eq!(value.share(), Alias(2));
30 assert_eq!(share_generic(&value), Alias(2));
31
32 let number = 3;
33 let shared = &number;
34 let shared_again = shared.share();
35 let shared_fqs: &i32 = Share::share(&shared);
36 let shared_generic: &i32 = share_generic(&shared);
37
38 assert!(std::ptr::eq(shared, shared_again));
39 assert!(std::ptr::eq(shared_fqs, shared));
40 assert!(std::ptr::eq(shared_generic, shared));
41
42 let slice: &[i32] = &[1, 2, 3];
43 assert!(std::ptr::eq(slice, slice.share()));
44}