about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-14 06:37:15 +0000
committerbors <bors@rust-lang.org>2024-01-14 06:37:15 +0000
commit0dab65b8a112dff83147f95c9ae1cbe75327b5e4 (patch)
tree01dd868928b3857623e88888a6827de781f17fe5 /compiler/rustc_trait_selection/src/traits
parentaa5f781bd42340fe4f2eb4d68d2984454f600b78 (diff)
parent7724ba7bd5f2c947a7dc561c24b19bb8409a6ed6 (diff)
downloadrust-0dab65b8a112dff83147f95c9ae1cbe75327b5e4.tar.gz
rust-0dab65b8a112dff83147f95c9ae1cbe75327b5e4.zip
Auto merge of #119934 - compiler-errors:could-impl, r=jackh726
Make `InferCtxtExt::could_impl_trait` more precise, less ICEy

The implementation for `InferCtxtExt::could_impl_trait` was very wrong. Along with being pretty poorly named, way too specific to ADTs, it was also doing impl substitution wrong -- this caused an ICE (#119915).

This PR generalizes that code, gives it a clearer name, makes it stop using the new trait solver (lol), and fixes some fallout bad suggestions that are made worse with the code fix.

Fixes #119915
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/fulfill.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs
index 045d7e444b6..472342f9898 100644
--- a/compiler/rustc_trait_selection/src/traits/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs
@@ -80,6 +80,11 @@ static_assert_size!(PendingPredicateObligation<'_>, 72);
 impl<'tcx> FulfillmentContext<'tcx> {
     /// Creates a new fulfillment context.
     pub(super) fn new(infcx: &InferCtxt<'tcx>) -> FulfillmentContext<'tcx> {
+        assert!(
+            !infcx.next_trait_solver(),
+            "old trait solver fulfillment context created when \
+            infcx is set up for new trait solver"
+        );
         FulfillmentContext {
             predicates: ObligationForest::new(),
             usable_in_snapshot: infcx.num_open_snapshots(),