about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-02-22 14:05:01 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-02-22 14:05:01 +0000
commite3021eb2452a28d9390542bf9a4fd618b431eceb (patch)
treec8b1cbcdf883d9f548520f610fe141b9edf6990f
parent9e016a8b847905dfabec3598da3e92c6287473f2 (diff)
Preserve the `Span` from `prove_predicate` all the way to registering opaque types
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs6
-rw-r--r--tests/ui/generic-associated-types/issue-90014-tait2.stderr7
-rw-r--r--tests/ui/type-alias-impl-trait/hkl_forbidden2.rs2
-rw-r--r--tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr7
4 files changed, 19 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
index fb09f094d37..8cf8de4509f 100644
--- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
@@ -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,
@@ -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,
@@ -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:?}"))
             })?;
 
@@ -178,6 +179,7 @@ where
                     obligation.param_env.and(ProvePredicate::new(obligation.predicate)),
                     infcx,
                     &mut region_constraints,
+                    span,
                 ) {
                     Ok(((), _, new, certainty)) => {
                         obligations.extend(new);
diff --git a/tests/ui/generic-associated-types/issue-90014-tait2.stderr b/tests/ui/generic-associated-types/issue-90014-tait2.stderr
index ed0b2085c88..58390032d92 100644
--- a/tests/ui/generic-associated-types/issue-90014-tait2.stderr
+++ b/tests/ui/generic-associated-types/issue-90014-tait2.stderr
@@ -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
 
diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden2.rs b/tests/ui/type-alias-impl-trait/hkl_forbidden2.rs
index 69493f0855f..3d583d4413d 100644
--- a/tests/ui/type-alias-impl-trait/hkl_forbidden2.rs
+++ b/tests/ui/type-alias-impl-trait/hkl_forbidden2.rs
@@ -1,5 +1,4 @@
 #![feature(type_alias_impl_trait)]
-//~^ ERROR: expected generic lifetime parameter, found `'a`
 
 type Opaque<'a> = impl Sized + 'a;
 
@@ -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() {}
diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr
index ed0b2085c88..0a9a9d6bcf4 100644
--- a/tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr
+++ b/tests/ui/type-alias-impl-trait/hkl_forbidden2.stderr
@@ -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