mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Address review suggestion, fix tidy tests
This commit is contained in:
parent
077592a12f
commit
db53db8046
4 changed files with 34 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
|||
//! FIXME: write short doc here
|
||||
use std::{iter, sync::Arc};
|
||||
use std::{fmt::Write, iter, sync::Arc};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use base_db::{CrateDisplayName, CrateId, Edition, FileId};
|
||||
|
@ -729,8 +729,7 @@ impl DefWithBody {
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct Function {
|
||||
// DO NOT MERGE: this was previously pub(crate)
|
||||
pub id: FunctionId,
|
||||
pub(crate) id: FunctionId,
|
||||
}
|
||||
|
||||
impl Function {
|
||||
|
@ -798,6 +797,19 @@ impl Function {
|
|||
pub fn has_body(self, db: &dyn HirDatabase) -> bool {
|
||||
db.function_data(self.id).has_body
|
||||
}
|
||||
|
||||
/// A textual representation of the HIR of this function for debugging purposes.
|
||||
pub fn debug_hir(self, db: &dyn HirDatabase) -> String {
|
||||
let body = db.body(self.id.into());
|
||||
|
||||
let mut result = String::new();
|
||||
writeln!(&mut result, "HIR expressions in the body of `{}`:", self.name(db)).unwrap();
|
||||
for (id, expr) in body.exprs.iter() {
|
||||
writeln!(&mut result, "{:?}: {:?}", id, expr).unwrap();
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
// Note: logically, this belongs to `hir_ty`, but we are not using it there yet.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue