Skip to content

Commit

Permalink
Preserve the Span from prove_predicate all the way to registering…
Browse files Browse the repository at this point in the history
… opaque types
  • Loading branch information
oli-obk committed Feb 22, 2024
1 parent 9e016a8 commit e3021eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
query_key: ParamEnvAnd<'tcx, Self>,
infcx: &InferCtxt<'tcx>,
output_query_region_constraints: &mut QueryRegionConstraints<'tcx>,
span: Span,
) -> Result<
(
Self::QueryResponse,
Expand All @@ -118,7 +119,7 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't

let InferOk { value, obligations } = infcx
.instantiate_nll_query_response_and_region_obligations(
&ObligationCause::dummy(),
&ObligationCause::dummy_with_span(span),
old_param_env,
&canonical_var_values,
canonical_result,
Expand Down Expand Up @@ -160,7 +161,7 @@ where

let mut region_constraints = QueryRegionConstraints::default();
let (output, error_info, mut obligations, _) =
Q::fully_perform_into(self, infcx, &mut region_constraints).map_err(|_| {
Q::fully_perform_into(self, infcx, &mut region_constraints, span).map_err(|_| {
infcx.dcx().span_delayed_bug(span, format!("error performing {self:?}"))
})?;

Expand All @@ -178,6 +179,7 @@ where
obligation.param_env.and(ProvePredicate::new(obligation.predicate)),
infcx,
&mut region_constraints,
span,
) {
Ok(((), _, new, certainty)) => {
obligations.extend(new);
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/generic-associated-types/issue-90014-tait2.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
error[E0792]: expected generic lifetime parameter, found `'a`
--> $DIR/issue-90014-tait2.rs:27:9
|
LL | type Fut<'a> = impl Future<Output = ()>;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | Box::new((async { () },))
| ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/type-alias-impl-trait/hkl_forbidden2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(type_alias_impl_trait)]
//~^ ERROR: expected generic lifetime parameter, found `'a`

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

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

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

fn main() {}
7 changes: 7 additions & 0 deletions tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
error[E0792]: expected generic lifetime parameter, found `'a`
--> $DIR/hkl_forbidden2.rs:14:5
|
LL | type Opaque<'a> = impl Sized + 'a;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | &()
| ^^^

error: aborting due to 1 previous error

Expand Down

0 comments on commit e3021eb

Please sign in to comment.