Skip to content

Commit f030d49

Browse files
committed
Expose Freeze trait again
1 parent 71a7b66 commit f030d49

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

library/core/src/marker.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -810,15 +810,21 @@ pub trait DiscriminantKind {
810810
type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin;
811811
}
812812

813-
/// Compiler-internal trait used to determine whether a type contains
813+
/// Used to determine whether a type contains
814814
/// any `UnsafeCell` internally, but not through an indirection.
815815
/// This affects, for example, whether a `static` of that type is
816816
/// placed in read-only static memory or writable static memory.
817+
/// This can be used to declare that a constant with a generic type
818+
/// will not contain interior mutability, and subsequently allow
819+
/// placing the constant behind references.
817820
#[lang = "freeze"]
818-
pub(crate) unsafe auto trait Freeze {}
821+
#[unstable(feature = "freeze", issue = "60715")]
822+
pub unsafe auto trait Freeze {}
819823

824+
#[unstable(feature = "freeze", issue = "60715")]
820825
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
821826
marker_impls! {
827+
#[unstable(feature = "freeze", issue = "60715")]
822828
unsafe Freeze for
823829
{T: ?Sized} PhantomData<T>,
824830
{T: ?Sized} *const T,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// https://github.com/rust-lang/rust/issues/50159
2-
#![crate_name="foo"]
2+
#![crate_name = "foo"]
33

44
pub trait Signal {
55
type Item;
@@ -9,15 +9,18 @@ pub trait Signal2 {
99
type Item2;
1010
}
1111

12-
impl<B, C> Signal2 for B where B: Signal<Item = C> {
12+
impl<B, C> Signal2 for B
13+
where
14+
B: Signal<Item = C>,
15+
{
1316
type Item2 = C;
1417
}
1518

1619
// @has foo/struct.Switch.html
1720
// @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send'
1821
// @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync'
1922
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
20-
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
23+
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6
2124
pub struct Switch<B: Signal> {
2225
pub inner: <B as Signal2>::Item2,
2326
}

tests/rustdoc/empty-section.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![crate_name = "foo"]
2-
3-
#![feature(negative_impls)]
2+
#![feature(negative_impls, freeze_impls, freeze)]
43

54
pub struct Foo;
65

76
// @has foo/struct.Foo.html
87
// @!hasraw - 'Auto Trait Implementations'
98
impl !Send for Foo {}
109
impl !Sync for Foo {}
10+
impl !std::marker::Freeze for Foo {}
1111
impl !std::marker::Unpin for Foo {}
1212
impl !std::panic::RefUnwindSafe for Foo {}
1313
impl !std::panic::UnwindSafe for Foo {}

tests/rustdoc/synthetic_auto/basic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send'
33
// @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync'
44
// @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0
5-
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
5+
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6
66
pub struct Foo<T> {
77
field: T,
88
}

tests/rustdoc/synthetic_auto/manual.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// 'impl<T> Send for Foo<T>'
77
//
88
// @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1
9-
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 4
9+
// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5
1010
pub struct Foo<T> {
1111
field: T,
1212
}

tests/ui/associated-consts/freeze.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(freeze)]
2+
3+
//@ check-pass
4+
5+
use std::marker::Freeze;
6+
7+
trait Trait<T: Freeze + 'static> {
8+
const VALUE: T;
9+
const VALUE_REF: &'static T = &Self::VALUE;
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)