Skip to content

Commit e236587

Browse files
committed
fix stage 2
1 parent 32d11e6 commit e236587

File tree

20 files changed

+41
-9
lines changed

20 files changed

+41
-9
lines changed

compiler/rustc_ast/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#![feature(negative_impls)]
1919
#![feature(slice_internals)]
2020
#![feature(stmt_expr_attributes)]
21+
#![feature(structural_match)]
2122
#![recursion_limit = "256"]
2223
#![deny(rustc::untranslatable_diagnostic)]
2324
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_borrowck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(once_cell)]
99
#![feature(rustc_attrs)]
1010
#![feature(stmt_expr_attributes)]
11+
#![feature(structural_match)]
1112
#![feature(trusted_step)]
1213
#![feature(try_blocks)]
1314
#![recursion_limit = "256"]

compiler/rustc_data_structures/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(maybe_uninit_uninit_array)]
1818
#![feature(min_specialization)]
1919
#![feature(never_type)]
20+
#![feature(structural_match)]
2021
#![feature(type_alias_impl_trait)]
2122
#![feature(new_uninit)]
2223
#![feature(once_cell)]

compiler/rustc_hir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#![feature(min_specialization)]
1010
#![feature(never_type)]
1111
#![feature(rustc_attrs)]
12+
#![feature(structural_match)]
1213
#![feature(variant_count)]
1314
#![recursion_limit = "256"]
1415
#![deny(rustc::untranslatable_diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ This API is completely unstable and subject to change.
6969
#![feature(never_type)]
7070
#![feature(once_cell)]
7171
#![feature(slice_partition_dedup)]
72+
#![feature(structural_match)]
7273
#![feature(try_blocks)]
7374
#![feature(is_some_and)]
7475
#![feature(type_alias_impl_trait)]

compiler/rustc_hir_typeck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(min_specialization)]
66
#![feature(control_flow_enum)]
77
#![feature(drain_filter)]
8+
#![feature(structural_match)]
89
#![allow(rustc::potential_query_instability)]
910
#![recursion_limit = "256"]
1011

compiler/rustc_index/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
new_uninit,
1010
step_trait,
1111
stmt_expr_attributes,
12+
structural_match,
1213
test
1314
)
1415
)]

compiler/rustc_infer/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![feature(if_let_guard)]
2121
#![feature(min_specialization)]
2222
#![feature(never_type)]
23+
#![feature(structural_match)]
2324
#![feature(try_blocks)]
2425
#![recursion_limit = "512"] // For rustdoc
2526

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#![feature(min_specialization)]
3838
#![feature(never_type)]
3939
#![feature(rustc_attrs)]
40+
#![feature(structural_match)]
4041
#![recursion_limit = "256"]
4142
#![deny(rustc::untranslatable_diagnostic)]
4243
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_macros/src/newtype.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Parse for Newtype {
9393
}
9494
impl<E: ::rustc_serialize::Encoder> ::rustc_serialize::Encodable<E> for #name {
9595
fn encode(&self, e: &mut E) {
96-
e.emit_u32(self.private);
96+
e.emit_u32(self.as_u32());
9797
}
9898
}
9999
}
@@ -103,11 +103,16 @@ impl Parse for Newtype {
103103

104104
if ord {
105105
derive_paths.push(parse_quote!(Ord));
106-
derive_paths.push(parse_quote!(PartialOrd));
107106
}
108107

109108
let step = if ord {
110109
quote! {
110+
impl ::std::cmp::PartialOrd for #name {
111+
fn partial_cmp(&self, other: &Self) -> Option<::std::cmp::Ordering> {
112+
self.as_u32().partial_cmp(&other.as_u32())
113+
}
114+
}
115+
111116
impl ::std::iter::Step for #name {
112117
#[inline]
113118
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
@@ -150,7 +155,7 @@ impl Parse for Newtype {
150155
#[inline]
151156
fn eq(l: &Option<Self>, r: &Option<Self>) -> bool {
152157
if #max_val < u32::MAX {
153-
l.map(|i| i.private).unwrap_or(#max_val+1) == r.map(|i| i.private).unwrap_or(#max_val+1)
158+
l.map(|i| i.as_u32()).unwrap_or(#max_val+1) == r.map(|i| i.as_u32()).unwrap_or(#max_val+1)
154159
} else {
155160
match (l, r) {
156161
(Some(l), Some(r)) => r == l,
@@ -170,13 +175,21 @@ impl Parse for Newtype {
170175

171176
Ok(Self(quote! {
172177
#(#attrs)*
173-
#[derive(Clone, Copy, PartialEq, Eq, Hash, #(#derive_paths),*)]
178+
#[derive(Clone, Copy, Eq, Hash, #(#derive_paths),*)]
174179
#[rustc_layout_scalar_valid_range_end(#max)]
175180
#[rustc_pass_by_value]
176181
#vis struct #name {
177182
private: u32,
178183
}
179184

185+
impl ::std::cmp::PartialEq for #name {
186+
fn eq(&self, other: &Self) -> bool {
187+
self.as_u32() == other.as_u32()
188+
}
189+
}
190+
191+
impl ::std::marker::StructuralPartialEq for #name {}
192+
180193
#(#consts)*
181194

182195
impl #name {
@@ -224,7 +237,7 @@ impl Parse for Newtype {
224237
/// Prefer using `from_u32`.
225238
#[inline]
226239
#vis const unsafe fn from_u32_unchecked(value: u32) -> Self {
227-
Self { private: value }
240+
Self { private: value as _ }
228241
}
229242

230243
/// Extracts the value of this index as a `usize`.
@@ -236,7 +249,7 @@ impl Parse for Newtype {
236249
/// Extracts the value of this index as a `u32`.
237250
#[inline]
238251
#vis const fn as_u32(self) -> u32 {
239-
self.private
252+
self.private as u32
240253
}
241254

242255
/// Extracts the value of this index as a `usize`.

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#![feature(type_alias_impl_trait)]
4646
#![feature(associated_type_bounds)]
4747
#![feature(rustc_attrs)]
48+
#![feature(structural_match)]
4849
#![feature(control_flow_enum)]
4950
#![feature(associated_type_defaults)]
5051
#![feature(trusted_step)]

compiler/rustc_mir_build/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(min_specialization)]
1111
#![feature(once_cell)]
1212
#![feature(try_blocks)]
13+
#![feature(structural_match)]
1314
#![recursion_limit = "256"]
1415

1516
#[macro_use]

compiler/rustc_mir_dataflow/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(exact_size_is_empty)]
44
#![feature(min_specialization)]
55
#![feature(once_cell)]
6+
#![feature(structural_match)]
67
#![feature(stmt_expr_attributes)]
78
#![feature(trusted_step)]
89
#![recursion_limit = "256"]

compiler/rustc_mir_transform/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![feature(never_type)]
88
#![feature(once_cell)]
99
#![feature(option_get_or_insert_default)]
10+
#![feature(structural_match)]
1011
#![feature(trusted_step)]
1112
#![feature(try_blocks)]
1213
#![feature(yeet_expr)]

compiler/rustc_passes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(let_chains)]
1111
#![feature(map_try_insert)]
1212
#![feature(min_specialization)]
13+
#![feature(structural_match)]
1314
#![feature(try_blocks)]
1415
#![recursion_limit = "256"]
1516

compiler/rustc_query_system/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![feature(hash_raw_entry)]
44
#![feature(min_specialization)]
55
#![feature(extern_types)]
6+
#![feature(structural_match)]
67
#![allow(rustc::potential_query_instability)]
78
#![deny(rustc::untranslatable_diagnostic)]
89
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_span/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![feature(negative_impls)]
2020
#![feature(min_specialization)]
2121
#![feature(rustc_attrs)]
22+
#![feature(structural_match)]
2223
#![deny(rustc::untranslatable_diagnostic)]
2324
#![deny(rustc::diagnostic_outside_of_impl)]
2425

compiler/rustc_target/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(never_type)]
1616
#![feature(rustc_attrs)]
1717
#![feature(step_trait)]
18+
#![feature(structural_match)]
1819
#![deny(rustc::untranslatable_diagnostic)]
1920
#![deny(rustc::diagnostic_outside_of_impl)]
2021

compiler/rustc_trait_selection/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![feature(if_let_guard)]
2121
#![feature(never_type)]
2222
#![feature(result_option_inspect)]
23+
#![feature(structural_match)]
2324
#![feature(type_alias_impl_trait)]
2425
#![feature(min_specialization)]
2526
#![recursion_limit = "512"] // For rustdoc

compiler/rustc_type_ir/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(fmt_helpers_for_derive)]
22
#![feature(min_specialization)]
33
#![feature(rustc_attrs)]
4+
#![feature(structural_match)]
45
#![deny(rustc::untranslatable_diagnostic)]
56
#![deny(rustc::diagnostic_outside_of_impl)]
67

@@ -818,20 +819,20 @@ impl UniverseIndex {
818819
/// name the region `'a`, but that region was not nameable from
819820
/// `U` because it was not in scope there.
820821
pub fn next_universe(self) -> UniverseIndex {
821-
UniverseIndex::from_u32(self.private.checked_add(1).unwrap())
822+
UniverseIndex::from_u32(self.as_u32().checked_add(1).unwrap())
822823
}
823824

824825
/// Returns `true` if `self` can name a name from `other` -- in other words,
825826
/// if the set of names in `self` is a superset of those in
826827
/// `other` (`self >= other`).
827828
pub fn can_name(self, other: UniverseIndex) -> bool {
828-
self.private >= other.private
829+
self.as_u32() >= other.as_u32()
829830
}
830831

831832
/// Returns `true` if `self` cannot name some names from `other` -- in other
832833
/// words, if the set of names in `self` is a strict subset of
833834
/// those in `other` (`self < other`).
834835
pub fn cannot_name(self, other: UniverseIndex) -> bool {
835-
self.private < other.private
836+
self.as_u32() < other.as_u32()
836837
}
837838
}

0 commit comments

Comments
 (0)