Skip to content

Commit 0bddce5

Browse files
Normalize assumed_wf_types after wfchecking is complete, for better spans
1 parent ca554ef commit 0bddce5

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,22 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
9797
let infcx = &tcx.infer_ctxt().build();
9898
let ocx = ObligationCtxt::new(infcx);
9999

100-
let assumed_wf_types = ocx.assumed_wf_types(param_env, span, body_def_id);
101-
102100
let mut wfcx = WfCheckingCtxt { ocx, span, body_id, param_env };
103101

104102
if !tcx.features().trivial_bounds {
105103
wfcx.check_false_global_bounds()
106104
}
107105
f(&mut wfcx);
106+
107+
let assumed_wf_types = wfcx.ocx.assumed_wf_types(param_env, span, body_def_id);
108+
let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
109+
108110
let errors = wfcx.select_all_or_error();
109111
if !errors.is_empty() {
110112
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
111113
return;
112114
}
113115

114-
let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
115116
let outlives_environment =
116117
OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
117118

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied
2-
--> $DIR/issue-35570.rs:8:16
2+
--> $DIR/issue-35570.rs:8:40
33
|
44
LL | fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()`
5+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()`
66

77
error: aborting due to previous error
88

src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied
2-
--> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:25
2+
--> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:49
33
|
44
LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T`
66
|
77
help: consider restricting type parameter `T`
88
|

src/test/ui/specialization/min_specialization/issue-79224.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ impl ToString for Cow<'_, str> {
1717

1818
impl<B: ?Sized> Display for Cow<'_, B> {
1919
//~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
20-
//~| ERROR: the trait bound `B: Clone` is not satisfied [E0277]
2120
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21+
//~^ ERROR: the trait bound `B: Clone` is not satisfied [E0277]
2222
write!(f, "foo")
2323
}
2424
}

src/test/ui/specialization/min_specialization/issue-79224.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `B: Clone` is not satisfied
2-
--> $DIR/issue-79224.rs:18:29
2+
--> $DIR/issue-79224.rs:18:17
33
|
44
LL | impl<B: ?Sized> Display for Cow<'_, B> {
5-
| ^^^^^^^^^^ the trait `Clone` is not implemented for `B`
5+
| ^^^^^^^ the trait `Clone` is not implemented for `B`
66
|
77
= note: required for `B` to implement `ToOwned`
88
help: consider further restricting this bound
@@ -11,10 +11,10 @@ LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
1111
| +++++++++++++++++++
1212

1313
error[E0277]: the trait bound `B: Clone` is not satisfied
14-
--> $DIR/issue-79224.rs:18:29
14+
--> $DIR/issue-79224.rs:20:12
1515
|
16-
LL | impl<B: ?Sized> Display for Cow<'_, B> {
17-
| ^^^^^^^^^^ the trait `Clone` is not implemented for `B`
16+
LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17+
| ^^^^^ the trait `Clone` is not implemented for `B`
1818
|
1919
= note: required for `B` to implement `ToOwned`
2020
help: consider further restricting this bound

src/test/ui/traits/issue-91594.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied
2-
--> $DIR/issue-91594.rs:10:1
2+
--> $DIR/issue-91594.rs:10:6
33
|
44
LL | impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
66
|
77
= help: the trait `HasComponent<<Foo as Component<Foo>>::Interface>` is implemented for `Foo`
88
note: required for `Foo` to implement `Component<Foo>`

src/test/ui/wf/issue-103573.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0277]: the trait bound `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB: TraitA` is not satisfied
2-
--> $DIR/issue-103573.rs:18:17
2+
--> $DIR/issue-103573.rs:18:18
33
|
44
LL | fn g<'a>(_: &<<Self::TypeC<'a> as TraitB>::TypeB as TraitA>::TypeA);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitA` is not implemented for `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TraitA` is not implemented for `<<Self as TraitC<E>>::TypeC<'a> as TraitB>::TypeB`
66
|
77
help: consider further restricting the associated type
88
|

0 commit comments

Comments
 (0)