diff options
| author | Michael Goulet <michael@errs.io> | 2023-01-19 03:26:54 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-01-19 15:31:57 +0000 |
| commit | c9c8e294d2b6fc7c83641476f4986a7bf5e84817 (patch) | |
| tree | c44c6d5476daf00073f4cd3ff77220a9c51d5373 | |
| parent | 280f69d8585b676b0441cdb476634882ebe1b983 (diff) | |
| download | rust-c9c8e294d2b6fc7c83641476f4986a7bf5e84817.tar.gz rust-c9c8e294d2b6fc7c83641476f4986a7bf5e84817.zip | |
HACK: self ty ambiguity hack
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly.rs b/compiler/rustc_trait_selection/src/solve/assembly.rs index 2336fb53aec..2c92e7eb9ad 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly.rs @@ -1,7 +1,7 @@ //! Code shared by trait and projection goals for candidate assembly. use super::infcx_ext::InferCtxtExt; -use super::{CanonicalResponse, EvalCtxt, Goal, QueryResult}; +use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult}; use rustc_hir::def_id::DefId; use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::util::elaborate_predicates; @@ -124,6 +124,16 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { &mut self, goal: Goal<'tcx, G>, ) -> Vec<Candidate<'tcx>> { + // HACK: `_: Trait` is ambiguous, because it may be satisfied via a builtin rule, + // object bound, alias bound, etc. We are unable to determine this until we can at + // least structually resolve the type one layer. + if goal.predicate.self_ty().is_ty_var() { + return vec![Candidate { + source: CandidateSource::BuiltinImpl, + result: self.make_canonical_response(Certainty::Maybe(MaybeCause::Ambiguity)).unwrap(), + }]; + } + let mut candidates = Vec::new(); self.assemble_candidates_after_normalizing_self_ty(goal, &mut candidates); |
