mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
rough, but appears to work
This commit is contained in:
parent
f0210f8a43
commit
73e49493bd
9 changed files with 81 additions and 15 deletions
|
@ -239,6 +239,7 @@ where
|
|||
T: HirDisplay,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
println!("formatting..");
|
||||
match self.t.hir_fmt(&mut HirFormatter {
|
||||
db: self.db,
|
||||
fmt: f,
|
||||
|
@ -341,6 +342,9 @@ impl HirDisplay for Ty {
|
|||
return write!(f, "{}", TYPE_HINT_TRUNCATION);
|
||||
}
|
||||
|
||||
let interner_kind = self.kind(Interner);
|
||||
println!("interner kind: {interner_kind:?}");
|
||||
|
||||
match self.kind(Interner) {
|
||||
TyKind::Never => write!(f, "!")?,
|
||||
TyKind::Str => write!(f, "str")?,
|
||||
|
@ -1094,15 +1098,27 @@ impl HirDisplay for TypeRef {
|
|||
inner.hir_fmt(f)?;
|
||||
write!(f, "]")?;
|
||||
}
|
||||
TypeRef::Fn(tys, is_varargs) => {
|
||||
// FIXME: Function pointer qualifiers.
|
||||
TypeRef::Fn(parameters, is_varargs) => {
|
||||
write!(f, "fn(")?;
|
||||
f.write_joined(&tys[..tys.len() - 1], ", ")?;
|
||||
for index in 0..parameters.len() - 1 {
|
||||
let (param_name,param_type) = ¶meters[index];
|
||||
match param_name {
|
||||
Some(name) => {
|
||||
write!(f, "{}: ", name)?;
|
||||
param_type.hir_fmt(f)?;
|
||||
},
|
||||
None => write!(f, " : {:?}", param_type)?,
|
||||
};
|
||||
|
||||
if index != parameters.len() - 2 {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
}
|
||||
if *is_varargs {
|
||||
write!(f, "{}...", if tys.len() == 1 { "" } else { ", " })?;
|
||||
write!(f, "{}...", if parameters.len() == 1 { "" } else { ", " })?;
|
||||
}
|
||||
write!(f, ")")?;
|
||||
let ret_ty = tys.last().unwrap();
|
||||
let ret_ty = ¶meters.last().unwrap().1;
|
||||
match ret_ty {
|
||||
TypeRef::Tuple(tup) if tup.is_empty() => {}
|
||||
_ => {
|
||||
|
|
|
@ -201,7 +201,7 @@ impl<'a> TyLoweringContext<'a> {
|
|||
TypeRef::Placeholder => TyKind::Error.intern(Interner),
|
||||
TypeRef::Fn(params, is_varargs) => {
|
||||
let substs = self.with_shifted_in(DebruijnIndex::ONE, |ctx| {
|
||||
Substitution::from_iter(Interner, params.iter().map(|tr| ctx.lower_ty(tr)))
|
||||
Substitution::from_iter(Interner, params.iter().map(|tr| ctx.lower_ty(&tr.1)))
|
||||
});
|
||||
TyKind::Function(FnPointer {
|
||||
num_binders: 0, // FIXME lower `for<'a> fn()` correctly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue