Skip to content

Commit e9c244e

Browse files
committed
Use GNU diff, not MacOS diff
1 parent 5bdac9a commit e9c244e

File tree

1 file changed

+73
-76
lines changed

1 file changed

+73
-76
lines changed

verifast-proofs/alloc/collections/linked_list.code-changes.diff

Lines changed: 73 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
0a1,2
22
> // verifast_options{prover:z3v4.5 skip_specless_fns}
33
>
4-
13c15
4+
13c15,27
55
< #![stable(feature = "rust1", since = "1.0.0")]
66
---
77
> // This is a slightly tweaked version of https://github.com/rust-lang/rust/blob/c290e9de32e8ba6a673ef125fde40eadd395d170/library/alloc/src/collections/linked_list.rs
8-
14a17,28
8+
>
99
> //#![stable(feature = "rust1", since = "1.0.0")]
1010
> #![feature(rustc_attrs)]
1111
> #![feature(dropck_eyepatch)]
@@ -17,7 +17,6 @@
1717
> #![feature(box_into_inner)]
1818
>
1919
> use std as core;
20-
>
2120
15a30
2221
> use core::fmt;
2322
16a32
@@ -26,14 +25,13 @@
2625
> use core::mem;
2726
20d36
2827
< use core::{fmt, mem};
29-
22,24c38,39
28+
22,24c38,40
3029
< use super::SpecExtend;
3130
< use crate::alloc::{Allocator, Global};
3231
< use crate::boxed::Box;
3332
---
3433
> use std::alloc::{Allocator, Global};
3534
> use std::boxed::Box;
36-
25a41
3735
>
3836
28a45,48
3937
> trait SpecExtend<I> {
@@ -194,7 +192,7 @@
194192
---
195193
> unsafe fn pop_front_node<'a>(&'a mut self) -> Option<Box<Node<T>, &'a A>>
196194
> {
197-
197,199c225,229
195+
197,199c225,235
198196
< self.head.map(|node| unsafe {
199197
< let node = Box::from_raw_in(node.as_ptr(), &self.alloc);
200198
< self.head = node.next;
@@ -204,26 +202,26 @@
204202
> Some(node) => unsafe {
205203
> self.head = (*node.as_ptr()).next;
206204
> let node_ = Box::from_raw_in(node.as_ptr(), &self.alloc);
207-
201,205c231,235
208-
< match self.head {
209-
< None => self.tail = None,
210-
< // Not creating new mutable (unique!) references overlapping `element`.
211-
< Some(head) => (*head.as_ptr()).prev = None,
212-
< }
213-
---
205+
>
214206
> match self.head {
215207
> None => self.tail = None,
216208
> // Not creating new mutable (unique!) references overlapping `element`.
217209
> Some(head) => (*head.as_ptr()).prev = None,
218210
> }
219-
207,209c237,240
211+
201,204c237,238
212+
< match self.head {
213+
< None => self.tail = None,
214+
< // Not creating new mutable (unique!) references overlapping `element`.
215+
< Some(head) => (*head.as_ptr()).prev = None,
216+
---
217+
> self.len -= 1;
218+
> Some(node_)
219+
206,209c240
220+
<
220221
< self.len -= 1;
221222
< node
222223
< })
223224
---
224-
> self.len -= 1;
225-
> Some(node_)
226-
> }
227225
> }
228226
224c255
229227
< let node = Some(node);
@@ -241,7 +239,7 @@
241239
< self.tail = node;
242240
---
243241
> self.tail = node_;
244-
242,244c273,277
242+
242,244c273,283
245243
< self.tail.map(|node| unsafe {
246244
< let node = Box::from_raw_in(node.as_ptr(), &self.alloc);
247245
< self.tail = node.prev;
@@ -251,26 +249,26 @@
251249
> Some(node) => unsafe {
252250
> let node_ = Box::from_raw_in(node.as_ptr(), &self.alloc);
253251
> self.tail = node_.prev;
254-
246,250c279,283
255-
< match self.tail {
256-
< None => self.head = None,
257-
< // Not creating new mutable (unique!) references overlapping `element`.
258-
< Some(tail) => (*tail.as_ptr()).next = None,
259-
< }
260-
---
252+
>
261253
> match self.tail {
262254
> None => self.head = None,
263255
> // Not creating new mutable (unique!) references overlapping `element`.
264256
> Some(tail) => (*tail.as_ptr()).next = None,
265257
> }
266-
252,254c285,288
258+
246,249c285,286
259+
< match self.tail {
260+
< None => self.head = None,
261+
< // Not creating new mutable (unique!) references overlapping `element`.
262+
< Some(tail) => (*tail.as_ptr()).next = None,
263+
---
264+
> self.len -= 1;
265+
> Some(node_)
266+
251,254c288
267+
<
267268
< self.len -= 1;
268269
< node
269270
< })
270271
---
271-
> self.len -= 1;
272-
> Some(node_)
273-
> }
274272
> }
275273
264,265c298,300
276274
< unsafe fn unlink_node(&mut self, mut node: NonNull<Node<T>>) {
@@ -543,7 +541,7 @@
543541
< #[stable(feature = "rust1", since = "1.0.0")]
544542
---
545543
> //#[stable(feature = "rust1", since = "1.0.0")]
546-
955,971c1036,1044
544+
955,982c1036,1076
547545
< let len = self.len();
548546
< assert!(at <= len, "Cannot split off at a nonexistent index");
549547
< if at == 0 {
@@ -561,17 +559,7 @@
561559
< // depending on implementation details of Skip
562560
< for _ in 0..at - 1 {
563561
< iter.next();
564-
---
565-
> unsafe {
566-
> let len = self.len;
567-
> assert!(at <= len, "Cannot split off at a nonexistent index");
568-
> if at == 0 {
569-
> let alloc1 = clone_allocator(&self.alloc);
570-
> return mem::replace(self, Self::new_in(alloc1));
571-
> } else if at == len {
572-
> let alloc2 = clone_allocator(&self.alloc);
573-
> return Self::new_in(alloc2);
574-
973,982c1046,1076
562+
< }
575563
< iter.head
576564
< } else {
577565
< // better off starting from the end
@@ -583,6 +571,16 @@
583571
< };
584572
< unsafe { self.split_off_after_node(split_node, at) }
585573
---
574+
> unsafe {
575+
> let len = self.len;
576+
> assert!(at <= len, "Cannot split off at a nonexistent index");
577+
> if at == 0 {
578+
> let alloc1 = clone_allocator(&self.alloc);
579+
> return mem::replace(self, Self::new_in(alloc1));
580+
> } else if at == len {
581+
> let alloc2 = clone_allocator(&self.alloc);
582+
> return Self::new_in(alloc2);
583+
> }
586584
>
587585
> // Below, we iterate towards the `i-1`th node, either from the start or the end,
588586
> // depending on which would be faster.
@@ -645,35 +643,29 @@
645643
---
646644
> let r = ExtractIf { list: self, it, pred: filter, idx: 0, old_len };
647645
> r
648-
1168,1171c1265
646+
1168,1169c1265,1267
649647
< #[stable(feature = "rust1", since = "1.0.0")]
650648
< unsafe impl<#[may_dangle] T, A: Allocator> Drop for LinkedList<T, A> {
651-
< fn drop(&mut self) {
652-
< struct DropGuard<'a, T, A: Allocator>(&'a mut LinkedList<T, A>);
653649
---
654650
> struct DropGuard<'a, T, A: Allocator>(&'a mut LinkedList<T, A>);
655-
1173,1178c1267,1272
656-
< impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
657-
< fn drop(&mut self) {
658-
< // Continue the same loop we do below. This only runs when a destructor has
659-
< // panicked. If another one panics this will abort.
660-
< while self.0.pop_front_node().is_some() {}
661-
< }
662-
---
651+
>
663652
> impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
664-
> fn drop(&mut self) {
653+
1171c1269,1275
654+
< struct DropGuard<'a, T, A: Allocator>(&'a mut LinkedList<T, A>);
655+
---
665656
> unsafe {
666657
> // Continue the same loop we do below. This only runs when a destructor has
667658
> // panicked. If another one panics this will abort.
668659
> while self.0.pop_front_node().is_some() {}
669-
1179a1274,1275
660+
> }
670661
> }
671662
> }
672-
1181,1184c1277,1292
673-
< // Wrap self so that if a destructor panics, we can try to keep looping
674-
< let guard = DropGuard(self);
675-
< while guard.0.pop_front_node().is_some() {}
676-
< mem::forget(guard);
663+
1173,1177c1277,1289
664+
< impl<'a, T, A: Allocator> Drop for DropGuard<'a, T, A> {
665+
< fn drop(&mut self) {
666+
< // Continue the same loop we do below. This only runs when a destructor has
667+
< // panicked. If another one panics this will abort.
668+
< while self.0.pop_front_node().is_some() {}
677669
---
678670
> //#[stable(feature = "rust1", since = "1.0.0")]
679671
> unsafe impl<#[may_dangle] T, A: Allocator> Drop for LinkedList<T, A> {
@@ -688,9 +680,14 @@
688680
> Some(element) => {
689681
> }
690682
> }
691-
> }
683+
1178a1291
692684
> mem::forget(guard);
693-
> }
685+
1180,1184d1292
686+
<
687+
< // Wrap self so that if a destructor panics, we can try to keep looping
688+
< let guard = DropGuard(self);
689+
< while guard.0.pop_front_node().is_some() {}
690+
< mem::forget(guard);
694691
1188c1296
695692
< #[stable(feature = "rust1", since = "1.0.0")]
696693
---
@@ -901,8 +898,7 @@
901898
< #[unstable(feature = "linked_list_cursors", issue = "58533")]
902899
---
903900
> /*#[unstable(feature = "linked_list_cursors", issue = "58533")]*/
904-
1614,1625d1740
905-
< }
901+
1615,1626d1741
906902
<
907903
< /// Provides a read-only reference to the cursor's parent list.
908904
< ///
@@ -914,6 +910,7 @@
914910
< #[unstable(feature = "linked_list_cursors", issue = "58533")]
915911
< pub fn as_list(&self) -> &LinkedList<T, A> {
916912
< self.list
913+
< }
917914
1636c1751
918915
< #[unstable(feature = "linked_list_cursors", issue = "58533")]
919916
---
@@ -1019,12 +1016,17 @@
10191016
>
10201017
> /*#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]*/
10211018
> impl<'a, T, F, A: Allocator> Iterator for ExtractIf<'a, T, F, A>
1022-
1959,1963c2087,2095
1019+
1959,1968c2087,2103
10231020
< fn next(&mut self) -> Option<T> {
10241021
< while let Some(mut node) = self.it {
10251022
< unsafe {
10261023
< self.it = node.as_ref().next;
10271024
< self.idx += 1;
1025+
<
1026+
< if (self.pred)(&mut node.as_mut().element) {
1027+
< // `unlink_node` is okay with aliasing `element` references.
1028+
< self.list.unlink_node(node);
1029+
< return Some(Box::from_raw_in(node.as_ptr(), &self.list.alloc).element);
10281030
---
10291031
> fn next(&mut self) -> Option<T>
10301032
> {
@@ -1035,12 +1037,7 @@
10351037
> self.it = (*node.as_ptr()).next; //node.as_ref().next;
10361038
> self.idx += 1;
10371039
>
1038-
1965,1968c2097,2103
1039-
< if (self.pred)(&mut node.as_mut().element) {
1040-
< // `unlink_node` is okay with aliasing `element` references.
1041-
< self.list.unlink_node(node);
1042-
< return Some(Box::from_raw_in(node.as_ptr(), &self.list.alloc).element);
1043-
---
1040+
>
10441041
> if call_pred(&mut self.pred, &mut node.as_mut().element) {
10451042
> // `unlink_node` is okay with aliasing `element` references.
10461043
> self.list.unlink_node(node);
@@ -1130,7 +1127,7 @@
11301127
< #[stable(feature = "std_collections_from_array", since = "1.56.0")]
11311128
---
11321129
> //#[stable(feature = "std_collections_from_array", since = "1.56.0")]
1133-
2203,2212c2337,2338
1130+
2203,2212c2337,2348
11341131
< fn assert_covariance() {
11351132
< fn a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> {
11361133
< x
@@ -1144,9 +1141,8 @@
11441141
---
11451142
> fn assert_covariance_a<'a>(x: LinkedList<&'static str>) -> LinkedList<&'a str> {
11461143
> x
1147-
2215c2341,2351
1148-
< #[stable(feature = "rust1", since = "1.0.0")]
1149-
---
1144+
> }
1145+
>
11501146
> #[allow(dead_code)]
11511147
> fn assert_covariance_b<'i, 'a>(x: Iter<'i, &'static str>) -> Iter<'i, &'a str> {
11521148
> x
@@ -1155,8 +1151,9 @@
11551151
> #[allow(dead_code)]
11561152
> fn assert_covariance_c<'a>(x: IntoIter<&'static str>) -> IntoIter<&'a str> {
11571153
> x
1158-
> }
1159-
>
1154+
2215c2351
1155+
< #[stable(feature = "rust1", since = "1.0.0")]
1156+
---
11601157
> //#[stable(feature = "rust1", since = "1.0.0")]
11611158
2218c2354
11621159
< #[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)