Skip to content

Commit bc487f7

Browse files
authoredNov 2, 2021
Rollup merge of #90417 - lcnr:stabilize-relaxed-struct-unsizing, r=wesleywiser
stabilize `relaxed_struct_unsize` closes #81793 the fcp is already complete.
2 parents 40f01aa + b40aa64 commit bc487f7

File tree

6 files changed

+14
-68
lines changed

6 files changed

+14
-68
lines changed
 

‎compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ declare_features! (
297297
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
298298
/// Allows panicking during const eval (producing compile-time errors).
299299
(accepted, const_panic, "1.57.0", Some(51999), None),
300+
/// Lessens the requirements for structs to implement `Unsize`.
301+
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None),
300302

301303
// -------------------------------------------------------------------------
302304
// feature-group-end: accepted features

‎compiler/rustc_feature/src/active.rs

-3
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,6 @@ declare_features! (
589589
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
590590
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
591591

592-
/// Lessens the requirements for structs to implement `Unsize`.
593-
(active, relaxed_struct_unsize, "1.51.0", Some(81793), None),
594-
595592
/// Allows associated types in inherent impls.
596593
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
597594

‎compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+12-40
Original file line numberDiff line numberDiff line change
@@ -948,52 +948,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
948948
let tail_field_ty = tcx.type_of(tail_field.did);
949949

950950
let mut unsizing_params = GrowableBitSet::new_empty();
951-
if tcx.features().relaxed_struct_unsize {
952-
for arg in tail_field_ty.walk(tcx) {
953-
if let Some(i) = maybe_unsizing_param_idx(arg) {
954-
unsizing_params.insert(i);
955-
}
956-
}
957-
958-
// Ensure none of the other fields mention the parameters used
959-
// in unsizing.
960-
for field in prefix_fields {
961-
for arg in tcx.type_of(field.did).walk(tcx) {
962-
if let Some(i) = maybe_unsizing_param_idx(arg) {
963-
unsizing_params.remove(i);
964-
}
965-
}
951+
for arg in tail_field_ty.walk(tcx) {
952+
if let Some(i) = maybe_unsizing_param_idx(arg) {
953+
unsizing_params.insert(i);
966954
}
955+
}
967956

968-
if unsizing_params.is_empty() {
969-
return Err(Unimplemented);
970-
}
971-
} else {
972-
let mut found = false;
973-
for arg in tail_field_ty.walk(tcx) {
957+
// Ensure none of the other fields mention the parameters used
958+
// in unsizing.
959+
for field in prefix_fields {
960+
for arg in tcx.type_of(field.did).walk(tcx) {
974961
if let Some(i) = maybe_unsizing_param_idx(arg) {
975-
unsizing_params.insert(i);
976-
found = true;
962+
unsizing_params.remove(i);
977963
}
978964
}
979-
if !found {
980-
return Err(Unimplemented);
981-
}
965+
}
982966

983-
// Ensure none of the other fields mention the parameters used
984-
// in unsizing.
985-
// FIXME(eddyb) cache this (including computing `unsizing_params`)
986-
// by putting it in a query; it would only need the `DefId` as it
987-
// looks at declared field types, not anything substituted.
988-
for field in prefix_fields {
989-
for arg in tcx.type_of(field.did).walk(tcx) {
990-
if let Some(i) = maybe_unsizing_param_idx(arg) {
991-
if unsizing_params.contains(i) {
992-
return Err(Unimplemented);
993-
}
994-
}
995-
}
996-
}
967+
if unsizing_params.is_empty() {
968+
return Err(Unimplemented);
997969
}
998970

999971
// Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`.

‎src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs

-10
This file was deleted.

‎src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr

-14
This file was deleted.

‎src/test/ui/unsized/unchanged-param.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(relaxed_struct_unsize)]
21
// run-pass
32
// Test that we allow unsizing even if there is an unchanged param in the
43
// field getting unsized.

0 commit comments

Comments
 (0)
Please sign in to comment.