Skip to content

Commit c9c8e29

Browse files
HACK: self ty ambiguity hack
1 parent 280f69d commit c9c8e29

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

compiler/rustc_trait_selection/src/solve/assembly.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Code shared by trait and projection goals for candidate assembly.
22
33
use super::infcx_ext::InferCtxtExt;
4-
use super::{CanonicalResponse, EvalCtxt, Goal, QueryResult};
4+
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
55
use rustc_hir::def_id::DefId;
66
use rustc_infer::traits::query::NoSolution;
77
use rustc_infer::traits::util::elaborate_predicates;
@@ -124,6 +124,16 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
124124
&mut self,
125125
goal: Goal<'tcx, G>,
126126
) -> Vec<Candidate<'tcx>> {
127+
// HACK: `_: Trait` is ambiguous, because it may be satisfied via a builtin rule,
128+
// object bound, alias bound, etc. We are unable to determine this until we can at
129+
// least structually resolve the type one layer.
130+
if goal.predicate.self_ty().is_ty_var() {
131+
return vec![Candidate {
132+
source: CandidateSource::BuiltinImpl,
133+
result: self.make_canonical_response(Certainty::Maybe(MaybeCause::Ambiguity)).unwrap(),
134+
}];
135+
}
136+
127137
let mut candidates = Vec::new();
128138

129139
self.assemble_candidates_after_normalizing_self_ty(goal, &mut candidates);

0 commit comments

Comments
 (0)