Skip to content

Commit 37a9903

Browse files
committed
Remove rustc_mir::borrowck_errors::Origin
1 parent 2975c01 commit 37a9903

File tree

6 files changed

+19
-78
lines changed

6 files changed

+19
-78
lines changed

Diff for: src/librustc_mir/borrow_check/conflict_errors.rs

+5-23
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use super::{InitializationRequiringAction, PrefixSet};
2222
use super::error_reporting::{IncludingDowncast, UseSpans};
2323
use crate::dataflow::drop_flag_effects;
2424
use crate::dataflow::indexes::{MovePathIndex, MoveOutIndex};
25-
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
25+
use crate::util::borrowck_errors::BorrowckErrors;
2626

2727
#[derive(Debug)]
2828
struct MoveSite {
@@ -94,7 +94,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
9494
desired_action.as_noun(),
9595
&self.describe_place_with_options(moved_place, IncludingDowncast(true))
9696
.unwrap_or_else(|| "_".to_owned()),
97-
Origin::Mir,
9897
);
9998
err.span_label(span, format!("use of possibly uninitialized {}", item_msg));
10099

@@ -125,7 +124,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
125124
desired_action.as_noun(),
126125
msg,
127126
self.describe_place_with_options(&moved_place, IncludingDowncast(true)),
128-
Origin::Mir,
129127
);
130128

131129
self.add_moved_or_invoked_closure_note(
@@ -286,7 +284,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
286284
let mut err = tcx.cannot_move_when_borrowed(
287285
span,
288286
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
289-
Origin::Mir,
290287
);
291288
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
292289
err.span_label(span, format!("move out of {} occurs here", value_msg));
@@ -331,7 +328,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
331328
borrow_span,
332329
&self.describe_place(&borrow.borrowed_place)
333330
.unwrap_or_else(|| "_".to_owned()),
334-
Origin::Mir,
335331
);
336332

337333
borrow_spans.var_span_label(&mut err, {
@@ -398,7 +394,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
398394
rgt,
399395
&msg_borrow,
400396
None,
401-
Origin::Mir,
402397
)
403398
}
404399
(BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => {
@@ -413,7 +408,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413408
rgt,
414409
&msg_borrow,
415410
None,
416-
Origin::Mir,
417411
)
418412
}
419413

@@ -426,7 +420,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
426420
issued_span,
427421
&msg_borrow,
428422
None,
429-
Origin::Mir,
430423
)
431424
}
432425

@@ -437,7 +430,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
437430
&desc_place,
438431
issued_span,
439432
None,
440-
Origin::Mir,
441433
)
442434
}
443435

@@ -448,7 +440,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
448440
issued_span,
449441
&desc_place,
450442
"mutably borrow",
451-
Origin::Mir,
452443
);
453444
borrow_spans.var_span_label(
454445
&mut err,
@@ -471,7 +462,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
471462
"it",
472463
"",
473464
None,
474-
Origin::Mir,
475465
)
476466
},
477467

@@ -487,7 +477,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
487477
"",
488478
None,
489479
second_borrow_desc,
490-
Origin::Mir,
491480
)
492481
}
493482

@@ -503,7 +492,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
503492
"",
504493
None,
505494
second_borrow_desc,
506-
Origin::Mir,
507495
)
508496
}
509497

@@ -836,7 +824,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
836824
let mut err = self.infcx.tcx.path_does_not_live_long_enough(
837825
borrow_span,
838826
&format!("`{}`", name),
839-
Origin::Mir,
840827
);
841828

842829
if let Some(annotation) = self.annotate_argument_and_return_for_borrow(borrow) {
@@ -927,7 +914,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
927914

928915
let mut err = self.infcx
929916
.tcx
930-
.cannot_borrow_across_destructor(borrow_span, Origin::Mir);
917+
.cannot_borrow_across_destructor(borrow_span);
931918

932919
let what_was_dropped = match self.describe_place(place) {
933920
Some(name) => format!("`{}`", name.as_str()),
@@ -980,7 +967,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
980967

981968
let mut err = self.infcx
982969
.tcx
983-
.thread_local_value_does_not_live_long_enough(borrow_span, Origin::Mir);
970+
.thread_local_value_does_not_live_long_enough(borrow_span);
984971

985972
err.span_label(
986973
borrow_span,
@@ -1025,7 +1012,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10251012
}
10261013

10271014
let tcx = self.infcx.tcx;
1028-
let mut err = tcx.temporary_value_borrowed_for_too_long(proper_span, Origin::Mir);
1015+
let mut err = tcx.temporary_value_borrowed_for_too_long(proper_span);
10291016
err.span_label(
10301017
proper_span,
10311018
"creates a temporary which is freed while still in use",
@@ -1137,7 +1124,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11371124
return_kind,
11381125
reference_desc,
11391126
&place_desc,
1140-
Origin::Mir,
11411127
);
11421128

11431129
if return_span != borrow_span {
@@ -1162,7 +1148,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11621148
args_span,
11631149
captured_var,
11641150
var_span,
1165-
Origin::Mir,
11661151
);
11671152

11681153
let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) {
@@ -1218,7 +1203,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12181203
"function"
12191204
};
12201205

1221-
let mut err = tcx.borrowed_data_escapes_closure(escape_span, escapes_from, Origin::Mir);
1206+
let mut err = tcx.borrowed_data_escapes_closure(escape_span, escapes_from);
12221207

12231208
err.span_label(
12241209
upvar_span,
@@ -1367,7 +1352,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13671352
loan_span,
13681353
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
13691354
"assign",
1370-
Origin::Mir,
13711355
);
13721356
loan_spans.var_span_label(
13731357
&mut err,
@@ -1383,7 +1367,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13831367
span,
13841368
loan_span,
13851369
&self.describe_place(place).unwrap_or_else(|| "_".to_owned()),
1386-
Origin::Mir,
13871370
);
13881371

13891372
loan_spans.var_span_label(
@@ -1448,7 +1431,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14481431
span,
14491432
place_description.as_ref().map(AsRef::as_ref).unwrap_or("_"),
14501433
from_arg,
1451-
Origin::Mir,
14521434
);
14531435
let msg = if from_arg {
14541436
"cannot assign to immutable argument"

Diff for: src/librustc_mir/borrow_check/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::dataflow::MoveDataParamEnv;
4141
use crate::dataflow::{do_dataflow, DebugFormatted};
4242
use crate::dataflow::EverInitializedPlaces;
4343
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
44-
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
44+
use crate::util::borrowck_errors::BorrowckErrors;
4545

4646
use self::borrow_set::{BorrowData, BorrowSet};
4747
use self::flows::Flows;
@@ -1503,7 +1503,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
15031503
.cannot_borrow_across_generator_yield(
15041504
self.retrieve_borrow_spans(borrow).var_or_use(),
15051505
yield_span,
1506-
Origin::Mir,
15071506
);
15081507

15091508
err.buffer(&mut self.errors_buffer);

Diff for: src/librustc_mir/borrow_check/move_errors.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::dataflow::move_paths::{
1212
IllegalMoveOrigin, IllegalMoveOriginKind,
1313
LookupResult, MoveError, MovePathIndex,
1414
};
15-
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
15+
use crate::util::borrowck_errors::BorrowckErrors;
1616

1717
// Often when desugaring a pattern match we may have many individual moves in
1818
// MIR that are all part of one operation from the user's point-of-view. For
@@ -255,11 +255,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
255255
}
256256
IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => {
257257
self.infcx.tcx
258-
.cannot_move_out_of_interior_of_drop(span, ty, Origin::Mir)
258+
.cannot_move_out_of_interior_of_drop(span, ty)
259259
}
260260
IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } =>
261261
self.infcx.tcx.cannot_move_out_of_interior_noncopy(
262-
span, ty, Some(*is_index), Origin::Mir
262+
span, ty, Some(*is_index),
263263
),
264264
},
265265
span,
@@ -293,7 +293,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
293293
)
294294
};
295295

296-
self.infcx.tcx.cannot_move_out_of(span, &description, Origin::Mir)
296+
self.infcx.tcx.cannot_move_out_of(span, &description)
297297
}
298298

299299
fn report_cannot_move_from_borrowed_content(
@@ -302,8 +302,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
302302
deref_target_place: &Place<'tcx>,
303303
span: Span,
304304
) -> DiagnosticBuilder<'a> {
305-
let origin = Origin::Mir;
306-
307305
// Inspect the type of the content behind the
308306
// borrow to provide feedback about why this
309307
// was a move rather than a copy.
@@ -322,7 +320,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
322320
let mut err = self.infcx.tcx.cannot_move_out_of(
323321
span,
324322
&format!("`{}` in pattern guard", decl.name.unwrap()),
325-
origin,
326323
);
327324
err.note(
328325
"variables bound in patterns cannot be moved from \
@@ -334,9 +331,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
334331
debug!("report: ty={:?}", ty);
335332
let mut err = match ty.sty {
336333
ty::Array(..) | ty::Slice(..) =>
337-
self.infcx.tcx.cannot_move_out_of_interior_noncopy(
338-
span, ty, None, origin
339-
),
334+
self.infcx.tcx.cannot_move_out_of_interior_noncopy(span, ty, None),
340335
ty::Closure(def_id, closure_substs)
341336
if def_id == self.mir_def_id && upvar_field.is_some()
342337
=> {
@@ -378,7 +373,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
378373
closure_kind_ty, closure_kind, place_description,
379374
);
380375

381-
let mut diag = self.infcx.tcx.cannot_move_out_of(span, &place_description, origin);
376+
let mut diag = self.infcx.tcx.cannot_move_out_of(span, &place_description);
382377

383378
diag.span_label(upvar_span, "captured outer variable");
384379

@@ -391,14 +386,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
391386
self.infcx.tcx.cannot_move_out_of(
392387
span,
393388
&format!("`{}` which is behind a {}", place_desc, source_desc),
394-
origin,
395389
)
396390
}
397391
(_, _) => {
398392
self.infcx.tcx.cannot_move_out_of(
399393
span,
400394
&source.describe_for_unnamed_place(),
401-
origin,
402395
)
403396
}
404397
}

Diff for: src/librustc_mir/borrow_check/mutability_errors.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use syntax_pos::symbol::kw;
99

1010
use crate::borrow_check::MirBorrowckCtxt;
1111
use crate::borrow_check::error_reporting::BorrowedContentSource;
12-
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
12+
use crate::util::borrowck_errors::BorrowckErrors;
1313
use crate::util::collect_writes::FindAssignments;
1414
use crate::util::suggest_ref_mut;
1515
use rustc_errors::Applicability;
@@ -161,15 +161,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
161161

162162
let span = match error_access {
163163
AccessKind::Move => {
164-
err = self.infcx.tcx
165-
.cannot_move_out_of(span, &(item_msg + &reason), Origin::Mir);
164+
err = self.infcx.tcx.cannot_move_out_of(span, &(item_msg + &reason));
166165
err.span_label(span, "cannot move");
167166
err.buffer(&mut self.errors_buffer);
168167
return;
169168
}
170169
AccessKind::Mutate => {
171-
err = self.infcx.tcx
172-
.cannot_assign(span, &(item_msg + &reason), Origin::Mir);
170+
err = self.infcx.tcx.cannot_assign(span, &(item_msg + &reason));
173171
act = "assign";
174172
acted_on = "written";
175173
span
@@ -184,7 +182,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
184182
borrow_span,
185183
&item_msg,
186184
&reason,
187-
Origin::Mir,
188185
);
189186
borrow_spans.var_span_label(
190187
&mut err,

Diff for: src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::borrow_check::nll::region_infer::RegionInferenceContext;
44
use crate::borrow_check::nll::type_check::Locations;
55
use crate::borrow_check::nll::universal_regions::DefiningTy;
66
use crate::borrow_check::nll::ConstraintDescription;
7-
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
7+
use crate::util::borrowck_errors::BorrowckErrors;
88
use crate::borrow_check::Upvar;
99
use rustc::hir::def_id::DefId;
1010
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
@@ -489,7 +489,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
489489

490490
let mut diag = infcx
491491
.tcx
492-
.borrowed_data_escapes_closure(span, escapes_from, Origin::Mir);
492+
.borrowed_data_escapes_closure(span, escapes_from);
493493

494494
if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span {
495495
diag.span_label(

0 commit comments

Comments
 (0)