Skip to content

Commit 119c9d7

Browse files
committed
library: add {Pointee,Meta}Sized to next prelude
Its strange to have to import sizedness traits, so add them to the prelude in the next edition.
1 parent b7b592c commit 119c9d7

File tree

6 files changed

+53
-13
lines changed

6 files changed

+53
-13
lines changed

library/core/src/prelude/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ pub mod rust_future {
9292
#[stable(feature = "prelude_2024", since = "1.85.0")]
9393
#[doc(no_inline)]
9494
pub use crate::future::{Future, IntoFuture};
95+
96+
#[unstable(feature = "prelude_next", issue = "none")]
97+
#[doc(no_inline)]
98+
pub use crate::marker::{MetaSized, PointeeSized};
9599
}

tests/ui/sized-hierarchy/constness.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#![allow(internal_features)]
44
#![feature(rustc_attrs, const_trait_impl, sized_hierarchy)]
55

6-
use std::marker::MetaSized;
7-
86
#[rustc_non_const_sized]
97
struct NotConstSized;
108

tests/ui/sized-hierarchy/constness.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0435]: attempt to use a non-constant value in a constant
2-
--> $DIR/constness.rs:32:34
2+
--> $DIR/constness.rs:30:34
33
|
44
LL | let _ = const { size_of_val(&v) };
55
| ^ non-constant value
@@ -11,7 +11,7 @@ LL + const v: /* Type */ = NotConstSized;
1111
|
1212

1313
error[E0435]: attempt to use a non-constant value in a constant
14-
--> $DIR/constness.rs:37:33
14+
--> $DIR/constness.rs:35:33
1515
|
1616
LL | let _ = const { size_of_val(v) };
1717
| ^ non-constant value
@@ -23,49 +23,49 @@ LL + const v: /* Type */ = NotConstSized;
2323
|
2424

2525
error[E0277]: the trait bound `NotConstSized: const Sized` is not satisfied
26-
--> $DIR/constness.rs:22:31
26+
--> $DIR/constness.rs:20:31
2727
|
2828
LL | let _ = const { size_of::<NotConstSized>() };
2929
| ^^^^^^^^^^^^^
3030
|
3131
note: required by a bound in `size_of`
32-
--> $DIR/constness.rs:18:21
32+
--> $DIR/constness.rs:16:21
3333
|
3434
LL | const fn size_of<T: ~const Sized>() { unimplemented!() }
3535
| ^^^^^^^^^^^^ required by this bound in `size_of`
3636

3737
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
38-
--> $DIR/constness.rs:26:31
38+
--> $DIR/constness.rs:24:31
3939
|
4040
LL | let _ = const { size_of::<NotConstMetaSized>() };
4141
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
4242
|
4343
= help: within `NotConstMetaSized`, the trait `Sized` is not implemented for `[u8]`
4444
note: required because it appears within the type `NotConstMetaSized`
45-
--> $DIR/constness.rs:12:8
45+
--> $DIR/constness.rs:10:8
4646
|
4747
LL | struct NotConstMetaSized([u8]);
4848
| ^^^^^^^^^^^^^^^^^
4949
note: required by a bound in `size_of`
50-
--> $DIR/constness.rs:18:21
50+
--> $DIR/constness.rs:16:21
5151
|
5252
LL | const fn size_of<T: ~const Sized>() { unimplemented!() }
5353
| ^^^^^^^^^^^^ required by this bound in `size_of`
5454

5555
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
56-
--> $DIR/constness.rs:28:23
56+
--> $DIR/constness.rs:26:23
5757
|
5858
LL | let _ = size_of::<NotConstMetaSized>();
5959
| ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
6060
|
6161
= help: within `NotConstMetaSized`, the trait `Sized` is not implemented for `[u8]`
6262
note: required because it appears within the type `NotConstMetaSized`
63-
--> $DIR/constness.rs:12:8
63+
--> $DIR/constness.rs:10:8
6464
|
6565
LL | struct NotConstMetaSized([u8]);
6666
| ^^^^^^^^^^^^^^^^^
6767
note: required by a bound in `size_of`
68-
--> $DIR/constness.rs:18:21
68+
--> $DIR/constness.rs:16:21
6969
|
7070
LL | const fn size_of<T: ~const Sized>() { unimplemented!() }
7171
| ^^^^^^^^^^^^ required by this bound in `size_of`

tests/ui/sized-hierarchy/extern-type-behind-ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ check-pass
22
#![feature(extern_types, sized_hierarchy)]
33

4-
use std::marker::{MetaSized, PointeeSized};
4+
use std::marker::PointeeSized;
55

66
pub fn hash<T: PointeeSized>(_: *const T) {
77
unimplemented!();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0405]: cannot find trait `MetaSized` in this scope
2+
--> $DIR/prelude.rs:10:21
3+
|
4+
LL | pub fn metasized<T: MetaSized>() {}
5+
| ^^^^^^^^^ not found in this scope
6+
|
7+
help: consider importing this trait
8+
|
9+
LL + use std::marker::MetaSized;
10+
|
11+
12+
error[E0405]: cannot find trait `PointeeSized` in this scope
13+
--> $DIR/prelude.rs:12:24
14+
|
15+
LL | pub fn pointeesized<T: PointeeSized>() {}
16+
| ^^^^^^^^^^^^ not found in this scope
17+
|
18+
help: consider importing this trait
19+
|
20+
LL + use std::marker::PointeeSized;
21+
|
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0405`.

tests/ui/sized-hierarchy/prelude.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ compile-flags: --crate-type=lib
2+
//@ revisions: e2024 future
3+
//@[e2024] edition: 2024
4+
//@[e2024] check-fail
5+
//@[future] compile-flags: -Zunstable-options
6+
//@[future] edition: future
7+
//@[future] check-pass
8+
#![feature(sized_hierarchy)]
9+
10+
pub fn metasized<T: MetaSized>() {}
11+
//[e2024]~^ ERROR cannot find trait `MetaSized` in this scope
12+
pub fn pointeesized<T: PointeeSized>() {}
13+
//[e2024]~^ ERROR cannot find trait `PointeeSized` in this scope

0 commit comments

Comments
 (0)