mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Remove RegionHighlightMode::tcx
.
It's easier to pass it in to the one method that needs it (`highlighting_region_vid`) than to store it in the type. This means `RegionHighlightMode` can impl `Default`.
This commit is contained in:
parent
203c57dbe2
commit
1281d43942
@ -442,8 +442,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
span: Span,
|
||||
counter: usize,
|
||||
) -> RegionNameHighlight {
|
||||
let mut highlight = RegionHighlightMode::new(self.infcx.tcx);
|
||||
highlight.highlighting_region_vid(needle_fr, counter);
|
||||
let mut highlight = RegionHighlightMode::default();
|
||||
highlight.highlighting_region_vid(self.infcx.tcx, needle_fr, counter);
|
||||
let type_name =
|
||||
self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name;
|
||||
|
||||
@ -804,8 +804,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut highlight = RegionHighlightMode::new(tcx);
|
||||
highlight.highlighting_region_vid(fr, *self.next_region_name.try_borrow().unwrap());
|
||||
let mut highlight = RegionHighlightMode::default();
|
||||
highlight.highlighting_region_vid(tcx, fr, *self.next_region_name.try_borrow().unwrap());
|
||||
let type_name =
|
||||
self.infcx.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight)).name;
|
||||
|
||||
|
@ -385,7 +385,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
|
||||
let highlight_trait_ref = |trait_ref| Highlighted {
|
||||
tcx: self.tcx(),
|
||||
highlight: RegionHighlightMode::new(self.tcx()),
|
||||
highlight: RegionHighlightMode::default(),
|
||||
value: trait_ref,
|
||||
};
|
||||
|
||||
|
@ -67,9 +67,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> HighlightBuilder<'tcx> {
|
||||
fn build(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> RegionHighlightMode<'tcx> {
|
||||
fn build(ty: Ty<'tcx>) -> RegionHighlightMode<'tcx> {
|
||||
let mut builder =
|
||||
HighlightBuilder { highlight: RegionHighlightMode::new(tcx), counter: 1 };
|
||||
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1 };
|
||||
builder.visit_ty(ty);
|
||||
builder.highlight
|
||||
}
|
||||
@ -85,12 +85,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
let expected_highlight = HighlightBuilder::build(self.tcx(), expected);
|
||||
let expected_highlight = HighlightBuilder::build(expected);
|
||||
let expected = self
|
||||
.cx
|
||||
.extract_inference_diagnostics_data(expected.into(), Some(expected_highlight))
|
||||
.name;
|
||||
let found_highlight = HighlightBuilder::build(self.tcx(), found);
|
||||
let found_highlight = HighlightBuilder::build(found);
|
||||
let found =
|
||||
self.cx.extract_inference_diagnostics_data(found.into(), Some(found_highlight)).name;
|
||||
|
||||
|
@ -136,10 +136,8 @@ define_helper!(
|
||||
///
|
||||
/// Regions not selected by the region highlight mode are presently
|
||||
/// unaffected.
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct RegionHighlightMode<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
/// If enabled, when we see the selected region, use "`'N`"
|
||||
/// instead of the ordinary behavior.
|
||||
highlight_regions: [Option<(ty::Region<'tcx>, usize)>; 3],
|
||||
@ -155,14 +153,6 @@ pub struct RegionHighlightMode<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> RegionHighlightMode<'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
|
||||
Self {
|
||||
tcx,
|
||||
highlight_regions: Default::default(),
|
||||
highlight_bound_region: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// If `region` and `number` are both `Some`, invokes
|
||||
/// `highlighting_region`.
|
||||
pub fn maybe_highlighting_region(
|
||||
@ -188,8 +178,13 @@ impl<'tcx> RegionHighlightMode<'tcx> {
|
||||
}
|
||||
|
||||
/// Convenience wrapper for `highlighting_region`.
|
||||
pub fn highlighting_region_vid(&mut self, vid: ty::RegionVid, number: usize) {
|
||||
self.highlighting_region(ty::Region::new_var(self.tcx, vid), number)
|
||||
pub fn highlighting_region_vid(
|
||||
&mut self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
vid: ty::RegionVid,
|
||||
number: usize,
|
||||
) {
|
||||
self.highlighting_region(ty::Region::new_var(tcx, vid), number)
|
||||
}
|
||||
|
||||
/// Returns `Some(n)` with the number to use for the given region, if any.
|
||||
@ -1778,7 +1773,7 @@ impl<'a, 'tcx> FmtPrinter<'a, 'tcx> {
|
||||
printed_type_count: 0,
|
||||
type_length_limit,
|
||||
truncated: false,
|
||||
region_highlight_mode: RegionHighlightMode::new(tcx),
|
||||
region_highlight_mode: RegionHighlightMode::default(),
|
||||
ty_infer_name_resolver: None,
|
||||
const_infer_name_resolver: None,
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user