Skip to content

Commit e3021eb

Browse files
committed
Preserve the Span from prove_predicate all the way to registering opaque types
1 parent 9e016a8 commit e3021eb

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
9898
query_key: ParamEnvAnd<'tcx, Self>,
9999
infcx: &InferCtxt<'tcx>,
100100
output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
101+
span: Span,
101102
) -> Result<
102103
(
103104
Self::QueryResponse,
@@ -118,7 +119,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
118119

119120
let InferOk { value, obligations } = infcx
120121
.instantiate_nll_query_response_and_region_obligations(
121-
&ObligationCause::dummy(),
122+
&ObligationCause::dummy_with_span(span),
122123
old_param_env,
123124
&canonical_var_values,
124125
canonical_result,
@@ -160,7 +161,7 @@ where
160161

161162
let mut region_constraints = QueryRegionConstraints::default();
162163
let (output, error_info, mut obligations, _) =
163-
Q::fully_perform_into(self, infcx, &mut region_constraints).map_err(|_| {
164+
Q::fully_perform_into(self, infcx, &mut region_constraints, span).map_err(|_| {
164165
infcx.dcx().span_delayed_bug(span, format!("error performing {self:?}"))
165166
})?;
166167

@@ -178,6 +179,7 @@ where
178179
obligation.param_env.and(ProvePredicate::new(obligation.predicate)),
179180
infcx,
180181
&mut region_constraints,
182+
span,
181183
) {
182184
Ok(((), _, new, certainty)) => {
183185
obligations.extend(new);

tests/ui/generic-associated-types/issue-90014-tait2.stderr

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
error[E0792]: expected generic lifetime parameter, found `'a`
2+
--> $DIR/issue-90014-tait2.rs:27:9
3+
|
4+
LL | type Fut<'a> = impl Future<Output = ()>;
5+
| -- this generic parameter must be used with a generic lifetime parameter
6+
...
7+
LL | Box::new((async { () },))
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
29

310
error: aborting due to 1 previous error
411

tests/ui/type-alias-impl-trait/hkl_forbidden2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(type_alias_impl_trait)]
2-
//~^ ERROR: expected generic lifetime parameter, found `'a`
32

43
type Opaque<'a> = impl Sized + 'a;
54

@@ -13,6 +12,7 @@ impl<'a> Trait<'a> for () {
1312

1413
fn test() -> &'static dyn for<'a> Trait<'a, Assoc = Opaque<'a>> {
1514
&()
15+
//~^ ERROR: expected generic lifetime parameter, found `'a`
1616
}
1717

1818
fn main() {}

tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
error[E0792]: expected generic lifetime parameter, found `'a`
2+
--> $DIR/hkl_forbidden2.rs:14:5
3+
|
4+
LL | type Opaque<'a> = impl Sized + 'a;
5+
| -- this generic parameter must be used with a generic lifetime parameter
6+
...
7+
LL | &()
8+
| ^^^
29

310
error: aborting due to 1 previous error
411

0 commit comments

Comments
 (0)