add RegionName::span
This commit is contained in:
parent
8ad7bc3f42
commit
c27633489d
2 changed files with 19 additions and 13 deletions
|
@ -19,7 +19,7 @@ use crate::borrow_check::{
|
|||
MirBorrowckCtxt,
|
||||
};
|
||||
|
||||
use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource};
|
||||
use super::{OutlivesSuggestionBuilder, RegionName};
|
||||
|
||||
impl ConstraintDescription for ConstraintCategory {
|
||||
fn description(&self) -> &'static str {
|
||||
|
@ -396,18 +396,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
diag.span_label(upvar_span, "variable captured here");
|
||||
}
|
||||
|
||||
match self.give_region_a_name(*outlived_fr).unwrap().source {
|
||||
RegionNameSource::NamedEarlyBoundRegion(fr_span)
|
||||
| RegionNameSource::NamedFreeRegion(fr_span)
|
||||
| RegionNameSource::SynthesizedFreeEnvRegion(fr_span, _)
|
||||
| RegionNameSource::CannotMatchHirTy(fr_span, _)
|
||||
| RegionNameSource::MatchedHirTy(fr_span)
|
||||
| RegionNameSource::MatchedAdtAndSegment(fr_span)
|
||||
| RegionNameSource::AnonRegionFromUpvar(fr_span, _)
|
||||
| RegionNameSource::AnonRegionFromOutput(fr_span, _, _) => {
|
||||
diag.span_label(fr_span, "inferred to be a `FnMut` closure");
|
||||
}
|
||||
_ => {}
|
||||
if let Some(fr_span) = self.give_region_a_name(*outlived_fr).unwrap().span() {
|
||||
diag.span_label(fr_span, "inferred to be a `FnMut` closure");
|
||||
}
|
||||
|
||||
diag.note(
|
||||
|
|
|
@ -68,6 +68,22 @@ impl RegionName {
|
|||
}
|
||||
}
|
||||
|
||||
crate fn span(&self) -> Option<Span> {
|
||||
match self.source {
|
||||
RegionNameSource::Static => None,
|
||||
RegionNameSource::NamedEarlyBoundRegion(span)
|
||||
| RegionNameSource::NamedFreeRegion(span)
|
||||
| RegionNameSource::SynthesizedFreeEnvRegion(span, _)
|
||||
| RegionNameSource::CannotMatchHirTy(span, _)
|
||||
| RegionNameSource::MatchedHirTy(span)
|
||||
| RegionNameSource::MatchedAdtAndSegment(span)
|
||||
| RegionNameSource::AnonRegionFromUpvar(span, _)
|
||||
| RegionNameSource::AnonRegionFromOutput(span, _, _)
|
||||
| RegionNameSource::AnonRegionFromYieldTy(span, _)
|
||||
| RegionNameSource::AnonRegionFromAsyncFn(span) => Some(span),
|
||||
}
|
||||
}
|
||||
|
||||
crate fn highlight_region_name(&self, diag: &mut DiagnosticBuilder<'_>) {
|
||||
match &self.source {
|
||||
RegionNameSource::NamedFreeRegion(span)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue