Skip to content

Commit cafa066

Browse files
committed
Fix tidy error
1 parent 025be1e commit cafa066

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ trait TypeOpInfo<'tcx> {
181181
bound: placeholder.bound,
182182
});
183183

184-
let error_region = None;
185-
186184
debug!(?placeholder_region);
187185

186+
// FIXME: this is obviously weird; this whole argument now does nothing and maybe
187+
// it should?
188188
let span = cause.span;
189-
let nice_error = self.nice_error(mbcx, cause, placeholder_region, error_region);
189+
let nice_error = self.nice_error(mbcx, cause, placeholder_region, None);
190190

191191
debug!(?nice_error);
192192

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -210,33 +210,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
210210
let mut suggestions = vec![];
211211
let hir = self.infcx.tcx.hir();
212212

213-
// find generic associated types in the given region 'lower_bound'
214-
// FIXME: this should find one of the special-case blamable
215-
// new constraints instead!
216-
//let gat_id_and_generics = vec![];
217-
//debug!(?gat_id_and_generics);
218-
219213
// find higher-ranked trait bounds bounded to the generic associated types
220214
let hrtb_bounds = vec![];
221215
/*
222-
gat_id_and_generics.iter().flatten().for_each(|(gat_hir_id, generics)| {
223-
for pred in generics.predicates {
224-
let BoundPredicate(WhereBoundPredicate { bound_generic_params, bounds, .. }) = pred
225-
else {
226-
continue;
227-
};
228-
if bound_generic_params
229-
.iter()
230-
.rfind(|bgp| self.infcx.tcx.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
231-
.is_some()
232-
{
233-
for bound in *bounds {
234-
hrtb_bounds.push(bound);
235-
}
236-
}
237-
}
238-
});
239-
debug!(?hrtb_bounds);
216+
// FIXME: the best we can do is look at the representative, using something like:
217+
let scc = self.regioncx.constraint_sccs().scc(lower_bound);
218+
let Some(representative) =
219+
self.regioncx.constraint_sccs().annotation(scc).placeholder_representative()
220+
else {
221+
return;
222+
};
240223
*/
241224

242225
hrtb_bounds.iter().for_each(|bound| {

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl RegionTracker {
153153

154154
/// If the representative is a placeholder, return it,
155155
/// otherwise return None.
156-
fn placeholder_representative(&self) -> Option<RegionVid> {
156+
pub(crate) fn placeholder_representative(&self) -> Option<RegionVid> {
157157
if self.representative_origin == RepresentativeOrigin::Placeholder {
158158
Some(self.representative)
159159
} else {
@@ -1668,7 +1668,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
16681668
let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
16691669
debug!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,);
16701670

1671-
for error_element in self.scc_values.elements_contained_in(longer_fr_scc) {
1671+
if let Some(error_element) = self.scc_values.elements_contained_in(longer_fr_scc).next() {
16721672
debug!(
16731673
"check_bound_universal_region, error_element: {error_element:?} for placeholder {placeholder:?} in scc: {longer_fr_scc:?}"
16741674
);
@@ -1678,11 +1678,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
16781678
error_element,
16791679
placeholder,
16801680
});
1681-
16821681
// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
1683-
break;
1682+
} else {
1683+
debug!("check_bound_universal_region: all bounds satisfied");
16841684
}
1685-
debug!("check_bound_universal_region: all bounds satisfied");
16861685
}
16871686

16881687
#[instrument(level = "debug", skip(self, infcx, errors_buffer))]

0 commit comments

Comments
 (0)