about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_next_trait_solver/src/delegate.rs5
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs2
-rw-r--r--compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs38
-rw-r--r--compiler/rustc_trait_selection/src/solve/delegate.rs5
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization-2.current.stderr (renamed from tests/ui/traits/unconstrained-projection-normalization-2.stderr)2
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization-2.next.stderr9
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization-2.rs4
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization.current.stderr (renamed from tests/ui/traits/unconstrained-projection-normalization.stderr)2
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization.next.stderr9
-rw-r--r--tests/ui/traits/unconstrained-projection-normalization.rs4
10 files changed, 57 insertions, 23 deletions
diff --git a/compiler/rustc_next_trait_solver/src/delegate.rs b/compiler/rustc_next_trait_solver/src/delegate.rs
index 4ba54a2e0bf..2d2d50e62f9 100644
--- a/compiler/rustc_next_trait_solver/src/delegate.rs
+++ b/compiler/rustc_next_trait_solver/src/delegate.rs
@@ -95,7 +95,10 @@ pub trait SolverDelegate: Deref<Target = <Self as SolverDelegate>::Infcx> + Size
         goal_trait_ref: ty::TraitRef<Self::Interner>,
         trait_assoc_def_id: <Self::Interner as Interner>::DefId,
         impl_def_id: <Self::Interner as Interner>::DefId,
-    ) -> Result<Option<<Self::Interner as Interner>::DefId>, NoSolution>;
+    ) -> Result<
+        Option<<Self::Interner as Interner>::DefId>,
+        <Self::Interner as Interner>::ErrorGuaranteed,
+    >;
 
     fn is_transmutable(
         &self,
diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
index 8c74490e0e0..91ad24bff67 100644
--- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
@@ -950,7 +950,7 @@ where
         goal_trait_ref: ty::TraitRef<I>,
         trait_assoc_def_id: I::DefId,
         impl_def_id: I::DefId,
-    ) -> Result<Option<I::DefId>, NoSolution> {
+    ) -> Result<Option<I::DefId>, I::ErrorGuaranteed> {
         self.delegate.fetch_eligible_assoc_item(goal_trait_ref, trait_assoc_def_id, impl_def_id)
     }
 
diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
index f5ecfea5408..76cbe5758b2 100644
--- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs
@@ -244,20 +244,7 @@ where
                     .map(|pred| goal.with(cx, pred)),
             );
 
-            // In case the associated item is hidden due to specialization, we have to
-            // return ambiguity this would otherwise be incomplete, resulting in
-            // unsoundness during coherence (#105782).
-            let Some(target_item_def_id) = ecx.fetch_eligible_assoc_item(
-                goal_trait_ref,
-                goal.predicate.def_id(),
-                impl_def_id,
-            )?
-            else {
-                return ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
-            };
-
-            let error_response = |ecx: &mut EvalCtxt<'_, D>, msg: &str| {
-                let guar = cx.delay_bug(msg);
+            let error_response = |ecx: &mut EvalCtxt<'_, D>, guar| {
                 let error_term = match goal.predicate.alias.kind(cx) {
                     ty::AliasTermKind::ProjectionTy => Ty::new_error(cx, guar).into(),
                     ty::AliasTermKind::ProjectionConst => Const::new_error(cx, guar).into(),
@@ -267,8 +254,24 @@ where
                 ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
             };
 
+            // In case the associated item is hidden due to specialization, we have to
+            // return ambiguity this would otherwise be incomplete, resulting in
+            // unsoundness during coherence (#105782).
+            let target_item_def_id = match ecx.fetch_eligible_assoc_item(
+                goal_trait_ref,
+                goal.predicate.def_id(),
+                impl_def_id,
+            ) {
+                Ok(Some(target_item_def_id)) => target_item_def_id,
+                Ok(None) => {
+                    return ecx
+                        .evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
+                }
+                Err(guar) => return error_response(ecx, guar),
+            };
+
             if !cx.has_item_definition(target_item_def_id) {
-                return error_response(ecx, "missing item");
+                return error_response(ecx, cx.delay_bug("missing item"));
             }
 
             let target_container_def_id = cx.parent(target_item_def_id);
@@ -292,7 +295,10 @@ where
             )?;
 
             if !cx.check_args_compatible(target_item_def_id, target_args) {
-                return error_response(ecx, "associated item has mismatched arguments");
+                return error_response(
+                    ecx,
+                    cx.delay_bug("associated item has mismatched arguments"),
+                );
             }
 
             // Finally we construct the actual value of the associated type.
diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs
index 9b8c9ff6bb8..acd00d9f74f 100644
--- a/compiler/rustc_trait_selection/src/solve/delegate.rs
+++ b/compiler/rustc_trait_selection/src/solve/delegate.rs
@@ -190,9 +190,8 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
         goal_trait_ref: ty::TraitRef<'tcx>,
         trait_assoc_def_id: DefId,
         impl_def_id: DefId,
-    ) -> Result<Option<DefId>, NoSolution> {
-        let node_item = specialization_graph::assoc_def(self.tcx, impl_def_id, trait_assoc_def_id)
-            .map_err(|ErrorGuaranteed { .. }| NoSolution)?;
+    ) -> Result<Option<DefId>, ErrorGuaranteed> {
+        let node_item = specialization_graph::assoc_def(self.tcx, impl_def_id, trait_assoc_def_id)?;
 
         let eligible = if node_item.is_final() {
             // Non-specializable items are always projectable.
diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr
index 6d3d4492b07..2bb389c6ec1 100644
--- a/tests/ui/traits/unconstrained-projection-normalization-2.stderr
+++ b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr
@@ -1,5 +1,5 @@
 error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
-  --> $DIR/unconstrained-projection-normalization-2.rs:10:6
+  --> $DIR/unconstrained-projection-normalization-2.rs:14:6
    |
 LL | impl<T: ?Sized> Every for Thing {
    |      ^ unconstrained type parameter
diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr
new file mode 100644
index 00000000000..2bb389c6ec1
--- /dev/null
+++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
+  --> $DIR/unconstrained-projection-normalization-2.rs:14:6
+   |
+LL | impl<T: ?Sized> Every for Thing {
+   |      ^ unconstrained type parameter
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs
index 085e9e4a61a..6b584c436c6 100644
--- a/tests/ui/traits/unconstrained-projection-normalization-2.rs
+++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs
@@ -2,6 +2,10 @@
 // an associated type in an impl with unconstrained non-lifetime params.
 // (This time in a function signature)
 
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
 struct Thing;
 
 pub trait Every {
diff --git a/tests/ui/traits/unconstrained-projection-normalization.stderr b/tests/ui/traits/unconstrained-projection-normalization.current.stderr
index 4e4421a73e5..991f0e8ba66 100644
--- a/tests/ui/traits/unconstrained-projection-normalization.stderr
+++ b/tests/ui/traits/unconstrained-projection-normalization.current.stderr
@@ -1,5 +1,5 @@
 error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
-  --> $DIR/unconstrained-projection-normalization.rs:9:6
+  --> $DIR/unconstrained-projection-normalization.rs:13:6
    |
 LL | impl<T: ?Sized> Every for Thing {
    |      ^ unconstrained type parameter
diff --git a/tests/ui/traits/unconstrained-projection-normalization.next.stderr b/tests/ui/traits/unconstrained-projection-normalization.next.stderr
new file mode 100644
index 00000000000..991f0e8ba66
--- /dev/null
+++ b/tests/ui/traits/unconstrained-projection-normalization.next.stderr
@@ -0,0 +1,9 @@
+error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
+  --> $DIR/unconstrained-projection-normalization.rs:13:6
+   |
+LL | impl<T: ?Sized> Every for Thing {
+   |      ^ unconstrained type parameter
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/traits/unconstrained-projection-normalization.rs b/tests/ui/traits/unconstrained-projection-normalization.rs
index e4d25a5ba6c..fa4ab7fec4c 100644
--- a/tests/ui/traits/unconstrained-projection-normalization.rs
+++ b/tests/ui/traits/unconstrained-projection-normalization.rs
@@ -1,6 +1,10 @@
 // Make sure we don't ICE in `normalize_erasing_regions` when normalizing
 // an associated type in an impl with unconstrained non-lifetime params.
 
+//@ revisions: current next
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@[next] compile-flags: -Znext-solver
+
 struct Thing;
 
 pub trait Every {