about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCharles Lew <crlf0710@gmail.com>2021-08-20 02:37:00 +0800
committerCharles Lew <crlf0710@gmail.com>2021-08-20 02:37:00 +0800
commitc22dfab21521f055d47a6680ecdaad7261949112 (patch)
treedd0c6ec88ccad6525d9a964ea332e45b5908859f
parente1e0989a0d53d7521b9efdc774236c25bff844bd (diff)
downloadrust-c22dfab21521f055d47a6680ecdaad7261949112.tar.gz
rust-c22dfab21521f055d47a6680ecdaad7261949112.zip
Add assertion to ensure the query doesn't get called before type infererence is done.
-rw-r--r--compiler/rustc_trait_selection/src/traits/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index 3acac504cff..477d29f1a4f 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -765,8 +765,8 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot(
     ),
 ) -> Option<usize> {
     let (source, target) = key;
-    debug_assert!(matches!(&source.kind(), &ty::Dynamic(..)));
-    debug_assert!(matches!(&target.kind(), &ty::Dynamic(..)));
+    assert!(matches!(&source.kind(), &ty::Dynamic(..)) && !source.needs_infer());
+    assert!(matches!(&target.kind(), &ty::Dynamic(..)) && !target.needs_infer());
 
     // this has been typecked-before, so diagnostics is not really needed.
     let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None);