mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Implement Chalk's debug methods using TLS
Chalk now panics if we don't implement these methods and run with CHALK_DEBUG, so I thought I'd try to implement them 'properly'. Sadly, it seems impossible to do without transmuting lifetimes somewhere. The problem is that we need a `&dyn HirDatabase` to get names etc., which we can't just put into TLS. I thought I could just use `scoped-tls`, but that doesn't support references to unsized types. So I put the `&dyn` into another struct and put the reference to *that* into the TLS, but I have to transmute the lifetime to 'static for that to work.
This commit is contained in:
parent
176f7f6117
commit
a0a80a4103
6 changed files with 304 additions and 56 deletions
|
@ -247,19 +247,21 @@ impl HirDisplay for ApplicationTy {
|
|||
}
|
||||
}
|
||||
TypeCtor::Closure { .. } => {
|
||||
let sig = self.parameters[0]
|
||||
.callable_sig(f.db)
|
||||
.expect("first closure parameter should contain signature");
|
||||
if sig.params().is_empty() {
|
||||
write!(f, "||")?;
|
||||
} else if f.omit_verbose_types() {
|
||||
write!(f, "|{}|", TYPE_HINT_TRUNCATION)?;
|
||||
let sig = self.parameters[0].callable_sig(f.db);
|
||||
if let Some(sig) = sig {
|
||||
if sig.params().is_empty() {
|
||||
write!(f, "||")?;
|
||||
} else if f.omit_verbose_types() {
|
||||
write!(f, "|{}|", TYPE_HINT_TRUNCATION)?;
|
||||
} else {
|
||||
write!(f, "|")?;
|
||||
f.write_joined(sig.params(), ", ")?;
|
||||
write!(f, "|")?;
|
||||
};
|
||||
write!(f, " -> {}", sig.ret().display(f.db))?;
|
||||
} else {
|
||||
write!(f, "|")?;
|
||||
f.write_joined(sig.params(), ", ")?;
|
||||
write!(f, "|")?;
|
||||
};
|
||||
write!(f, " -> {}", sig.ret().display(f.db))?;
|
||||
write!(f, "{{closure}}")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue