Expose Freeze
trait again
This commit is contained in:
parent
71a7b66f20
commit
f030d49536
@ -810,15 +810,21 @@ pub trait DiscriminantKind {
|
|||||||
type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin;
|
type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compiler-internal trait used to determine whether a type contains
|
/// Used to determine whether a type contains
|
||||||
/// any `UnsafeCell` internally, but not through an indirection.
|
/// any `UnsafeCell` internally, but not through an indirection.
|
||||||
/// This affects, for example, whether a `static` of that type is
|
/// This affects, for example, whether a `static` of that type is
|
||||||
/// placed in read-only static memory or writable static memory.
|
/// placed in read-only static memory or writable static memory.
|
||||||
|
/// This can be used to declare that a constant with a generic type
|
||||||
|
/// will not contain interior mutability, and subsequently allow
|
||||||
|
/// placing the constant behind references.
|
||||||
#[lang = "freeze"]
|
#[lang = "freeze"]
|
||||||
pub(crate) unsafe auto trait Freeze {}
|
#[unstable(feature = "freeze", issue = "60715")]
|
||||||
|
pub unsafe auto trait Freeze {}
|
||||||
|
|
||||||
|
#[unstable(feature = "freeze", issue = "60715")]
|
||||||
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
|
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
|
||||||
marker_impls! {
|
marker_impls! {
|
||||||
|
#[unstable(feature = "freeze", issue = "60715")]
|
||||||
unsafe Freeze for
|
unsafe Freeze for
|
||||||
{T: ?Sized} PhantomData<T>,
|
{T: ?Sized} PhantomData<T>,
|
||||||
{T: ?Sized} *const T,
|
{T: ?Sized} *const T,
|
||||||
|
@ -9,7 +9,10 @@ pub trait Signal2 {
|
|||||||
type Item2;
|
type Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<B, C> Signal2 for B where B: Signal<Item = C> {
|
impl<B, C> Signal2 for B
|
||||||
|
where
|
||||||
|
B: Signal<Item = C>,
|
||||||
|
{
|
||||||
type Item2 = C;
|
type Item2 = C;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +20,7 @@ impl<B, C> Signal2 for B where B: Signal<Item = C> {
|
|||||||
// @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send'
|
// @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send'
|
||||||
// @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync'
|
// @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync'
|
||||||
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
|
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
|
||||||
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
|
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6
|
||||||
pub struct Switch<B: Signal> {
|
pub struct Switch<B: Signal> {
|
||||||
pub inner: <B as Signal2>::Item2,
|
pub inner: <B as Signal2>::Item2,
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#![crate_name = "foo"]
|
#![crate_name = "foo"]
|
||||||
|
#![feature(negative_impls, freeze_impls, freeze)]
|
||||||
#![feature(negative_impls)]
|
|
||||||
|
|
||||||
pub struct Foo;
|
pub struct Foo;
|
||||||
|
|
||||||
@ -8,6 +7,7 @@
|
|||||||
// @!hasraw - 'Auto Trait Implementations'
|
// @!hasraw - 'Auto Trait Implementations'
|
||||||
impl !Send for Foo {}
|
impl !Send for Foo {}
|
||||||
impl !Sync for Foo {}
|
impl !Sync for Foo {}
|
||||||
|
impl !std::marker::Freeze for Foo {}
|
||||||
impl !std::marker::Unpin for Foo {}
|
impl !std::marker::Unpin for Foo {}
|
||||||
impl !std::panic::RefUnwindSafe for Foo {}
|
impl !std::panic::RefUnwindSafe for Foo {}
|
||||||
impl !std::panic::UnwindSafe for Foo {}
|
impl !std::panic::UnwindSafe for Foo {}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send'
|
// @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send'
|
||||||
// @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync'
|
// @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync'
|
||||||
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
|
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
|
||||||
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
|
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6
|
||||||
pub struct Foo<T> {
|
pub struct Foo<T> {
|
||||||
field: T,
|
field: T,
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// 'impl<T> Send for Foo<T>'
|
// 'impl<T> Send for Foo<T>'
|
||||||
//
|
//
|
||||||
// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1
|
// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1
|
||||||
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 4
|
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
|
||||||
pub struct Foo<T> {
|
pub struct Foo<T> {
|
||||||
field: T,
|
field: T,
|
||||||
}
|
}
|
||||||
|
12
tests/ui/associated-consts/freeze.rs
Normal file
12
tests/ui/associated-consts/freeze.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#![feature(freeze)]
|
||||||
|
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
use std::marker::Freeze;
|
||||||
|
|
||||||
|
trait Trait<T: Freeze + 'static> {
|
||||||
|
const VALUE: T;
|
||||||
|
const VALUE_REF: &'static T = &Self::VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue
Block a user