Skip to content

Commit 9cc7bd7

Browse files
committed
Review comments
1 parent 83ce1aa commit 9cc7bd7

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
151151
if mention_capture {
152152
spans.push(sup_origin.span());
153153
}
154-
// We sort the spans *ignoring* expansion context. Below, the closure logic is repeated
155-
// because one method expects a closure taking `&Span` and the other `&mut Span`.
156-
spans.sort_by_key(|span| (span.lo(), span.hi()));
154+
// We dedup the spans *ignoring* expansion context.
155+
spans.sort();
157156
spans.dedup_by_key(|span| (span.lo(), span.hi()));
158157

159158
// We try to make the output have fewer overlapping spans if possible.
@@ -183,7 +182,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
183182
err.span_note(*bound, "`'static` lifetime requirement introduced by this bound");
184183
}
185184
if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = sub_origin {
186-
if let ObligationCauseCode::BlockTailExpression(hir_id) = &cause.code {
185+
if let ObligationCauseCode::ReturnValue(hir_id)
186+
| ObligationCauseCode::BlockTailExpression(hir_id) = &cause.code
187+
{
187188
let parent_id = tcx.hir().get_parent_item(*hir_id);
188189
if let Some(fn_decl) = tcx.hir().fn_decl_by_hir_id(parent_id) {
189190
let mut span: MultiSpan = fn_decl.output.span().into();

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub enum RegionResolutionError<'tcx> {
9797
Region<'tcx>,
9898
SubregionOrigin<'tcx>,
9999
Region<'tcx>,
100-
Vec<Span>,
100+
Vec<Span>, // All the influences on a given value that didn't meet its constraints.
101101
),
102102

103103
/// Indicates a `'b: 'a` constraint where `'a` is in a universe that
@@ -570,9 +570,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
570570
// have to revisit this portion of the code and
571571
// think hard about it. =) -- nikomatsakis
572572

573-
// Obtain the spans for all the capture points for
573+
// Obtain the spans for all the places that can
574+
// influence the constraints on this value for
574575
// richer diagnostics in `static_impl_trait`.
575-
let captures: Vec<Span> = self
576+
let influences: Vec<Span> = self
576577
.data
577578
.constraints
578579
.iter()
@@ -590,7 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
590591
&mut dup_vec,
591592
node_vid,
592593
errors,
593-
captures,
594+
influences,
594595
);
595596
}
596597
}
@@ -645,7 +646,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
645646
dup_vec: &mut IndexVec<RegionVid, Option<RegionVid>>,
646647
node_idx: RegionVid,
647648
errors: &mut Vec<RegionResolutionError<'tcx>>,
648-
captures: Vec<Span>,
649+
influences: Vec<Span>,
649650
) {
650651
// Errors in expanding nodes result from a lower-bound that is
651652
// not contained by an upper-bound.
@@ -700,7 +701,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
700701
lower_bound.region,
701702
upper_bound.origin.clone(),
702703
upper_bound.region,
703-
captures,
704+
influences,
704705
));
705706
return;
706707
}

0 commit comments

Comments
 (0)