Skip to content

Commit e0afd4a

Browse files
committed
Add runtime check to avoid overwrite arg in Diag
Signed-off-by: xizheyin <[email protected]>
1 parent 2fcf177 commit e0afd4a

File tree

64 files changed

+957
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+957
-527
lines changed

compiler/rustc_borrowck/messages.ftl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ borrowck_moved_a_fn_once_in_call_call =
109109
`FnOnce` closures can only be called once
110110
111111
borrowck_moved_a_fn_once_in_call_def =
112-
`{$ty}` is made to be an `FnOnce` closure here
112+
`{$ty_}` is made to be an `FnOnce` closure here
113113
114114
borrowck_moved_due_to_await =
115-
{$place_name} {$is_partial ->
115+
{$place_name_await} {$is_partial_await ->
116116
[true] partially moved
117117
*[false] moved
118118
} due to this {$is_loop_message ->
@@ -121,7 +121,7 @@ borrowck_moved_due_to_await =
121121
}
122122
123123
borrowck_moved_due_to_call =
124-
{$place_name} {$is_partial ->
124+
{$place_name_call} {$is_partial_call ->
125125
[true] partially moved
126126
*[false] moved
127127
} due to this {$is_loop_message ->
@@ -130,7 +130,7 @@ borrowck_moved_due_to_call =
130130
}
131131
132132
borrowck_moved_due_to_implicit_into_iter_call =
133-
{$place_name} {$is_partial ->
133+
{$place_name_implicit_call} {$is_partial_implicit_call ->
134134
[true] partially moved
135135
*[false] moved
136136
} due to this implicit call to {$is_loop_message ->
@@ -139,7 +139,7 @@ borrowck_moved_due_to_implicit_into_iter_call =
139139
}
140140
141141
borrowck_moved_due_to_method_call =
142-
{$place_name} {$is_partial ->
142+
{$place_name_method_call} {$is_partial_method_call ->
143143
[true] partially moved
144144
*[false] moved
145145
} due to this method {$is_loop_message ->
@@ -148,7 +148,7 @@ borrowck_moved_due_to_method_call =
148148
}
149149
150150
borrowck_moved_due_to_usage_in_operator =
151-
{$place_name} {$is_partial ->
151+
{$place_name_use} {$is_partial_use ->
152152
[true] partially moved
153153
*[false] moved
154154
} due to usage in {$is_loop_message ->
@@ -211,10 +211,10 @@ borrowck_tail_expr_drop_order = relative drop order changing in Rust 2024
211211
.note = consider using a `let` binding to ensure the value will live long enough
212212
213213
borrowck_ty_no_impl_copy =
214-
{$is_partial_move ->
214+
{$is_partial_type_no_copy ->
215215
[true] partial move
216216
*[false] move
217-
} occurs because {$place} has type `{$ty}`, which does not implement the `Copy` trait
217+
} occurs because {$place} has type `{$ty_}`, which does not implement the `Copy` trait
218218
219219
borrowck_use_due_to_use_closure =
220220
use occurs due to use in closure
@@ -232,7 +232,7 @@ borrowck_value_capture_here =
232232
}
233233
234234
borrowck_value_moved_here =
235-
value {$is_partial ->
235+
value {$is_partial_move ->
236236
[true] partially moved
237237
*[false] moved
238238
} {$is_move_msg ->

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
279279
if let Some(local) = place.as_local() {
280280
let span = self.body.local_decls[local].source_info.span;
281281
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
282-
is_partial_move,
283-
ty,
282+
is_partial_type_no_copy: is_partial_move,
283+
ty_: ty,
284284
place: &note_msg,
285285
span,
286286
});
287287
} else {
288288
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Note {
289-
is_partial_move,
290-
ty,
289+
is_partial_type_no_copy: is_partial_move,
290+
ty_: ty,
291291
place: &note_msg,
292292
});
293293
};

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11911191
{
11921192
err.subdiagnostic(CaptureReasonLabel::Call {
11931193
fn_call_span,
1194-
place_name: &place_name,
1195-
is_partial,
1194+
place_name_call: &place_name,
1195+
is_partial_call: is_partial,
11961196
is_loop_message,
11971197
});
11981198
// Check if the move occurs on a value because of a call on a closure that comes
@@ -1270,8 +1270,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
12701270
let self_arg = self_arg.unwrap();
12711271
err.subdiagnostic(CaptureReasonLabel::OperatorUse {
12721272
fn_call_span,
1273-
place_name: &place_name,
1274-
is_partial,
1273+
place_name_use: &place_name,
1274+
is_partial_use: is_partial,
12751275
is_loop_message,
12761276
});
12771277
if self.fn_self_span_reported.insert(fn_span) {
@@ -1341,8 +1341,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13411341

13421342
err.subdiagnostic(CaptureReasonLabel::ImplicitCall {
13431343
fn_call_span,
1344-
place_name: &place_name,
1345-
is_partial,
1344+
place_name_implicit_call: &place_name,
1345+
is_partial_implicit_call: is_partial,
13461346
is_loop_message,
13471347
});
13481348
// If the moved place was a `&mut` ref, then we can
@@ -1367,15 +1367,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13671367
if let Some((CallDesugaringKind::Await, _)) = desugaring {
13681368
err.subdiagnostic(CaptureReasonLabel::Await {
13691369
fn_call_span,
1370-
place_name: &place_name,
1371-
is_partial,
1370+
place_name_await: &place_name,
1371+
is_partial_await: is_partial,
13721372
is_loop_message,
13731373
});
13741374
} else {
13751375
err.subdiagnostic(CaptureReasonLabel::MethodCall {
13761376
fn_call_span,
1377-
place_name: &place_name,
1378-
is_partial,
1377+
place_name_method_call: &place_name,
1378+
is_partial_method_call: is_partial,
13791379
is_loop_message,
13801380
});
13811381
}
@@ -1481,7 +1481,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14811481
if move_span != span || is_loop_message {
14821482
err.subdiagnostic(CaptureReasonLabel::MovedHere {
14831483
move_span,
1484-
is_partial,
1484+
is_partial_move: is_partial,
14851485
is_move_msg,
14861486
is_loop_message,
14871487
});

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
597597
}
598598

599599
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
600-
is_partial_move: false,
601-
ty: place_ty,
600+
is_partial_type_no_copy: false,
601+
ty_: place_ty,
602602
place: &place_desc,
603603
span,
604604
});
@@ -629,8 +629,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
629629
}
630630

631631
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
632-
is_partial_move: false,
633-
ty: place_ty,
632+
is_partial_type_no_copy: false,
633+
ty_: place_ty,
634634
place: &place_desc,
635635
span: use_span,
636636
});
@@ -832,8 +832,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
832832
}
833833

834834
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
835-
is_partial_move: false,
836-
ty: bind_to.ty,
835+
is_partial_type_no_copy: false,
836+
ty_: bind_to.ty,
837837
place: place_desc,
838838
span: binding_span,
839839
});

0 commit comments

Comments
 (0)