Skip to content

Commit d5a471c

Browse files
authored
Rollup merge of rust-lang#144016 - davidtwco:sized-hierarchy-temp-pseudo-revert, r=lcnr
trait_sel: `MetaSized` always holds temporarily As a temporary measure while a proper fix for `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` is implemented, make `MetaSized` obligations always hold. In effect, temporarily reverting the `sized_hierarchy` feature. This is a small change that can be backported. cc rust-lang#143992 r? ```@lcnr```
2 parents 7e041c4 + 8d64937 commit d5a471c

19 files changed

+77
-244
lines changed

compiler/rustc_trait_selection/src/traits/util.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ pub fn sizedness_fast_path<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
378378
_ => return false,
379379
};
380380

381+
// FIXME(sized_hierarchy): this temporarily reverts the `sized_hierarchy` feature
382+
// while a proper fix for `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
383+
// is pending a proper fix
384+
if !tcx.features().sized_hierarchy() && matches!(sizedness, SizedTraitKind::MetaSized) {
385+
return true;
386+
}
387+
381388
if trait_pred.self_ty().has_trivial_sizedness(tcx, sizedness) {
382389
debug!("fast path -- trivial sizedness");
383390
return true;

tests/ui/consts/const-size_of_val-align_of_val-extern-type.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extern "C" {
88
}
99

1010
const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
11-
//~^ ERROR the size for values of type `Opaque` cannot be known
11+
//~^ ERROR `extern type` does not have known layout
1212
const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
13-
//~^ ERROR the size for values of type `Opaque` cannot be known
13+
//~^ ERROR `extern type` does not have known layout
1414

1515
fn main() {}
Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
1-
error[E0277]: the size for values of type `Opaque` cannot be known
2-
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:43
1+
error[E0080]: `extern type` does not have known layout
2+
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:31
33
|
44
LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
5-
| ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque`
6-
| |
7-
| required by a bound introduced by this call
8-
|
9-
= note: the trait bound `Opaque: MetaSized` is not satisfied
10-
note: required by a bound in `std::intrinsics::size_of_val`
11-
--> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
12-
help: consider borrowing here
13-
|
14-
LL | const _SIZE: usize = unsafe { size_of_val(&(&4 as *const i32 as *const Opaque)) };
15-
| ++ +
16-
LL | const _SIZE: usize = unsafe { size_of_val(&mut (&4 as *const i32 as *const Opaque)) };
17-
| ++++++ +
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_SIZE` failed here
186

19-
error[E0277]: the size for values of type `Opaque` cannot be known
20-
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:45
7+
error[E0080]: `extern type` does not have known layout
8+
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:32
219
|
2210
LL | const _ALIGN: usize = unsafe { align_of_val(&4 as *const i32 as *const Opaque) };
23-
| ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Opaque`
24-
| |
25-
| required by a bound introduced by this call
26-
|
27-
= note: the trait bound `Opaque: MetaSized` is not satisfied
28-
note: required by a bound in `std::intrinsics::align_of_val`
29-
--> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL
30-
help: consider borrowing here
31-
|
32-
LL | const _ALIGN: usize = unsafe { align_of_val(&(&4 as *const i32 as *const Opaque)) };
33-
| ++ +
34-
LL | const _ALIGN: usize = unsafe { align_of_val(&mut (&4 as *const i32 as *const Opaque)) };
35-
| ++++++ +
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_ALIGN` failed here
3612

3713
error: aborting due to 2 previous errors
3814

39-
For more information about this error, try `rustc --explain E0277`.
15+
For more information about this error, try `rustc --explain E0080`.

tests/ui/extern/extern-types-size_of_val.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ check-fail
1+
//@ check-pass
22
#![feature(extern_types)]
33

44
use std::mem::{align_of_val, size_of_val};
@@ -11,7 +11,5 @@ fn main() {
1111
let x: &A = unsafe { &*(1usize as *const A) };
1212

1313
size_of_val(x);
14-
//~^ ERROR the size for values of type `A` cannot be known
1514
align_of_val(x);
16-
//~^ ERROR the size for values of type `A` cannot be known
1715
}

tests/ui/extern/extern-types-size_of_val.stderr

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/ui/extern/extern-types-unsized.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ fn main() {
2727

2828
assert_sized::<Bar<A>>();
2929
//~^ ERROR the size for values of type
30-
//~| ERROR the size for values of type
3130

3231
assert_sized::<Bar<Bar<A>>>();
3332
//~^ ERROR the size for values of type
34-
//~| ERROR the size for values of type
3533
}

tests/ui/extern/extern-types-unsized.stderr

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,8 @@ help: consider relaxing the implicit `Sized` restriction
5959
LL | fn assert_sized<T: ?Sized>() {}
6060
| ++++++++
6161

62-
error[E0277]: the size for values of type `A` cannot be known
63-
--> $DIR/extern-types-unsized.rs:28:20
64-
|
65-
LL | assert_sized::<Bar<A>>();
66-
| ^^^^^^ doesn't have a known size
67-
|
68-
= help: the trait `MetaSized` is not implemented for `A`
69-
note: required by a bound in `Bar`
70-
--> $DIR/extern-types-unsized.rs:14:12
71-
|
72-
LL | struct Bar<T: ?Sized> {
73-
| ^ required by this bound in `Bar`
74-
7562
error[E0277]: the size for values of type `A` cannot be known at compilation time
76-
--> $DIR/extern-types-unsized.rs:32:20
63+
--> $DIR/extern-types-unsized.rs:31:20
7764
|
7865
LL | assert_sized::<Bar<Bar<A>>>();
7966
| ^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -94,19 +81,6 @@ help: consider relaxing the implicit `Sized` restriction
9481
LL | fn assert_sized<T: ?Sized>() {}
9582
| ++++++++
9683

97-
error[E0277]: the size for values of type `A` cannot be known
98-
--> $DIR/extern-types-unsized.rs:32:20
99-
|
100-
LL | assert_sized::<Bar<Bar<A>>>();
101-
| ^^^^^^^^^^^ doesn't have a known size
102-
|
103-
= help: the trait `MetaSized` is not implemented for `A`
104-
note: required by a bound in `Bar`
105-
--> $DIR/extern-types-unsized.rs:14:12
106-
|
107-
LL | struct Bar<T: ?Sized> {
108-
| ^ required by this bound in `Bar`
109-
110-
error: aborting due to 6 previous errors
84+
error: aborting due to 4 previous errors
11185

11286
For more information about this error, try `rustc --explain E0277`.

tests/ui/extern/unsized-extern-derefmove.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ extern "C" {
77
}
88

99
unsafe fn make_device() -> Box<Device> {
10-
//~^ ERROR the size for values of type `Device` cannot be known
1110
Box::from_raw(0 as *mut _)
12-
//~^ ERROR the size for values of type `Device` cannot be known
13-
//~| ERROR the size for values of type `Device` cannot be known
1411
}
1512

1613
fn main() {
1714
let d: Device = unsafe { *make_device() };
1815
//~^ ERROR the size for values of type `Device` cannot be known
19-
//~| ERROR the size for values of type `Device` cannot be known
2016
}
Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,5 @@
1-
error[E0277]: the size for values of type `Device` cannot be known
2-
--> $DIR/unsized-extern-derefmove.rs:9:28
3-
|
4-
LL | unsafe fn make_device() -> Box<Device> {
5-
| ^^^^^^^^^^^ doesn't have a known size
6-
|
7-
= help: the trait `MetaSized` is not implemented for `Device`
8-
note: required by a bound in `Box`
9-
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
10-
11-
error[E0277]: the size for values of type `Device` cannot be known
12-
--> $DIR/unsized-extern-derefmove.rs:11:19
13-
|
14-
LL | Box::from_raw(0 as *mut _)
15-
| ------------- ^^^^^^^^^^^ the trait `MetaSized` is not implemented for `Device`
16-
| |
17-
| required by a bound introduced by this call
18-
|
19-
= note: the trait bound `Device: MetaSized` is not satisfied
20-
note: required by a bound in `Box::<T>::from_raw`
21-
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
22-
help: consider borrowing here
23-
|
24-
LL | Box::from_raw(&(0 as *mut _))
25-
| ++ +
26-
LL | Box::from_raw(&mut (0 as *mut _))
27-
| ++++++ +
28-
29-
error[E0277]: the size for values of type `Device` cannot be known
30-
--> $DIR/unsized-extern-derefmove.rs:11:5
31-
|
32-
LL | Box::from_raw(0 as *mut _)
33-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size
34-
|
35-
= help: the trait `MetaSized` is not implemented for `Device`
36-
note: required by a bound in `Box`
37-
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
38-
391
error[E0277]: the size for values of type `Device` cannot be known at compilation time
40-
--> $DIR/unsized-extern-derefmove.rs:17:9
2+
--> $DIR/unsized-extern-derefmove.rs:14:9
413
|
424
LL | let d: Device = unsafe { *make_device() };
435
| ^ doesn't have a size known at compile-time
@@ -49,16 +11,6 @@ help: consider borrowing here
4911
LL | let d: &Device = unsafe { *make_device() };
5012
| +
5113

52-
error[E0277]: the size for values of type `Device` cannot be known
53-
--> $DIR/unsized-extern-derefmove.rs:17:31
54-
|
55-
LL | let d: Device = unsafe { *make_device() };
56-
| ^^^^^^^^^^^^^ doesn't have a known size
57-
|
58-
= help: the trait `MetaSized` is not implemented for `Device`
59-
note: required by a bound in `Box`
60-
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
61-
62-
error: aborting due to 5 previous errors
14+
error: aborting due to 1 previous error
6315

6416
For more information about this error, try `rustc --explain E0277`.

tests/ui/layout/unconstrained-param-ice-137308.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ impl<C: ?Sized> A for u8 { //~ ERROR: the type parameter `C` is not constrained
1717
#[rustc_layout(debug)]
1818
struct S([u8; <u8 as A>::B]);
1919
//~^ ERROR: the type has an unknown layout
20-
//~| ERROR: type annotations needed

0 commit comments

Comments
 (0)