Skip to content

Commit 0eabba8

Browse files
committed
Renamed ppaux highlight region hook.
Changed `highlight_region_with_region` function(s) to `highlight_region_with_bound_region` to be more specific and less ambigious.
1 parent 350ed42 commit 0eabba8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/librustc/util/ppaux.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ thread_local! {
4040
thread_local! {
4141
/// Mechanism for highlighting of specific regions for display in NLL's 'borrow does not live
4242
/// long enough' errors. Contains a region to highlight and a counter to use.
43-
static HIGHLIGHT_REGION_FOR_REGION: Cell<Option<(ty::BoundRegion, usize)>> = Cell::new(None)
43+
static HIGHLIGHT_REGION_FOR_BOUND_REGION: Cell<Option<(ty::BoundRegion, usize)>> =
44+
Cell::new(None)
4445
}
4546

4647
macro_rules! gen_display_debug_body {
@@ -588,16 +589,16 @@ pub fn with_highlight_region_for_regionvid<R>(
588589
})
589590
}
590591

591-
fn get_highlight_region_for_region() -> Option<(ty::BoundRegion, usize)> {
592-
HIGHLIGHT_REGION_FOR_REGION.with(|hr| hr.get())
592+
fn get_highlight_region_for_bound_region() -> Option<(ty::BoundRegion, usize)> {
593+
HIGHLIGHT_REGION_FOR_BOUND_REGION.with(|hr| hr.get())
593594
}
594595

595-
pub fn with_highlight_region_for_region<R>(
596+
pub fn with_highlight_region_for_bound_region<R>(
596597
r: ty::BoundRegion,
597598
counter: usize,
598599
op: impl Fn() -> R
599600
) -> R {
600-
HIGHLIGHT_REGION_FOR_REGION.with(|hr| {
601+
HIGHLIGHT_REGION_FOR_BOUND_REGION.with(|hr| {
601602
assert_eq!(hr.get(), None);
602603
hr.set(Some((r, counter)));
603604
let r = op();
@@ -754,7 +755,7 @@ define_print! {
754755
return self.print_debug(f, cx);
755756
}
756757

757-
if let Some((region, counter)) = get_highlight_region_for_region() {
758+
if let Some((region, counter)) = get_highlight_region_for_bound_region() {
758759
if *self == region {
759760
return match *self {
760761
BrNamed(_, name) => write!(f, "{}", name),

src/librustc_mir/borrow_check/error_reporting.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc::ty;
2222
use rustc_data_structures::fx::FxHashSet;
2323
use rustc_data_structures::sync::Lrc;
2424
use rustc_errors::{Applicability, DiagnosticBuilder};
25-
use rustc::util::ppaux::with_highlight_region_for_region;
25+
use rustc::util::ppaux::with_highlight_region_for_bound_region;
2626
use syntax_pos::Span;
2727

2828
use super::borrow_set::BorrowData;
@@ -1358,24 +1358,28 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
13581358
}
13591359
}
13601360

1361+
/// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime
1362+
/// name where required.
13611363
fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
13621364
// We need to add synthesized lifetimes where appropriate. We do
13631365
// this by hooking into the pretty printer and telling it to label the
13641366
// lifetimes without names with the value `'0`.
13651367
match ty.sty {
13661368
ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _) |
13671369
ty::TyKind::Ref(ty::RegionKind::ReSkolemized(_, br), _, _) =>
1368-
with_highlight_region_for_region(*br, counter, || format!("{}", ty)),
1370+
with_highlight_region_for_bound_region(*br, counter, || format!("{}", ty)),
13691371
_ => format!("{}", ty),
13701372
}
13711373
}
13721374

1375+
/// Return the name of the provided `Ty` (that must be a reference)'s region with a
1376+
/// synthesized lifetime name where required.
13731377
fn get_region_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
13741378
match ty.sty {
13751379
ty::TyKind::Ref(region, _, _) => match region {
13761380
ty::RegionKind::ReLateBound(_, br) |
13771381
ty::RegionKind::ReSkolemized(_, br) =>
1378-
with_highlight_region_for_region(*br, counter, || format!("{}", region)),
1382+
with_highlight_region_for_bound_region(*br, counter, || format!("{}", region)),
13791383
_ => format!("{}", region),
13801384
}
13811385
_ => bug!("ty for annotation of borrow region is not a reference"),

0 commit comments

Comments
 (0)