Skip to content

Commit d011188

Browse files
Auto merge of #142223 - compiler-errors:perf-wf, r=<try>
[perf] Fast path for WF goals in new solver I'll clean this up obviously, but I don't want to do that if this is worthless.
2 parents c31cccb + d5c1103 commit d011188

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

compiler/rustc_trait_selection/src/solve/delegate.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,54 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
136136
None
137137
}
138138
}
139+
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => match arg.kind() {
140+
ty::TermKind::Ty(ty) => match self.shallow_resolve(ty).kind() {
141+
ty::Bool
142+
| ty::Char
143+
| ty::Int(_)
144+
| ty::Uint(_)
145+
| ty::Float(_)
146+
| ty::Str
147+
| ty::Never
148+
| ty::Param(_)
149+
| ty::Placeholder(_) => Some(Certainty::Yes),
150+
151+
ty::Infer(infer) => match infer {
152+
ty::TyVar(_) => Some(Certainty::AMBIGUOUS),
153+
ty::IntVar(_) | ty::FloatVar(_) => Some(Certainty::Yes),
154+
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => unreachable!(),
155+
},
156+
157+
ty::Adt(_, _)
158+
| ty::Foreign(_)
159+
| ty::Array(_, _)
160+
| ty::Pat(_, _)
161+
| ty::Slice(_)
162+
| ty::RawPtr(..)
163+
| ty::Ref(..)
164+
| ty::FnDef(..)
165+
| ty::FnPtr(..)
166+
| ty::UnsafeBinder(..)
167+
| ty::Dynamic(..)
168+
| ty::Closure(..)
169+
| ty::CoroutineClosure(..)
170+
| ty::Coroutine(..)
171+
| ty::CoroutineWitness(..)
172+
| ty::Tuple(_)
173+
| ty::Alias(..)
174+
| ty::Bound(..)
175+
| ty::Error(_) => None,
176+
},
177+
ty::TermKind::Const(ct) => match self.shallow_resolve_const(ct).kind() {
178+
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(_) => Some(Certainty::Yes),
179+
ty::ConstKind::Infer(_) => Some(Certainty::AMBIGUOUS),
180+
ty::ConstKind::Bound(..)
181+
| ty::ConstKind::Unevaluated(..)
182+
| ty::ConstKind::Value(_)
183+
| ty::ConstKind::Error(_)
184+
| ty::ConstKind::Expr(_) => None,
185+
},
186+
},
139187
_ => None,
140188
}
141189
}

0 commit comments

Comments
 (0)