Skip to content

Commit bba514b

Browse files
committed
Revert "Use Predicate ConstraintCategory when normalizing"
This reverts commit aae37f8.
1 parent df34db9 commit bba514b

File tree

14 files changed

+15
-172
lines changed

14 files changed

+15
-172
lines changed

compiler/rustc_borrowck/src/constraints/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ pub(crate) struct OutlivesConstraintSet<'tcx> {
2121

2222
impl<'tcx> OutlivesConstraintSet<'tcx> {
2323
pub(crate) fn push(&mut self, constraint: OutlivesConstraint<'tcx>) {
24-
debug!("OutlivesConstraintSet::push({:?})", constraint);
24+
debug!(
25+
"OutlivesConstraintSet::push({:?}: {:?} @ {:?}",
26+
constraint.sup, constraint.sub, constraint.locations
27+
);
2528
if constraint.sup == constraint.sub {
2629
// 'a: 'a is pretty uninteresting
2730
return;

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::session_diagnostics::{
3131
};
3232

3333
use super::{OutlivesSuggestionBuilder, RegionName};
34-
use crate::region_infer::{BlameConstraint, ExtraConstraintInfo};
34+
use crate::region_infer::BlameConstraint;
3535
use crate::{
3636
nll::ConstraintDescription,
3737
region_infer::{values::RegionElement, TypeTest},
@@ -354,11 +354,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
354354
) {
355355
debug!("report_region_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr);
356356

357-
let (blame_constraint, extra_info) =
358-
self.regioncx.best_blame_constraint(fr, fr_origin, |r| {
357+
let BlameConstraint { category, cause, variance_info, .. } = self
358+
.regioncx
359+
.best_blame_constraint(fr, fr_origin, |r| {
359360
self.regioncx.provides_universal_region(r, fr, outlived_fr)
360-
});
361-
let BlameConstraint { category, cause, variance_info, .. } = blame_constraint;
361+
})
362+
.0;
362363

363364
debug!("report_region_error: category={:?} {:?} {:?}", category, cause, variance_info);
364365

@@ -467,14 +468,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
467468
}
468469
}
469470

470-
for extra in extra_info {
471-
match extra {
472-
ExtraConstraintInfo::PlaceholderFromPredicate(span) => {
473-
diag.span_note(span, format!("due to current limitations in the borrow checker, this implies a `'static` lifetime"));
474-
}
475-
}
476-
}
477-
478471
self.buffer_error(diag);
479472
}
480473

@@ -566,7 +559,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
566559
/// LL | ref_obj(x)
567560
/// | ^^^^^^^^^^ `x` escapes the function body here
568561
/// ```
569-
#[instrument(level = "debug", skip(self))]
570562
fn report_escaping_data_error(
571563
&self,
572564
errci: &ErrorConstraintInfo<'tcx>,

compiler/rustc_borrowck/src/type_check/canonical.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
104104
);
105105
}
106106

107-
#[instrument(level = "debug", skip(self))]
108107
pub(super) fn normalize_and_prove_instantiated_predicates(
109108
&mut self,
110109
// Keep this parameter for now, in case we start using
@@ -119,9 +118,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
119118
.zip(instantiated_predicates.spans.into_iter())
120119
{
121120
debug!(?predicate);
122-
let category = ConstraintCategory::Predicate(span);
123-
let predicate = self.normalize_with_category(predicate, locations, category);
124-
self.prove_predicate(predicate, locations, category);
121+
let predicate = self.normalize(predicate, locations);
122+
self.prove_predicate(predicate, locations, ConstraintCategory::Predicate(span));
125123
}
126124
}
127125

@@ -157,27 +155,15 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
157155
})
158156
}
159157

160-
pub(super) fn normalize<T>(&mut self, value: T, location: impl NormalizeLocation) -> T
161-
where
162-
T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
163-
{
164-
self.normalize_with_category(value, location, ConstraintCategory::Boring)
165-
}
166-
167158
#[instrument(skip(self), level = "debug")]
168-
pub(super) fn normalize_with_category<T>(
169-
&mut self,
170-
value: T,
171-
location: impl NormalizeLocation,
172-
category: ConstraintCategory<'tcx>,
173-
) -> T
159+
pub(super) fn normalize<T>(&mut self, value: T, location: impl NormalizeLocation) -> T
174160
where
175161
T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx,
176162
{
177163
let param_env = self.param_env;
178164
self.fully_perform_op(
179165
location.to_locations(),
180-
category,
166+
ConstraintCategory::Boring,
181167
param_env.and(type_op::normalize::Normalize::new(value)),
182168
)
183169
.unwrap_or_else(|NoSolution| {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
312312
}
313313

314314
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
315-
debug!(?constant, ?location, "visit_constant");
316-
317315
self.super_constant(constant, location);
318316
let ty = self.sanitize_type(constant, constant.literal.ty());
319317

@@ -1813,8 +1811,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18131811
}
18141812

18151813
fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
1816-
debug!(?op, ?location, "check_operand");
1817-
18181814
if let Operand::Constant(constant) = op {
18191815
let maybe_uneval = match constant.literal {
18201816
ConstantKind::Ty(ct) => match ct.kind() {

compiler/rustc_trait_selection/src/traits/query/normalize.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,10 @@ impl<'cx, 'tcx> AtExt<'tcx> for At<'cx, 'tcx> {
4848
T: TypeFoldable<'tcx>,
4949
{
5050
debug!(
51-
"normalize::<{}>(value={:?}, param_env={:?}, cause={:?})",
51+
"normalize::<{}>(value={:?}, param_env={:?})",
5252
std::any::type_name::<T>(),
5353
value,
5454
self.param_env,
55-
self.cause,
5655
);
5756
if !needs_normalization(&value, self.param_env.reveal()) {
5857
return Ok(Normalized { value, obligations: vec![] });

src/test/ui/generic-associated-types/bugs/hrtb-implied-2.rs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/test/ui/generic-associated-types/bugs/hrtb-implied-2.stderr

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/test/ui/generic-associated-types/bugs/hrtb-implied-3.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/test/ui/generic-associated-types/bugs/hrtb-implied-3.stderr

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/test/ui/generic-associated-types/trait-objects.extended.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ LL | x.size_hint().0
1111
| |
1212
| `x` escapes the function body here
1313
| argument requires that `'1` must outlive `'static`
14-
|
15-
= note: due to current limitations in the borrow checker, this implies a `'static` lifetime
1614

1715
error: aborting due to previous error
1816

src/test/ui/higher-rank-trait-bounds/hrtb-just-for-static.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ LL | fn give_some<'a>() {
1414
| -- lifetime `'a` defined here
1515
LL | want_hrtb::<&'a u32>()
1616
| ^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
17-
|
18-
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
19-
--> $DIR/hrtb-just-for-static.rs:9:15
20-
|
21-
LL | where T : for<'a> Foo<&'a isize>
22-
| ^^^^^^^^^^^^^^^^^^^^^^
2317

2418
error: implementation of `Foo` is not general enough
2519
--> $DIR/hrtb-just-for-static.rs:30:5

src/test/ui/higher-rank-trait-bounds/hrtb-perfect-forwarding.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ LL | fn foo_hrtb_bar_not<'b, T>(mut t: T)
4646
...
4747
LL | foo_hrtb_bar_not(&mut t);
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static`
49-
|
50-
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
51-
--> $DIR/hrtb-perfect-forwarding.rs:37:8
52-
|
53-
LL | T: for<'a> Foo<&'a isize> + Bar<&'b isize>,
54-
| ^^^^^^^^^^^^^^^^^^^^^^
5549

5650
error: implementation of `Bar` is not general enough
5751
--> $DIR/hrtb-perfect-forwarding.rs:43:5

src/test/ui/issues/issue-26217.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ LL | fn bar<'a>() {
55
| -- lifetime `'a` defined here
66
LL | foo::<&'a i32>();
77
| ^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
8-
|
9-
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
10-
--> $DIR/issue-26217.rs:1:30
11-
|
12-
LL | fn foo<T>() where for<'a> T: 'a {}
13-
| ^^
148

159
error: aborting due to previous error
1610

src/test/ui/nll/type-test-universe.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ LL | fn test2<'a>() {
1111
| -- lifetime `'a` defined here
1212
LL | outlives_forall::<Value<'a>>();
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
14-
|
15-
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
16-
--> $DIR/type-test-universe.rs:6:16
17-
|
18-
LL | for<'u> T: 'u,
19-
| ^^
2014

2115
error: aborting due to 2 previous errors
2216

0 commit comments

Comments
 (0)