about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-08 23:30:50 +0000
committerGitHub <noreply@github.com>2022-02-08 23:30:50 +0000
commit7c2d7035a6a0217a8162ce7ba889097933746d98 (patch)
tree21e512ec90856b40ffd044c78891501292456377
parent8ac459501ea74bf19ad664b4df135cf340c889ba (diff)
parent1c1d900d0bb71b2611b2a6c72d3f0f31cbcc3b06 (diff)
downloadrust-7c2d7035a6a0217a8162ce7ba889097933746d98.tar.gz
rust-7c2d7035a6a0217a8162ce7ba889097933746d98.zip
Merge #11437
11437: [ide_completion] render if a function is async/const/unsafe in completion details r=Veykril a=jhgg

this change renders in the autocomplete detail, whether a function is async/const/unsafe.

i found myself wanting to know this information at a glance, so now it renders here:

![image](https://user-images.githubusercontent.com/5489149/153089518-5419afe4-b2c6-4be8-80f7-585f5c514ff2.png)


Co-authored-by: Jake Heinz <jh@discordapp.com>
-rw-r--r--crates/ide_completion/src/render/function.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index 20c7fe657ce..c1908ba0c84 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -110,7 +110,19 @@ fn render(
 
 fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
     let ret_ty = func.ret_type(db);
-    let mut detail = format!("fn({})", params_display(db, func));
+    let mut detail = String::new();
+
+    if func.is_const(db) {
+        format_to!(detail, "const ");
+    }
+    if func.is_async(db) {
+        format_to!(detail, "async ");
+    }
+    if func.is_unsafe(db) {
+        format_to!(detail, "unsafe ");
+    }
+
+    format_to!(detail, "fn({})", params_display(db, func));
     if !ret_ty.is_unit() {
         format_to!(detail, " -> {}", ret_ty.display(db));
     }