Skip to content

Commit 5fd7ffe

Browse files
committed
Add the same logic to evaluate
1 parent f6bd15b commit 5fd7ffe

File tree

1 file changed

+20
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+20
-1
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,26 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
838838
}
839839
}
840840

841-
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) => todo!(),
841+
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
842+
for pred in obligation.param_env.caller_bounds().iter() {
843+
match pred.kind().skip_binder() {
844+
ty::ClauseKind::UnstableFeature(sym) => {
845+
if sym == symbol {
846+
return Ok(EvaluatedToOk);
847+
}
848+
}
849+
_ => {} // don't care
850+
}
851+
}
852+
// Check if feature is enabled at crate level with #[feature(..)] or if we are currently in codegen.
853+
if self.tcx().features().enabled(symbol)
854+
|| (self.infcx.typing_mode() == TypingMode::PostAnalysis)
855+
{
856+
return Ok(EvaluatedToOk);
857+
} else {
858+
return Ok(EvaluatedToAmbig);
859+
}
860+
}
842861

843862
ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(uv)) => {
844863
match const_evaluatable::is_const_evaluatable(

0 commit comments

Comments
 (0)