diff options
| author | lcnr <rust@lcnr.de> | 2025-09-23 17:33:24 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-09-26 16:33:15 +0200 |
| commit | 148fd9ad3c434c26a952e01e37c35aa26cb8315c (patch) | |
| tree | ce2212f59abdb0e93ca76092ab1aaabd29d4cf8d /compiler/rustc_infer/src | |
| parent | 6b379b560df483307958f2a606a1dd514fff36ca (diff) | |
| download | rust-148fd9ad3c434c26a952e01e37c35aa26cb8315c.tar.gz rust-148fd9ad3c434c26a952e01e37c35aa26cb8315c.zip | |
allow method calls on opaques
Diffstat (limited to 'compiler/rustc_infer/src')
| -rw-r--r-- | compiler/rustc_infer/src/infer/canonical/query_response.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 5d1b4be9e57..a20cd31113a 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -85,11 +85,32 @@ impl<'tcx> InferCtxt<'tcx> { where T: Debug + TypeFoldable<TyCtxt<'tcx>>, { + // While we ignore region constraints and pending obligations, + // we do return constrained opaque types to avoid unconstrained + // inference variables in the response. This is still slightly + // insufficient as ambiguous `Projection` obligations have the + // same issue. + // + // FIXME(-Znext-solver): We could alternatively extend the `var_values` + // each time we call `make_query_response_ignoring_pending_obligations` + // and equate inference variables created inside of the query this way. + // This is what we do for `CanonicalState` and is probably a bit nicer. + let opaque_types = if self.next_trait_solver() { + self.inner + .borrow_mut() + .opaque_type_storage + .iter_opaque_types() + .map(|(k, v)| (k, v.ty)) + .collect() + } else { + vec![] + }; + self.canonicalize_response(QueryResponse { var_values: inference_vars, region_constraints: QueryRegionConstraints::default(), certainty: Certainty::Proven, // Ambiguities are OK! - opaque_types: vec![], + opaque_types, value: answer, }) } |
