Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow printing lifetime placeholders #557

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions chalk-solve/src/display/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ impl<I: Interner> RenderAsRust<I> for TyData<I> {
TyData::Alias(alias_ty) => alias_ty.fmt(s, f),
TyData::Apply(apply_ty) => apply_ty.fmt(s, f),
TyData::Function(func) => func.fmt(s, f),
TyData::Placeholder(_) => unreachable!(
"cannot print placeholder variables; these should only be in goals not programs"
),
TyData::Placeholder(_) => write!(f, "<placeholder>"),
}
}
}
Expand Down Expand Up @@ -214,9 +212,12 @@ impl<I: Interner> RenderAsRust<I> for ApplicationTy<I> {
)?;
}
TypeName::Error => write!(f, "{{error}}")?,
TypeName::Never => todo!("never type"),
TypeName::FnDef(_) => todo!("fn def type"),
TypeName::Closure(..) => todo!("closure type"),
TypeName::Never => write!(f, "!")?,

// FIXME: write out valid types for these variants
TypeName::FnDef(_) => write!(f, "<fn_def>")?,
TypeName::Closure(..) => write!(f, "<closure>")?,

TypeName::Array => write!(
f,
"[{}; {}]",
Expand Down Expand Up @@ -267,9 +268,9 @@ impl<I: Interner> RenderAsRust<I> for LifetimeData<I> {
match self {
LifetimeData::BoundVar(v) => write!(f, "'{}", s.display_bound_var(v)),
LifetimeData::InferenceVar(_) => write!(f, "'_"),
LifetimeData::Placeholder(_) => unreachable!(
"cannot print placeholder variables; these should only be in goals not programs"
),
LifetimeData::Placeholder(ix) => {
write!(f, "'_placeholder_{}_{}", ix.ui.counter, ix.idx)
}
// Matching the void ensures at compile time that this code is
// unreachable
LifetimeData::Phantom(void, _) => match *void {},
Expand All @@ -288,9 +289,7 @@ impl<I: Interner> RenderAsRust<I> for ConstValue<I> {
match self {
ConstValue::BoundVar(v) => write!(f, "{}", s.display_bound_var(v)),
ConstValue::InferenceVar(_) => write!(f, "_"),
ConstValue::Placeholder(_) => unreachable!(
"cannot print placeholder variables; these should only be in goals not programs"
),
ConstValue::Placeholder(_) => write!(f, "<const placeholder>"),
ConstValue::Concrete(_value) => unimplemented!("const values"),
}
}
Expand Down