Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f87f3db

Browse files
authoredJul 25, 2019
Rollup merge of #62978 - LukasKalbertodt:remove-array-impl-bootstrap-cfg, r=Mark-Simulacrum
Remove `cfg(bootstrap)` code for array implementations In #62435 ("Use const generics for array impls [part 1]") the old macro-based implementations were not removed but still used with `cfg(bootstrap)` since the bootstrap compiler had some problems with const generics at the time. This does not seem to be the case anymore, so there is no reason to keep the old code. Unfortunately, the diff is pretty ugly because much of the code was indented by one level before. The change is pretty trivial, though. PS: I did not run the full test suite locally. There are 40°C outside and 31°C inside my room. I don't want my notebook to melt. I hope that CI is green. r? @scottmcm
2 parents ca26d2e + 9d39758 commit f87f3db

File tree

2 files changed

+241
-434
lines changed

2 files changed

+241
-434
lines changed
 

‎src/libcore/array.rs

Lines changed: 240 additions & 433 deletions
Original file line numberDiff line numberDiff line change
@@ -81,487 +81,296 @@ impl From<Infallible> for TryFromSliceError {
8181
}
8282
}
8383

84-
#[cfg(bootstrap)]
85-
macro_rules! __impl_slice_eq1 {
86-
($Lhs: ty, $Rhs: ty) => {
87-
__impl_slice_eq1! { $Lhs, $Rhs, Sized }
88-
};
89-
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
90-
#[stable(feature = "rust1", since = "1.0.0")]
91-
impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
92-
#[inline]
93-
fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
94-
#[inline]
95-
fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
96-
}
84+
#[stable(feature = "rust1", since = "1.0.0")]
85+
impl<T, const N: usize> AsRef<[T]> for [T; N]
86+
where
87+
[T; N]: LengthAtMost32,
88+
{
89+
#[inline]
90+
fn as_ref(&self) -> &[T] {
91+
&self[..]
9792
}
9893
}
9994

100-
#[cfg(bootstrap)]
101-
macro_rules! __impl_slice_eq2 {
102-
($Lhs: ty, $Rhs: ty) => {
103-
__impl_slice_eq2! { $Lhs, $Rhs, Sized }
104-
};
105-
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
106-
__impl_slice_eq1!($Lhs, $Rhs, $Bound);
107-
108-
#[stable(feature = "rust1", since = "1.0.0")]
109-
impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq<A> {
110-
#[inline]
111-
fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] }
112-
#[inline]
113-
fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] }
114-
}
95+
#[stable(feature = "rust1", since = "1.0.0")]
96+
impl<T, const N: usize> AsMut<[T]> for [T; N]
97+
where
98+
[T; N]: LengthAtMost32,
99+
{
100+
#[inline]
101+
fn as_mut(&mut self) -> &mut [T] {
102+
&mut self[..]
115103
}
116104
}
117105

118-
// macro for implementing n-element array functions and operations
119-
#[cfg(bootstrap)]
120-
macro_rules! array_impls {
121-
($($N:expr)+) => {
122-
$(
123-
#[stable(feature = "rust1", since = "1.0.0")]
124-
impl<T> AsRef<[T]> for [T; $N] {
125-
#[inline]
126-
fn as_ref(&self) -> &[T] {
127-
&self[..]
128-
}
129-
}
130-
131-
#[stable(feature = "rust1", since = "1.0.0")]
132-
impl<T> AsMut<[T]> for [T; $N] {
133-
#[inline]
134-
fn as_mut(&mut self) -> &mut [T] {
135-
&mut self[..]
136-
}
137-
}
138-
139-
#[stable(feature = "array_borrow", since = "1.4.0")]
140-
impl<T> Borrow<[T]> for [T; $N] {
141-
fn borrow(&self) -> &[T] {
142-
self
143-
}
144-
}
145-
146-
#[stable(feature = "array_borrow", since = "1.4.0")]
147-
impl<T> BorrowMut<[T]> for [T; $N] {
148-
fn borrow_mut(&mut self) -> &mut [T] {
149-
self
150-
}
151-
}
152-
153-
#[stable(feature = "try_from", since = "1.34.0")]
154-
impl<T> TryFrom<&[T]> for [T; $N] where T: Copy {
155-
type Error = TryFromSliceError;
156-
157-
fn try_from(slice: &[T]) -> Result<[T; $N], TryFromSliceError> {
158-
<&Self>::try_from(slice).map(|r| *r)
159-
}
160-
}
161-
162-
#[stable(feature = "try_from", since = "1.34.0")]
163-
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
164-
type Error = TryFromSliceError;
165-
166-
fn try_from(slice: &[T]) -> Result<&[T; $N], TryFromSliceError> {
167-
if slice.len() == $N {
168-
let ptr = slice.as_ptr() as *const [T; $N];
169-
unsafe { Ok(&*ptr) }
170-
} else {
171-
Err(TryFromSliceError(()))
172-
}
173-
}
174-
}
175-
176-
#[stable(feature = "try_from", since = "1.34.0")]
177-
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
178-
type Error = TryFromSliceError;
179-
180-
fn try_from(slice: &mut [T]) -> Result<&mut [T; $N], TryFromSliceError> {
181-
if slice.len() == $N {
182-
let ptr = slice.as_mut_ptr() as *mut [T; $N];
183-
unsafe { Ok(&mut *ptr) }
184-
} else {
185-
Err(TryFromSliceError(()))
186-
}
187-
}
188-
}
189-
190-
#[stable(feature = "rust1", since = "1.0.0")]
191-
impl<T: Hash> Hash for [T; $N] {
192-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
193-
Hash::hash(&self[..], state)
194-
}
195-
}
196-
197-
#[stable(feature = "rust1", since = "1.0.0")]
198-
impl<T: fmt::Debug> fmt::Debug for [T; $N] {
199-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
200-
fmt::Debug::fmt(&&self[..], f)
201-
}
202-
}
203-
204-
#[stable(feature = "rust1", since = "1.0.0")]
205-
impl<'a, T> IntoIterator for &'a [T; $N] {
206-
type Item = &'a T;
207-
type IntoIter = Iter<'a, T>;
208-
209-
fn into_iter(self) -> Iter<'a, T> {
210-
self.iter()
211-
}
212-
}
213-
214-
#[stable(feature = "rust1", since = "1.0.0")]
215-
impl<'a, T> IntoIterator for &'a mut [T; $N] {
216-
type Item = &'a mut T;
217-
type IntoIter = IterMut<'a, T>;
218-
219-
fn into_iter(self) -> IterMut<'a, T> {
220-
self.iter_mut()
221-
}
222-
}
223-
224-
// NOTE: some less important impls are omitted to reduce code bloat
225-
__impl_slice_eq1! { [A; $N], [B; $N] }
226-
__impl_slice_eq2! { [A; $N], [B] }
227-
__impl_slice_eq2! { [A; $N], &'b [B] }
228-
__impl_slice_eq2! { [A; $N], &'b mut [B] }
229-
// __impl_slice_eq2! { [A; $N], &'b [B; $N] }
230-
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
231-
232-
#[stable(feature = "rust1", since = "1.0.0")]
233-
impl<T:Eq> Eq for [T; $N] { }
234-
235-
#[stable(feature = "rust1", since = "1.0.0")]
236-
impl<T:PartialOrd> PartialOrd for [T; $N] {
237-
#[inline]
238-
fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> {
239-
PartialOrd::partial_cmp(&&self[..], &&other[..])
240-
}
241-
#[inline]
242-
fn lt(&self, other: &[T; $N]) -> bool {
243-
PartialOrd::lt(&&self[..], &&other[..])
244-
}
245-
#[inline]
246-
fn le(&self, other: &[T; $N]) -> bool {
247-
PartialOrd::le(&&self[..], &&other[..])
248-
}
249-
#[inline]
250-
fn ge(&self, other: &[T; $N]) -> bool {
251-
PartialOrd::ge(&&self[..], &&other[..])
252-
}
253-
#[inline]
254-
fn gt(&self, other: &[T; $N]) -> bool {
255-
PartialOrd::gt(&&self[..], &&other[..])
256-
}
257-
}
258-
259-
#[stable(feature = "rust1", since = "1.0.0")]
260-
impl<T:Ord> Ord for [T; $N] {
261-
#[inline]
262-
fn cmp(&self, other: &[T; $N]) -> Ordering {
263-
Ord::cmp(&&self[..], &&other[..])
264-
}
265-
}
266-
)+
106+
#[stable(feature = "array_borrow", since = "1.4.0")]
107+
impl<T, const N: usize> Borrow<[T]> for [T; N]
108+
where
109+
[T; N]: LengthAtMost32,
110+
{
111+
fn borrow(&self) -> &[T] {
112+
self
267113
}
268114
}
269115

270-
#[cfg(not(bootstrap))]
271-
mod impls_using_const_generics {
272-
use super::*;
273-
274-
#[stable(feature = "rust1", since = "1.0.0")]
275-
impl<T, const N: usize> AsRef<[T]> for [T; N]
276-
where
277-
[T; N]: LengthAtMost32,
278-
{
279-
#[inline]
280-
fn as_ref(&self) -> &[T] {
281-
&self[..]
282-
}
116+
#[stable(feature = "array_borrow", since = "1.4.0")]
117+
impl<T, const N: usize> BorrowMut<[T]> for [T; N]
118+
where
119+
[T; N]: LengthAtMost32,
120+
{
121+
fn borrow_mut(&mut self) -> &mut [T] {
122+
self
283123
}
124+
}
284125

285-
#[stable(feature = "rust1", since = "1.0.0")]
286-
impl<T, const N: usize> AsMut<[T]> for [T; N]
287-
where
288-
[T; N]: LengthAtMost32,
289-
{
290-
#[inline]
291-
fn as_mut(&mut self) -> &mut [T] {
292-
&mut self[..]
293-
}
126+
#[stable(feature = "try_from", since = "1.34.0")]
127+
impl<T, const N: usize> TryFrom<&[T]> for [T; N]
128+
where
129+
T: Copy,
130+
[T; N]: LengthAtMost32,
131+
{
132+
type Error = TryFromSliceError;
133+
134+
fn try_from(slice: &[T]) -> Result<[T; N], TryFromSliceError> {
135+
<&Self>::try_from(slice).map(|r| *r)
294136
}
137+
}
295138

296-
#[stable(feature = "array_borrow", since = "1.4.0")]
297-
impl<T, const N: usize> Borrow<[T]> for [T; N]
298-
where
299-
[T; N]: LengthAtMost32,
300-
{
301-
fn borrow(&self) -> &[T] {
302-
self
139+
#[stable(feature = "try_from", since = "1.34.0")]
140+
impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N]
141+
where
142+
[T; N]: LengthAtMost32,
143+
{
144+
type Error = TryFromSliceError;
145+
146+
fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> {
147+
if slice.len() == N {
148+
let ptr = slice.as_ptr() as *const [T; N];
149+
unsafe { Ok(&*ptr) }
150+
} else {
151+
Err(TryFromSliceError(()))
303152
}
304153
}
154+
}
305155

306-
#[stable(feature = "array_borrow", since = "1.4.0")]
307-
impl<T, const N: usize> BorrowMut<[T]> for [T; N]
308-
where
309-
[T; N]: LengthAtMost32,
310-
{
311-
fn borrow_mut(&mut self) -> &mut [T] {
312-
self
156+
#[stable(feature = "try_from", since = "1.34.0")]
157+
impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N]
158+
where
159+
[T; N]: LengthAtMost32,
160+
{
161+
type Error = TryFromSliceError;
162+
163+
fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> {
164+
if slice.len() == N {
165+
let ptr = slice.as_mut_ptr() as *mut [T; N];
166+
unsafe { Ok(&mut *ptr) }
167+
} else {
168+
Err(TryFromSliceError(()))
313169
}
314170
}
171+
}
315172

316-
#[stable(feature = "try_from", since = "1.34.0")]
317-
impl<T, const N: usize> TryFrom<&[T]> for [T; N]
318-
where
319-
T: Copy,
320-
[T; N]: LengthAtMost32,
321-
{
322-
type Error = TryFromSliceError;
173+
#[stable(feature = "rust1", since = "1.0.0")]
174+
impl<T: Hash, const N: usize> Hash for [T; N]
175+
where
176+
[T; N]: LengthAtMost32,
177+
{
178+
fn hash<H: hash::Hasher>(&self, state: &mut H) {
179+
Hash::hash(&self[..], state)
180+
}
181+
}
323182

324-
fn try_from(slice: &[T]) -> Result<[T; N], TryFromSliceError> {
325-
<&Self>::try_from(slice).map(|r| *r)
326-
}
183+
#[stable(feature = "rust1", since = "1.0.0")]
184+
impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N]
185+
where
186+
[T; N]: LengthAtMost32,
187+
{
188+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
189+
fmt::Debug::fmt(&&self[..], f)
327190
}
191+
}
328192

329-
#[stable(feature = "try_from", since = "1.34.0")]
330-
impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N]
331-
where
332-
[T; N]: LengthAtMost32,
333-
{
334-
type Error = TryFromSliceError;
193+
#[stable(feature = "rust1", since = "1.0.0")]
194+
impl<'a, T, const N: usize> IntoIterator for &'a [T; N]
195+
where
196+
[T; N]: LengthAtMost32,
197+
{
198+
type Item = &'a T;
199+
type IntoIter = Iter<'a, T>;
335200

336-
fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> {
337-
if slice.len() == N {
338-
let ptr = slice.as_ptr() as *const [T; N];
339-
unsafe { Ok(&*ptr) }
340-
} else {
341-
Err(TryFromSliceError(()))
342-
}
343-
}
201+
fn into_iter(self) -> Iter<'a, T> {
202+
self.iter()
344203
}
204+
}
345205

346-
#[stable(feature = "try_from", since = "1.34.0")]
347-
impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N]
348-
where
349-
[T; N]: LengthAtMost32,
350-
{
351-
type Error = TryFromSliceError;
206+
#[stable(feature = "rust1", since = "1.0.0")]
207+
impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N]
208+
where
209+
[T; N]: LengthAtMost32,
210+
{
211+
type Item = &'a mut T;
212+
type IntoIter = IterMut<'a, T>;
352213

353-
fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> {
354-
if slice.len() == N {
355-
let ptr = slice.as_mut_ptr() as *mut [T; N];
356-
unsafe { Ok(&mut *ptr) }
357-
} else {
358-
Err(TryFromSliceError(()))
359-
}
360-
}
214+
fn into_iter(self) -> IterMut<'a, T> {
215+
self.iter_mut()
361216
}
217+
}
362218

363-
#[stable(feature = "rust1", since = "1.0.0")]
364-
impl<T: Hash, const N: usize> Hash for [T; N]
365-
where
366-
[T; N]: LengthAtMost32,
367-
{
368-
fn hash<H: hash::Hasher>(&self, state: &mut H) {
369-
Hash::hash(&self[..], state)
370-
}
219+
#[stable(feature = "rust1", since = "1.0.0")]
220+
impl<'a, 'b, A, B, const N: usize> PartialEq<[B; N]> for [A; N]
221+
where
222+
A: PartialEq<B>,
223+
[A; N]: LengthAtMost32,
224+
[B; N]: LengthAtMost32,
225+
{
226+
#[inline]
227+
fn eq(&self, other: &[B; N]) -> bool {
228+
self[..] == other[..]
371229
}
372-
373-
#[stable(feature = "rust1", since = "1.0.0")]
374-
impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N]
375-
where
376-
[T; N]: LengthAtMost32,
377-
{
378-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
379-
fmt::Debug::fmt(&&self[..], f)
380-
}
230+
#[inline]
231+
fn ne(&self, other: &[B; N]) -> bool {
232+
self[..] != other[..]
381233
}
234+
}
382235

383-
#[stable(feature = "rust1", since = "1.0.0")]
384-
impl<'a, T, const N: usize> IntoIterator for &'a [T; N]
385-
where
386-
[T; N]: LengthAtMost32,
387-
{
388-
type Item = &'a T;
389-
type IntoIter = Iter<'a, T>;
390-
391-
fn into_iter(self) -> Iter<'a, T> {
392-
self.iter()
393-
}
236+
#[stable(feature = "rust1", since = "1.0.0")]
237+
impl<'a, 'b, A, B, const N: usize> PartialEq<[B]> for [A; N]
238+
where
239+
A: PartialEq<B>,
240+
[A; N]: LengthAtMost32,
241+
{
242+
#[inline]
243+
fn eq(&self, other: &[B]) -> bool {
244+
self[..] == other[..]
394245
}
395-
396-
#[stable(feature = "rust1", since = "1.0.0")]
397-
impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N]
398-
where
399-
[T; N]: LengthAtMost32,
400-
{
401-
type Item = &'a mut T;
402-
type IntoIter = IterMut<'a, T>;
403-
404-
fn into_iter(self) -> IterMut<'a, T> {
405-
self.iter_mut()
406-
}
246+
#[inline]
247+
fn ne(&self, other: &[B]) -> bool {
248+
self[..] != other[..]
407249
}
250+
}
408251

409-
#[stable(feature = "rust1", since = "1.0.0")]
410-
impl<'a, 'b, A, B, const N: usize> PartialEq<[B; N]> for [A; N]
411-
where
412-
A: PartialEq<B>,
413-
[A; N]: LengthAtMost32,
414-
[B; N]: LengthAtMost32,
415-
{
416-
#[inline]
417-
fn eq(&self, other: &[B; N]) -> bool {
418-
self[..] == other[..]
419-
}
420-
#[inline]
421-
fn ne(&self, other: &[B; N]) -> bool {
422-
self[..] != other[..]
423-
}
252+
#[stable(feature = "rust1", since = "1.0.0")]
253+
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for [B]
254+
where
255+
B: PartialEq<A>,
256+
[A; N]: LengthAtMost32,
257+
{
258+
#[inline]
259+
fn eq(&self, other: &[A; N]) -> bool {
260+
self[..] == other[..]
424261
}
425-
426-
#[stable(feature = "rust1", since = "1.0.0")]
427-
impl<'a, 'b, A, B, const N: usize> PartialEq<[B]> for [A; N]
428-
where
429-
A: PartialEq<B>,
430-
[A; N]: LengthAtMost32,
431-
{
432-
#[inline]
433-
fn eq(&self, other: &[B]) -> bool {
434-
self[..] == other[..]
435-
}
436-
#[inline]
437-
fn ne(&self, other: &[B]) -> bool {
438-
self[..] != other[..]
439-
}
262+
#[inline]
263+
fn ne(&self, other: &[A; N]) -> bool {
264+
self[..] != other[..]
440265
}
266+
}
441267

442-
#[stable(feature = "rust1", since = "1.0.0")]
443-
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for [B]
444-
where
445-
B: PartialEq<A>,
446-
[A; N]: LengthAtMost32,
447-
{
448-
#[inline]
449-
fn eq(&self, other: &[A; N]) -> bool {
450-
self[..] == other[..]
451-
}
452-
#[inline]
453-
fn ne(&self, other: &[A; N]) -> bool {
454-
self[..] != other[..]
455-
}
268+
#[stable(feature = "rust1", since = "1.0.0")]
269+
impl<'a, 'b, A, B, const N: usize> PartialEq<&'b [B]> for [A; N]
270+
where
271+
A: PartialEq<B>,
272+
[A; N]: LengthAtMost32,
273+
{
274+
#[inline]
275+
fn eq(&self, other: &&'b [B]) -> bool {
276+
self[..] == other[..]
456277
}
457-
458-
#[stable(feature = "rust1", since = "1.0.0")]
459-
impl<'a, 'b, A, B, const N: usize> PartialEq<&'b [B]> for [A; N]
460-
where
461-
A: PartialEq<B>,
462-
[A; N]: LengthAtMost32,
463-
{
464-
#[inline]
465-
fn eq(&self, other: &&'b [B]) -> bool {
466-
self[..] == other[..]
467-
}
468-
#[inline]
469-
fn ne(&self, other: &&'b [B]) -> bool {
470-
self[..] != other[..]
471-
}
278+
#[inline]
279+
fn ne(&self, other: &&'b [B]) -> bool {
280+
self[..] != other[..]
472281
}
282+
}
473283

474-
#[stable(feature = "rust1", since = "1.0.0")]
475-
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for &'b [B]
476-
where
477-
B: PartialEq<A>,
478-
[A; N]: LengthAtMost32,
479-
{
480-
#[inline]
481-
fn eq(&self, other: &[A; N]) -> bool {
482-
self[..] == other[..]
483-
}
484-
#[inline]
485-
fn ne(&self, other: &[A; N]) -> bool {
486-
self[..] != other[..]
487-
}
284+
#[stable(feature = "rust1", since = "1.0.0")]
285+
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for &'b [B]
286+
where
287+
B: PartialEq<A>,
288+
[A; N]: LengthAtMost32,
289+
{
290+
#[inline]
291+
fn eq(&self, other: &[A; N]) -> bool {
292+
self[..] == other[..]
293+
}
294+
#[inline]
295+
fn ne(&self, other: &[A; N]) -> bool {
296+
self[..] != other[..]
488297
}
298+
}
489299

490-
#[stable(feature = "rust1", since = "1.0.0")]
491-
impl<'a, 'b, A, B, const N: usize> PartialEq<&'b mut [B]> for [A; N]
492-
where
493-
A: PartialEq<B>,
494-
[A; N]: LengthAtMost32,
495-
{
496-
#[inline]
497-
fn eq(&self, other: &&'b mut [B]) -> bool {
498-
self[..] == other[..]
499-
}
500-
#[inline]
501-
fn ne(&self, other: &&'b mut [B]) -> bool {
502-
self[..] != other[..]
503-
}
300+
#[stable(feature = "rust1", since = "1.0.0")]
301+
impl<'a, 'b, A, B, const N: usize> PartialEq<&'b mut [B]> for [A; N]
302+
where
303+
A: PartialEq<B>,
304+
[A; N]: LengthAtMost32,
305+
{
306+
#[inline]
307+
fn eq(&self, other: &&'b mut [B]) -> bool {
308+
self[..] == other[..]
309+
}
310+
#[inline]
311+
fn ne(&self, other: &&'b mut [B]) -> bool {
312+
self[..] != other[..]
504313
}
314+
}
505315

506-
#[stable(feature = "rust1", since = "1.0.0")]
507-
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for &'b mut [B]
508-
where
509-
B: PartialEq<A>,
510-
[A; N]: LengthAtMost32,
511-
{
512-
#[inline]
513-
fn eq(&self, other: &[A; N]) -> bool {
514-
self[..] == other[..]
515-
}
516-
#[inline]
517-
fn ne(&self, other: &[A; N]) -> bool {
518-
self[..] != other[..]
519-
}
316+
#[stable(feature = "rust1", since = "1.0.0")]
317+
impl<'a, 'b, A, B, const N: usize> PartialEq<[A; N]> for &'b mut [B]
318+
where
319+
B: PartialEq<A>,
320+
[A; N]: LengthAtMost32,
321+
{
322+
#[inline]
323+
fn eq(&self, other: &[A; N]) -> bool {
324+
self[..] == other[..]
325+
}
326+
#[inline]
327+
fn ne(&self, other: &[A; N]) -> bool {
328+
self[..] != other[..]
520329
}
330+
}
521331

522-
// NOTE: some less important impls are omitted to reduce code bloat
523-
// __impl_slice_eq2! { [A; $N], &'b [B; $N] }
524-
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
332+
// NOTE: some less important impls are omitted to reduce code bloat
333+
// __impl_slice_eq2! { [A; $N], &'b [B; $N] }
334+
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
525335

526-
#[stable(feature = "rust1", since = "1.0.0")]
527-
impl<T: Eq, const N: usize> Eq for [T; N] where [T; N]: LengthAtMost32 {}
336+
#[stable(feature = "rust1", since = "1.0.0")]
337+
impl<T: Eq, const N: usize> Eq for [T; N] where [T; N]: LengthAtMost32 {}
528338

529-
#[stable(feature = "rust1", since = "1.0.0")]
530-
impl<T: PartialOrd, const N: usize> PartialOrd for [T; N]
531-
where
532-
[T; N]: LengthAtMost32,
533-
{
534-
#[inline]
535-
fn partial_cmp(&self, other: &[T; N]) -> Option<Ordering> {
536-
PartialOrd::partial_cmp(&&self[..], &&other[..])
537-
}
538-
#[inline]
539-
fn lt(&self, other: &[T; N]) -> bool {
540-
PartialOrd::lt(&&self[..], &&other[..])
541-
}
542-
#[inline]
543-
fn le(&self, other: &[T; N]) -> bool {
544-
PartialOrd::le(&&self[..], &&other[..])
545-
}
546-
#[inline]
547-
fn ge(&self, other: &[T; N]) -> bool {
548-
PartialOrd::ge(&&self[..], &&other[..])
549-
}
550-
#[inline]
551-
fn gt(&self, other: &[T; N]) -> bool {
552-
PartialOrd::gt(&&self[..], &&other[..])
553-
}
339+
#[stable(feature = "rust1", since = "1.0.0")]
340+
impl<T: PartialOrd, const N: usize> PartialOrd for [T; N]
341+
where
342+
[T; N]: LengthAtMost32,
343+
{
344+
#[inline]
345+
fn partial_cmp(&self, other: &[T; N]) -> Option<Ordering> {
346+
PartialOrd::partial_cmp(&&self[..], &&other[..])
347+
}
348+
#[inline]
349+
fn lt(&self, other: &[T; N]) -> bool {
350+
PartialOrd::lt(&&self[..], &&other[..])
351+
}
352+
#[inline]
353+
fn le(&self, other: &[T; N]) -> bool {
354+
PartialOrd::le(&&self[..], &&other[..])
554355
}
356+
#[inline]
357+
fn ge(&self, other: &[T; N]) -> bool {
358+
PartialOrd::ge(&&self[..], &&other[..])
359+
}
360+
#[inline]
361+
fn gt(&self, other: &[T; N]) -> bool {
362+
PartialOrd::gt(&&self[..], &&other[..])
363+
}
364+
}
555365

556-
#[stable(feature = "rust1", since = "1.0.0")]
557-
impl<T: Ord, const N: usize> Ord for [T; N]
558-
where
559-
[T; N]: LengthAtMost32,
560-
{
561-
#[inline]
562-
fn cmp(&self, other: &[T; N]) -> Ordering {
563-
Ord::cmp(&&self[..], &&other[..])
564-
}
366+
#[stable(feature = "rust1", since = "1.0.0")]
367+
impl<T: Ord, const N: usize> Ord for [T; N]
368+
where
369+
[T; N]: LengthAtMost32,
370+
{
371+
#[inline]
372+
fn cmp(&self, other: &[T; N]) -> Ordering {
373+
Ord::cmp(&&self[..], &&other[..])
565374
}
566375
}
567376

@@ -571,10 +380,8 @@ mod impls_using_const_generics {
571380
)]
572381
#[unstable(feature = "const_generic_impls_guard", issue = "0",
573382
reason = "will never be stable, just a temporary step until const generics are stable")]
574-
#[cfg(not(bootstrap))]
575383
pub trait LengthAtMost32 {}
576384

577-
#[cfg(not(bootstrap))]
578385
macro_rules! array_impls {
579386
($($N:literal)+) => {
580387
$(

‎src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#![feature(concat_idents)]
7575
#![feature(const_fn)]
7676
#![feature(const_fn_union)]
77-
#![cfg_attr(not(bootstrap), feature(const_generics))]
77+
#![feature(const_generics)]
7878
#![feature(custom_inner_attributes)]
7979
#![feature(decl_macro)]
8080
#![feature(doc_cfg)]

0 commit comments

Comments
 (0)
Please sign in to comment.