You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::sync::Arc;fnworks<'r>(x:Box<&'staticstr>) -> Box<&'rstr>{
x
}fnalso_works<'r,'w>(x:&'w&'staticstr) -> &'w&'rstr{
x
}fnbreaks<'r>(x:Arc<&'staticstr>) -> Arc<&'rstr>{
x
}fnmain(){}
I'm working on implementing Shared per @gankro's Raw Pointer Cleanup pre-RFC, but I'll point out that by naively changing ArcInner to use *const T instead of *mut T, we get RFC 1214 warnings in libstd/thread/mod:283:
../rust/src/libstd/thread/mod.rs:283:27: 283:32 warning: the parameter type `T` may not live long enough [E0310]
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
../rust/src/libstd/thread/mod.rs:283:27: 283:32 help: run `rustc --explain E0310` to see a detailed explanation
../rust/src/libstd/thread/mod.rs:283:27: 283:32 help: consider adding an explicit lifetime bound `T: 'static`...
../rust/src/libstd/thread/mod.rs:283:27: 283:32 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
../rust/src/libstd/thread/mod.rs:283:27: 283:32 note: ...so that the reference type `&alloc::arc::Arc<core::cell::UnsafeCell<core::option::Option<core::result::Result<T, Box<core::any::Any + Send>>>>>` does not outlive the data it points at
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
../rust/src/libstd/thread/mod.rs:283:27: 283:32 warning: the parameter type `T` may not live long enough [E0310]
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
../rust/src/libstd/thread/mod.rs:283:27: 283:32 help: run `rustc --explain E0310` to see a detailed explanation
../rust/src/libstd/thread/mod.rs:283:27: 283:32 help: consider adding an explicit lifetime bound `T: 'static`...
../rust/src/libstd/thread/mod.rs:283:27: 283:32 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
../rust/src/libstd/thread/mod.rs:283:27: 283:32 note: ...so that the reference type `&core::cell::UnsafeCell<core::option::Option<core::result::Result<T, Box<core::any::Any + Send>>>>` does not outlive the data it points at
../rust/src/libstd/thread/mod.rs:283 *their_packet.get() = Some(try_result.map(|()| {
^~~~~
Activity
bluss commentedon Oct 15, 2015
@gankro's Raw Pointer Cleanup seems to already touch upon this.
apasel422 commentedon Oct 15, 2015
I'm working on implementing
Shared
per @gankro's Raw Pointer Cleanup pre-RFC, but I'll point out that by naively changingArcInner
to use*const T
instead of*mut T
, we get RFC 1214 warnings in libstd/thread/mod:283:These may or may not be spurious.
arielb1 commentedon Oct 15, 2015
@apasel422
That method has been giving me trouble, so probably spurious.
apasel422 commentedon Oct 16, 2015
@arielb1 Should I file that as a separate RFC 1214 bug?
apasel422 commentedon Oct 16, 2015
For what it's worth,
Rc
is also invariant.Arc
andRc
are dropck-unsound #29106Shared
pointer and have{Arc, Rc}
use it #29110AtomicPtr
is invariant in its type parameter #29211