Skip to content

Commit 3f34196

Browse files
committed
Remove redundant argument from subdiagnostic method
1 parent 7ba82d6 commit 3f34196

File tree

38 files changed

+361
-542
lines changed

38 files changed

+361
-542
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+54-84
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
228228
seen_spans.insert(move_span);
229229
}
230230

231-
use_spans.var_path_only_subdiag(self.dcx(), &mut err, desired_action);
231+
use_spans.var_path_only_subdiag(&mut err, desired_action);
232232

233233
if !is_loop_move {
234234
err.span_label(
@@ -303,24 +303,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
303303
if needs_note {
304304
if let Some(local) = place.as_local() {
305305
let span = self.body.local_decls[local].source_info.span;
306-
err.subdiagnostic(
307-
self.dcx(),
308-
crate::session_diagnostics::TypeNoCopy::Label {
309-
is_partial_move,
310-
ty,
311-
place: &note_msg,
312-
span,
313-
},
314-
);
306+
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Label {
307+
is_partial_move,
308+
ty,
309+
place: &note_msg,
310+
span,
311+
});
315312
} else {
316-
err.subdiagnostic(
317-
self.dcx(),
318-
crate::session_diagnostics::TypeNoCopy::Note {
319-
is_partial_move,
320-
ty,
321-
place: &note_msg,
322-
},
323-
);
313+
err.subdiagnostic(crate::session_diagnostics::TypeNoCopy::Note {
314+
is_partial_move,
315+
ty,
316+
place: &note_msg,
317+
});
324318
};
325319
}
326320

@@ -597,7 +591,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
597591
E0381,
598592
"{used} binding {desc}{isnt_initialized}"
599593
);
600-
use_spans.var_path_only_subdiag(self.dcx(), &mut err, desired_action);
594+
use_spans.var_path_only_subdiag(&mut err, desired_action);
601595

602596
if let InitializationRequiringAction::PartialAssignment
603597
| InitializationRequiringAction::Assignment = desired_action
@@ -1410,13 +1404,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14101404
&value_msg,
14111405
);
14121406

1413-
borrow_spans.var_path_only_subdiag(
1414-
self.dcx(),
1415-
&mut err,
1416-
crate::InitializationRequiringAction::Borrow,
1417-
);
1407+
borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
14181408

1419-
move_spans.var_subdiag(self.dcx(), &mut err, None, |kind, var_span| {
1409+
move_spans.var_subdiag(&mut err, None, |kind, var_span| {
14201410
use crate::session_diagnostics::CaptureVarCause::*;
14211411
match kind {
14221412
hir::ClosureKind::Coroutine(_) => MoveUseInCoroutine { var_span },
@@ -1468,7 +1458,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14681458
borrow_span,
14691459
&self.describe_any_place(borrow.borrowed_place.as_ref()),
14701460
);
1471-
borrow_spans.var_subdiag(self.dcx(), &mut err, Some(borrow.kind), |kind, var_span| {
1461+
borrow_spans.var_subdiag(&mut err, Some(borrow.kind), |kind, var_span| {
14721462
use crate::session_diagnostics::CaptureVarCause::*;
14731463
let place = &borrow.borrowed_place;
14741464
let desc_place = self.describe_any_place(place.as_ref());
@@ -1633,7 +1623,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16331623
"mutably borrow",
16341624
);
16351625
borrow_spans.var_subdiag(
1636-
self.dcx(),
16371626
&mut err,
16381627
Some(BorrowKind::Mut { kind: MutBorrowKind::ClosureCapture }),
16391628
|kind, var_span| {
@@ -1730,64 +1719,45 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17301719
};
17311720

17321721
if issued_spans == borrow_spans {
1733-
borrow_spans.var_subdiag(
1734-
self.dcx(),
1735-
&mut err,
1736-
Some(gen_borrow_kind),
1737-
|kind, var_span| {
1738-
use crate::session_diagnostics::CaptureVarCause::*;
1739-
match kind {
1740-
hir::ClosureKind::Coroutine(_) => BorrowUsePlaceCoroutine {
1741-
place: desc_place,
1742-
var_span,
1743-
is_single_var: false,
1744-
},
1745-
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1746-
BorrowUsePlaceClosure {
1747-
place: desc_place,
1748-
var_span,
1749-
is_single_var: false,
1750-
}
1751-
}
1722+
borrow_spans.var_subdiag(&mut err, Some(gen_borrow_kind), |kind, var_span| {
1723+
use crate::session_diagnostics::CaptureVarCause::*;
1724+
match kind {
1725+
hir::ClosureKind::Coroutine(_) => BorrowUsePlaceCoroutine {
1726+
place: desc_place,
1727+
var_span,
1728+
is_single_var: false,
1729+
},
1730+
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1731+
BorrowUsePlaceClosure { place: desc_place, var_span, is_single_var: false }
17521732
}
1753-
},
1754-
);
1733+
}
1734+
});
17551735
} else {
1756-
issued_spans.var_subdiag(
1757-
self.dcx(),
1758-
&mut err,
1759-
Some(issued_borrow.kind),
1760-
|kind, var_span| {
1761-
use crate::session_diagnostics::CaptureVarCause::*;
1762-
let borrow_place = &issued_borrow.borrowed_place;
1763-
let borrow_place_desc = self.describe_any_place(borrow_place.as_ref());
1764-
match kind {
1765-
hir::ClosureKind::Coroutine(_) => {
1766-
FirstBorrowUsePlaceCoroutine { place: borrow_place_desc, var_span }
1767-
}
1768-
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1769-
FirstBorrowUsePlaceClosure { place: borrow_place_desc, var_span }
1770-
}
1736+
issued_spans.var_subdiag(&mut err, Some(issued_borrow.kind), |kind, var_span| {
1737+
use crate::session_diagnostics::CaptureVarCause::*;
1738+
let borrow_place = &issued_borrow.borrowed_place;
1739+
let borrow_place_desc = self.describe_any_place(borrow_place.as_ref());
1740+
match kind {
1741+
hir::ClosureKind::Coroutine(_) => {
1742+
FirstBorrowUsePlaceCoroutine { place: borrow_place_desc, var_span }
17711743
}
1772-
},
1773-
);
1744+
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1745+
FirstBorrowUsePlaceClosure { place: borrow_place_desc, var_span }
1746+
}
1747+
}
1748+
});
17741749

1775-
borrow_spans.var_subdiag(
1776-
self.dcx(),
1777-
&mut err,
1778-
Some(gen_borrow_kind),
1779-
|kind, var_span| {
1780-
use crate::session_diagnostics::CaptureVarCause::*;
1781-
match kind {
1782-
hir::ClosureKind::Coroutine(_) => {
1783-
SecondBorrowUsePlaceCoroutine { place: desc_place, var_span }
1784-
}
1785-
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1786-
SecondBorrowUsePlaceClosure { place: desc_place, var_span }
1787-
}
1750+
borrow_spans.var_subdiag(&mut err, Some(gen_borrow_kind), |kind, var_span| {
1751+
use crate::session_diagnostics::CaptureVarCause::*;
1752+
match kind {
1753+
hir::ClosureKind::Coroutine(_) => {
1754+
SecondBorrowUsePlaceCoroutine { place: desc_place, var_span }
17881755
}
1789-
},
1790-
);
1756+
hir::ClosureKind::Closure | hir::ClosureKind::CoroutineClosure(_) => {
1757+
SecondBorrowUsePlaceClosure { place: desc_place, var_span }
1758+
}
1759+
}
1760+
});
17911761
}
17921762

17931763
if union_type_name != "" {
@@ -2961,7 +2931,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
29612931
err.span_label(borrow_span, "borrowed value does not live long enough");
29622932
err.span_label(drop_span, format!("`{name}` dropped here while still borrowed"));
29632933

2964-
borrow_spans.args_subdiag(self.dcx(), &mut err, |args_span| {
2934+
borrow_spans.args_subdiag(&mut err, |args_span| {
29652935
crate::session_diagnostics::CaptureArgLabel::Capture {
29662936
is_within: borrow_spans.for_coroutine(),
29672937
args_span,
@@ -3219,7 +3189,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
32193189
None,
32203190
);
32213191

3222-
borrow_spans.args_subdiag(self.dcx(), &mut err, |args_span| {
3192+
borrow_spans.args_subdiag(&mut err, |args_span| {
32233193
crate::session_diagnostics::CaptureArgLabel::Capture {
32243194
is_within: borrow_spans.for_coroutine(),
32253195
args_span,
@@ -3680,7 +3650,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
36803650
"assign",
36813651
);
36823652

3683-
loan_spans.var_subdiag(self.dcx(), &mut err, Some(loan.kind), |kind, var_span| {
3653+
loan_spans.var_subdiag(&mut err, Some(loan.kind), |kind, var_span| {
36843654
use crate::session_diagnostics::CaptureVarCause::*;
36853655
match kind {
36863656
hir::ClosureKind::Coroutine(_) => BorrowUseInCoroutine { var_span },
@@ -3698,7 +3668,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
36983668

36993669
let mut err = self.cannot_assign_to_borrowed(span, loan_span, &descr_place);
37003670

3701-
loan_spans.var_subdiag(self.dcx(), &mut err, Some(loan.kind), |kind, var_span| {
3671+
loan_spans.var_subdiag(&mut err, Some(loan.kind), |kind, var_span| {
37023672
use crate::session_diagnostics::CaptureVarCause::*;
37033673
match kind {
37043674
hir::ClosureKind::Coroutine(_) => BorrowUseInCoroutine { var_span },

0 commit comments

Comments
 (0)