1
- // { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" }
2
-
1
+ // { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers " }
2
+ // { dg-enable-nn-line-numbers "" }
3
3
4
4
#[ lang = "sized" ]
5
5
pub trait Sized { }
@@ -32,27 +32,63 @@ fn immutable_borrow_while_immutable_borrowed_struct() {
32
32
}
33
33
34
34
fn immutable_borrow_while_mutable_borrowed_struct ( ) {
35
- // { dg-error "Found loan errors in function immutable_borrow_while_mutable_borrowed_struct" "" { target *-*-* } .-1 }
36
35
let mut x = 0 ;
37
36
let y = ReferenceMut :: new ( & mut x) ;
38
37
let z = & x; //~ ERROR
38
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
39
39
let w = y;
40
+ /*
41
+ { dg-begin-multiline-output "" }
42
+ NN | let y = ReferenceMut::new(&mut x);
43
+ | ~
44
+ | |
45
+ | borrow occurs here
46
+ NN | let z = &x; //~ ERROR
47
+ | ^
48
+ | |
49
+ | borrowed value used here
50
+ { dg-end-multiline-output "" }
51
+ */
40
52
}
41
53
42
54
fn mutable_borrow_while_immutable_borrowed_struct ( ) {
43
- // { dg-error "Found loan errors in function mutable_borrow_while_immutable_borrowed_struct" "" { target *-*-* } .-1 }
44
55
let x = 0 ;
45
56
let y = Reference :: new ( & x) ;
46
57
let z = & mut x; //~ ERROR
58
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
47
59
let w = y;
60
+ /*
61
+ { dg-begin-multiline-output "" }
62
+ NN | let y = Reference::new(&x);
63
+ | ~
64
+ | |
65
+ | borrow occurs here
66
+ NN | let z = &mut x; //~ ERROR
67
+ | ^
68
+ | |
69
+ | borrowed value used here
70
+ { dg-end-multiline-output "" }
71
+ */
48
72
}
49
73
50
74
fn mutable_borrow_while_mutable_borrowed_struct ( ) {
51
- // { dg-error "Found loan errors in function mutable_borrow_while_mutable_borrowed_struct" "" { target *-*-* } .-1 }
52
75
let mut x = 0 ;
53
76
let y = ReferenceMut :: new ( & mut x) ;
54
77
let z = & mut x; //~ ERROR
78
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
55
79
let w = y;
80
+ /*
81
+ { dg-begin-multiline-output "" }
82
+ NN | let y = ReferenceMut::new(&mut x);
83
+ | ~
84
+ | |
85
+ | borrow occurs here
86
+ NN | let z = &mut x; //~ ERROR
87
+ | ^
88
+ | |
89
+ | borrowed value used here
90
+ { dg-end-multiline-output "" }
91
+ */
56
92
}
57
93
58
94
fn immutable_reborrow_while_immutable_borrowed_struct ( ) {
@@ -69,31 +105,73 @@ fn immutable_reborrow_while_mutable_borrowed_struct() {
69
105
70
106
fn mutable_reborrow_while_immutable_borrowed_struct ( ) {
71
107
// { dg-error "Cannot reborrow immutable borrow as mutable" "" { target *-*-* } .-1 }
108
+ /*
109
+ { dg-begin-multiline-output "" }
110
+ NN | fn mutable_reborrow_while_immutable_borrowed_struct() {
111
+ | ^~
112
+ { dg-end-multiline-output "" }
113
+ */
72
114
let x = 0 ;
73
115
let y = Reference :: new ( & x) ;
74
116
let z = & mut * y. value ; //~ ERROR
75
117
}
76
118
77
119
fn read_while_mutable_borrowed_struct ( ) {
78
- // { dg-error "Found loan errors in function read_while_mutable_borrowed_struct" "" { target *-*-* } .-1 }
79
120
let mut x = 0 ;
80
121
let y = ReferenceMut :: new ( & mut x) ;
81
122
let z = x; //~ ERROR
123
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
82
124
let w = y;
125
+ /*
126
+ { dg-begin-multiline-output "" }
127
+ NN | let y = ReferenceMut::new(&mut x);
128
+ | ~
129
+ | |
130
+ | borrow occurs here
131
+ NN | let z = x; //~ ERROR
132
+ | ^
133
+ | |
134
+ | borrowed value used here
135
+ { dg-end-multiline-output "" }
136
+ */
83
137
}
84
138
85
139
fn write_while_borrowed_struct ( ) {
86
- // { dg-error "Found loan errors in function write_while_borrowed_struct" "" { target *-*-* } .-1 }
87
140
let mut x = 0 ;
88
141
let y = Reference :: new ( & x) ;
89
142
x = 1 ; //~ ERROR
143
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
90
144
let z = y;
145
+ /*
146
+ { dg-begin-multiline-output "" }
147
+ NN | let y = Reference::new(&x);
148
+ | ~
149
+ | |
150
+ | borrow occurs here
151
+ NN | x = 1; //~ ERROR
152
+ | ^
153
+ | |
154
+ | borrowed value used here
155
+ { dg-end-multiline-output "" }
156
+ */
91
157
}
92
158
93
159
fn write_while_immutable_borrowed_struct ( ) {
94
- // { dg-error "Found loan errors in function write_while_immutable_borrowed_struct" "" { target *-*-* } .-1 }
95
160
let x = 0 ;
96
161
let y = Reference :: new ( & x) ;
97
162
x = 1 ; //~ ERROR
163
+ // { dg-error "use of borrowed value" "" { target *-*-* } .-1 }
98
164
let z = y;
99
- }
165
+ /*
166
+ { dg-begin-multiline-output "" }
167
+ NN | let y = Reference::new(&x);
168
+ | ~
169
+ | |
170
+ | borrow occurs here
171
+ NN | x = 1; //~ ERROR
172
+ | ^
173
+ | |
174
+ | borrowed value used here
175
+ { dg-end-multiline-output "" }
176
+ */
177
+ }
0 commit comments