about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHeinenen <th.m.heinen@gmail.com>2021-12-22 16:29:26 +0100
committerme <th.m.heinen@gmail.com>2021-12-23 12:56:38 +0100
commit05abfc77f5551dbaf81f79abca3c3da5debc1331 (patch)
treed7cda637631ce29b5bbeda9ac668a1b0a8f1b224
parentd7dfe93fc3336804c68ff550d8da5bbd027f5434 (diff)
downloadrust-05abfc77f5551dbaf81f79abca3c3da5debc1331.tar.gz
rust-05abfc77f5551dbaf81f79abca3c3da5debc1331.zip
hide type inlay hints
-rw-r--r--crates/ide/src/inlay_hints.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 509b158184b..cc304cb10a6 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -265,12 +265,15 @@ fn is_named_constructor(
     };
     let path = expr.path()?;
 
-    // If it exists, use qualifying segment as the constructor name.
-    // If not, use the last segment.
-    let qual_seg = match path.qualifier() {
-        Some(qual) => qual.segment(),
-        None => path.segment(),
+    let callable = sema.type_of_expr(&ast::Expr::PathExpr(expr))?.original.as_callable(sema.db);
+    let callable_kind = callable.map(|it| it.kind());
+    let qual_seg = match callable_kind {
+        Some(hir::CallableKind::Function(_) | hir::CallableKind::TupleEnumVariant(_)) => {
+            path.qualifier()?.segment()
+        }
+        _ => path.segment(),
     }?;
+
     let ctor_name = match qual_seg.kind()? {
         ast::PathSegmentKind::Name(name_ref) => {
             match qual_seg.generic_arg_list().map(|it| it.generic_args()) {
@@ -1348,6 +1351,13 @@ fn main() {
 //- minicore: try, option
 use core::ops::ControlFlow;
 
+mod x {
+    pub mod y { pub struct Foo; }
+    pub struct Foo;
+    pub enum AnotherEnum {
+        Variant()
+    };
+}
 struct Struct;
 struct TupleStruct();
 
@@ -1378,6 +1388,8 @@ fn times2(value: i32) -> i32 {
 fn main() {
     let enumb = Enum::Variant(0);
 
+    let strukt = x::Foo;
+    let strukt = x::y::Foo;
     let strukt = Struct;
     let strukt = Struct::new();