make effect infer variables suggestable in diagnostics

it works when a non-const context that does not enable effects
calls into a const effects-enabled trait. We'd simply suggest the
non-const trait bound in this case consistent to its fallback.
This commit is contained in:
Deadbeef 2024-01-28 00:20:52 +08:00
parent c9192be561
commit 96108c5981

View File

@ -98,6 +98,7 @@ impl<'tcx, T> IsSuggestable<'tcx> for T
where
T: TypeVisitable<TyCtxt<'tcx>> + TypeFoldable<TyCtxt<'tcx>>,
{
#[tracing::instrument(level = "debug", skip(tcx))]
fn is_suggestable(self, tcx: TyCtxt<'tcx>, infer_suggestable: bool) -> bool {
self.visit_with(&mut IsSuggestableVisitor { tcx, infer_suggestable }).is_continue()
}
@ -533,6 +534,9 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
match c.kind() {
ConstKind::Infer(InferConst::Var(_)) if self.infer_suggestable => {}
// effect variables are always suggestable, because they are not visible
ConstKind::Infer(InferConst::EffectVar(_)) => {}
ConstKind::Infer(..)
| ConstKind::Bound(..)
| ConstKind::Placeholder(..)