about summary refs log tree commit diff
path: root/compiler/rustc_traits/src/codegen.rs
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-02-15 17:12:05 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-03-07 06:27:09 +0000
commit8206cffc48b77886e18ecdf22e8762aaaa792eec (patch)
tree744389d9ece5ef8a891d7aca690c497bf4e6c5cb /compiler/rustc_traits/src/codegen.rs
parentaa029ce4d8f5048dafd44b6af794542ee19f7c37 (diff)
downloadrust-8206cffc48b77886e18ecdf22e8762aaaa792eec.tar.gz
rust-8206cffc48b77886e18ecdf22e8762aaaa792eec.zip
Merge `check_mod_impl_wf` and `check_mod_type_wf`
Diffstat (limited to 'compiler/rustc_traits/src/codegen.rs')
-rw-r--r--compiler/rustc_traits/src/codegen.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_traits/src/codegen.rs b/compiler/rustc_traits/src/codegen.rs
index f3fae63ecc7..b2b5c6cd909 100644
--- a/compiler/rustc_traits/src/codegen.rs
+++ b/compiler/rustc_traits/src/codegen.rs
@@ -6,7 +6,7 @@
 use rustc_infer::infer::TyCtxtInferExt;
 use rustc_infer::traits::{FulfillmentErrorCode, TraitEngineExt as _};
 use rustc_middle::traits::CodegenObligationError;
-use rustc_middle::ty::{self, TyCtxt};
+use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
 use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
 use rustc_trait_selection::traits::{
     ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine, TraitEngineExt,
@@ -72,6 +72,13 @@ pub fn codegen_select_candidate<'tcx>(
 
     let impl_source = infcx.resolve_vars_if_possible(impl_source);
     let impl_source = infcx.tcx.erase_regions(impl_source);
+    if impl_source.has_infer() {
+        // Unused lifetimes on an impl get replaced with inference vars, but never resolved,
+        // causing the return value of a query to contain inference vars. We do not have a concept
+        // for this and will in fact ICE in stable hashing of the return value. So bail out instead.
+        infcx.tcx.dcx().has_errors().unwrap();
+        return Err(CodegenObligationError::FulfillmentError);
+    }
 
     Ok(&*tcx.arena.alloc(impl_source))
 }