diff options
author | TomasKralCZ <[email protected]> | 2020-01-19 16:51:03 +0000 |
---|---|---|
committer | TomasKralCZ <[email protected]> | 2020-01-19 16:51:03 +0000 |
commit | 514df15d9e32e057ba23dda0d4f5c07e82e7ed23 (patch) | |
tree | 41e93f63182bae10a7325fc50220f67df79aaece | |
parent | c3b9a19eb72ae9542272ae7a22ac3fb57c75daca (diff) | |
parent | 3a7724e44181ccd5c248589538bd82458b5a9407 (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer
-rw-r--r-- | Cargo.lock | 24 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/op.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 21 | ||||
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 19 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 23 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar.rs | 2 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 28 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt | 54 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt | 37 | ||||
-rw-r--r-- | editors/emacs/rust-analyzer.el | 19 | ||||
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 2 | ||||
-rw-r--r-- | xtask/src/lib.rs | 1 |
15 files changed, 181 insertions, 86 deletions
diff --git a/Cargo.lock b/Cargo.lock index 10bd94f7b..67822cb8a 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -45,7 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
45 | 45 | ||
46 | [[package]] | 46 | [[package]] |
47 | name = "backtrace" | 47 | name = "backtrace" |
48 | version = "0.3.41" | 48 | version = "0.3.42" |
49 | source = "registry+https://github.com/rust-lang/crates.io-index" | 49 | source = "registry+https://github.com/rust-lang/crates.io-index" |
50 | dependencies = [ | 50 | dependencies = [ |
51 | "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", | 51 | "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -463,10 +463,10 @@ dependencies = [ | |||
463 | 463 | ||
464 | [[package]] | 464 | [[package]] |
465 | name = "indexmap" | 465 | name = "indexmap" |
466 | version = "1.3.0" | 466 | version = "1.3.1" |
467 | source = "registry+https://github.com/rust-lang/crates.io-index" | 467 | source = "registry+https://github.com/rust-lang/crates.io-index" |
468 | dependencies = [ | 468 | dependencies = [ |
469 | "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", | 469 | "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
470 | ] | 470 | ] |
471 | 471 | ||
472 | [[package]] | 472 | [[package]] |
@@ -730,7 +730,7 @@ dependencies = [ | |||
730 | 730 | ||
731 | [[package]] | 731 | [[package]] |
732 | name = "num_cpus" | 732 | name = "num_cpus" |
733 | version = "1.11.1" | 733 | version = "1.12.0" |
734 | source = "registry+https://github.com/rust-lang/crates.io-index" | 734 | source = "registry+https://github.com/rust-lang/crates.io-index" |
735 | dependencies = [ | 735 | dependencies = [ |
736 | "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 736 | "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1038,7 +1038,7 @@ dependencies = [ | |||
1038 | "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1038 | "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1039 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1039 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1040 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1040 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1041 | "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1041 | "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1042 | "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1042 | "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1043 | "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1043 | "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1044 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1044 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1114,7 +1114,7 @@ dependencies = [ | |||
1114 | name = "ra_prof" | 1114 | name = "ra_prof" |
1115 | version = "0.1.0" | 1115 | version = "0.1.0" |
1116 | dependencies = [ | 1116 | dependencies = [ |
1117 | "backtrace 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)", | 1117 | "backtrace 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)", |
1118 | "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1118 | "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1119 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1119 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1120 | "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1120 | "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1353,7 +1353,7 @@ dependencies = [ | |||
1353 | "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1353 | "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1354 | "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1354 | "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1355 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1355 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1356 | "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1356 | "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1357 | ] | 1357 | ] |
1358 | 1358 | ||
1359 | [[package]] | 1359 | [[package]] |
@@ -1449,7 +1449,7 @@ version = "0.14.1" | |||
1449 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1449 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1450 | dependencies = [ | 1450 | dependencies = [ |
1451 | "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1451 | "crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1452 | "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1452 | "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1453 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1453 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1454 | "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1454 | "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1455 | "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1455 | "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1631,7 +1631,7 @@ name = "threadpool" | |||
1631 | version = "1.7.1" | 1631 | version = "1.7.1" |
1632 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1633 | dependencies = [ | 1633 | dependencies = [ |
1634 | "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1634 | "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1635 | ] | 1635 | ] |
1636 | 1636 | ||
1637 | [[package]] | 1637 | [[package]] |
@@ -1781,7 +1781,7 @@ dependencies = [ | |||
1781 | "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" | 1781 | "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" |
1782 | "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" | 1782 | "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" |
1783 | "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" | 1783 | "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" |
1784 | "checksum backtrace 0.3.41 (registry+https://github.com/rust-lang/crates.io-index)" = "a4ed64ae6d9ebfd9893193c4b2532b1292ec97bd8271c9d7d0fa90cd78a34cba" | 1784 | "checksum backtrace 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b4b1549d804b6c73f4817df2ba073709e96e426f12987127c48e6745568c350b" |
1785 | "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" | 1785 | "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" |
1786 | "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" | 1786 | "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" |
1787 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" | 1787 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" |
@@ -1832,7 +1832,7 @@ dependencies = [ | |||
1832 | "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" | 1832 | "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" |
1833 | "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" | 1833 | "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" |
1834 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" | 1834 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" |
1835 | "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" | 1835 | "checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" |
1836 | "checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" | 1836 | "checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" |
1837 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" | 1837 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" |
1838 | "checksum insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d499dc062e841590a67230d853bce62d0abeb91304927871670b7c55c461349" | 1838 | "checksum insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d499dc062e841590a67230d853bce62d0abeb91304927871670b7c55c461349" |
@@ -1863,7 +1863,7 @@ dependencies = [ | |||
1863 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" | 1863 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" |
1864 | "checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" | 1864 | "checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" |
1865 | "checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" | 1865 | "checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" |
1866 | "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" | 1866 | "checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" |
1867 | "checksum once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5941ec2d5ee5916c709580d71553b81a633df245bcc73c04dcbd62152ceefc4" | 1867 | "checksum once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5941ec2d5ee5916c709580d71553b81a633df245bcc73c04dcbd62152ceefc4" |
1868 | "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" | 1868 | "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" |
1869 | "checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" | 1869 | "checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" |
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index d6a17e469..31259a01d 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -386,11 +386,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
386 | let lhs_ty = self.infer_expr(*lhs, &lhs_expectation); | 386 | let lhs_ty = self.infer_expr(*lhs, &lhs_expectation); |
387 | // FIXME: find implementation of trait corresponding to operation | 387 | // FIXME: find implementation of trait corresponding to operation |
388 | // symbol and resolve associated `Output` type | 388 | // symbol and resolve associated `Output` type |
389 | let rhs_expectation = op::binary_op_rhs_expectation(*op, lhs_ty); | 389 | let rhs_expectation = op::binary_op_rhs_expectation(*op, lhs_ty.clone()); |
390 | let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(rhs_expectation)); | 390 | let rhs_ty = self.infer_expr(*rhs, &Expectation::has_type(rhs_expectation)); |
391 | 391 | ||
392 | // FIXME: similar as above, return ty is often associated trait type | 392 | // FIXME: similar as above, return ty is often associated trait type |
393 | op::binary_op_return_ty(*op, rhs_ty) | 393 | op::binary_op_return_ty(*op, lhs_ty, rhs_ty) |
394 | } | 394 | } |
395 | _ => Ty::Unknown, | 395 | _ => Ty::Unknown, |
396 | }, | 396 | }, |
diff --git a/crates/ra_hir_ty/src/op.rs b/crates/ra_hir_ty/src/op.rs index 09c47a76d..ae253ca04 100644 --- a/crates/ra_hir_ty/src/op.rs +++ b/crates/ra_hir_ty/src/op.rs | |||
@@ -1,13 +1,21 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Helper functions for binary operator type inference. |
2 | use hir_def::expr::{BinaryOp, CmpOp}; | 2 | use hir_def::expr::{ArithOp, BinaryOp, CmpOp}; |
3 | 3 | ||
4 | use super::{InferTy, Ty, TypeCtor}; | 4 | use super::{InferTy, Ty, TypeCtor}; |
5 | use crate::ApplicationTy; | 5 | use crate::ApplicationTy; |
6 | 6 | ||
7 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | 7 | pub(super) fn binary_op_return_ty(op: BinaryOp, lhs_ty: Ty, rhs_ty: Ty) -> Ty { |
8 | match op { | 8 | match op { |
9 | BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => Ty::simple(TypeCtor::Bool), | 9 | BinaryOp::LogicOp(_) | BinaryOp::CmpOp(_) => Ty::simple(TypeCtor::Bool), |
10 | BinaryOp::Assignment { .. } => Ty::unit(), | 10 | BinaryOp::Assignment { .. } => Ty::unit(), |
11 | BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => match lhs_ty { | ||
12 | Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { | ||
13 | TypeCtor::Int(..) | TypeCtor::Float(..) => lhs_ty, | ||
14 | _ => Ty::Unknown, | ||
15 | }, | ||
16 | Ty::Infer(InferTy::IntVar(..)) | Ty::Infer(InferTy::FloatVar(..)) => lhs_ty, | ||
17 | _ => Ty::Unknown, | ||
18 | }, | ||
11 | BinaryOp::ArithOp(_) => match rhs_ty { | 19 | BinaryOp::ArithOp(_) => match rhs_ty { |
12 | Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { | 20 | Ty::Apply(ApplicationTy { ctor, .. }) => match ctor { |
13 | TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, | 21 | TypeCtor::Int(..) | TypeCtor::Float(..) => rhs_ty, |
@@ -36,6 +44,7 @@ pub(super) fn binary_op_rhs_expectation(op: BinaryOp, lhs_ty: Ty) -> Ty { | |||
36 | _ => Ty::Unknown, | 44 | _ => Ty::Unknown, |
37 | } | 45 | } |
38 | } | 46 | } |
47 | BinaryOp::ArithOp(ArithOp::Shl) | BinaryOp::ArithOp(ArithOp::Shr) => Ty::Unknown, | ||
39 | BinaryOp::CmpOp(CmpOp::Ord { .. }) | 48 | BinaryOp::CmpOp(CmpOp::Ord { .. }) |
40 | | BinaryOp::Assignment { op: Some(_) } | 49 | | BinaryOp::Assignment { op: Some(_) } |
41 | | BinaryOp::ArithOp(_) => match lhs_ty { | 50 | | BinaryOp::ArithOp(_) => match lhs_ty { |
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index f7e042c12..b7204ec00 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -614,6 +614,27 @@ fn test() -> bool { | |||
614 | } | 614 | } |
615 | 615 | ||
616 | #[test] | 616 | #[test] |
617 | fn infer_shift_op() { | ||
618 | assert_snapshot!( | ||
619 | infer(r#" | ||
620 | fn test() { | ||
621 | 1u32 << 5u8; | ||
622 | 1u32 >> 5u8; | ||
623 | } | ||
624 | "#), | ||
625 | @r###" | ||
626 | [11; 48) '{ ...5u8; }': () | ||
627 | [17; 21) '1u32': u32 | ||
628 | [17; 28) '1u32 << 5u8': u32 | ||
629 | [25; 28) '5u8': u8 | ||
630 | [34; 38) '1u32': u32 | ||
631 | [34; 45) '1u32 >> 5u8': u32 | ||
632 | [42; 45) '5u8': u8 | ||
633 | "### | ||
634 | ); | ||
635 | } | ||
636 | |||
637 | #[test] | ||
617 | fn infer_field_autoderef() { | 638 | fn infer_field_autoderef() { |
618 | assert_snapshot!( | 639 | assert_snapshot!( |
619 | infer(r#" | 640 | infer(r#" |
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index ddc53a52b..1e4a472b4 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -169,9 +169,22 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
169 | res.push(self_param.syntax().text().to_string()) | 169 | res.push(self_param.syntax().text().to_string()) |
170 | } | 170 | } |
171 | 171 | ||
172 | res.extend(param_list.params().map(|param| { | 172 | res.extend( |
173 | param.pat().map(|pat| pat.syntax().text().to_string()).unwrap_or_default() | 173 | param_list |
174 | })); | 174 | .params() |
175 | .map(|param| { | ||
176 | Some( | ||
177 | param | ||
178 | .pat()? | ||
179 | .syntax() | ||
180 | .descendants() | ||
181 | .find_map(ast::Name::cast)? | ||
182 | .text() | ||
183 | .to_string(), | ||
184 | ) | ||
185 | }) | ||
186 | .map(|param| param.unwrap_or_default()), | ||
187 | ); | ||
175 | } | 188 | } |
176 | res | 189 | res |
177 | } | 190 | } |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 1b631c7cd..236557541 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -116,7 +116,7 @@ fn get_param_name_hints( | |||
116 | let hints = parameters | 116 | let hints = parameters |
117 | .zip(args) | 117 | .zip(args) |
118 | .filter_map(|(param, arg)| { | 118 | .filter_map(|(param, arg)| { |
119 | if arg.syntax().kind() == SyntaxKind::LITERAL { | 119 | if arg.syntax().kind() == SyntaxKind::LITERAL && !param.is_empty() { |
120 | Some((arg.syntax().text_range(), param)) | 120 | Some((arg.syntax().text_range(), param)) |
121 | } else { | 121 | } else { |
122 | None | 122 | None |
@@ -683,12 +683,12 @@ fn main() { | |||
683 | struct Test {} | 683 | struct Test {} |
684 | 684 | ||
685 | impl Test { | 685 | impl Test { |
686 | fn method(&self, param: i32) -> i32 { | 686 | fn method(&self, mut param: i32) -> i32 { |
687 | param * 2 | 687 | param * 2 |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | fn test_func(foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 { | 691 | fn test_func(mut foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 { |
692 | foo + bar | 692 | foo + bar |
693 | } | 693 | } |
694 | 694 | ||
@@ -704,37 +704,32 @@ fn main() { | |||
704 | assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###" | 704 | assert_debug_snapshot!(analysis.inlay_hints(file_id, None).unwrap(), @r###" |
705 | [ | 705 | [ |
706 | InlayHint { | 706 | InlayHint { |
707 | range: [207; 218), | 707 | range: [215; 226), |
708 | kind: TypeHint, | 708 | kind: TypeHint, |
709 | label: "i32", | 709 | label: "i32", |
710 | }, | 710 | }, |
711 | InlayHint { | 711 | InlayHint { |
712 | range: [251; 252), | 712 | range: [259; 260), |
713 | kind: ParameterHint, | 713 | kind: ParameterHint, |
714 | label: "foo", | 714 | label: "foo", |
715 | }, | 715 | }, |
716 | InlayHint { | 716 | InlayHint { |
717 | range: [254; 255), | 717 | range: [262; 263), |
718 | kind: ParameterHint, | 718 | kind: ParameterHint, |
719 | label: "bar", | 719 | label: "bar", |
720 | }, | 720 | }, |
721 | InlayHint { | 721 | InlayHint { |
722 | range: [257; 264), | 722 | range: [265; 272), |
723 | kind: ParameterHint, | 723 | kind: ParameterHint, |
724 | label: "msg", | 724 | label: "msg", |
725 | }, | 725 | }, |
726 | InlayHint { | 726 | InlayHint { |
727 | range: [266; 267), | 727 | range: [331; 334), |
728 | kind: ParameterHint, | ||
729 | label: "_", | ||
730 | }, | ||
731 | InlayHint { | ||
732 | range: [323; 326), | ||
733 | kind: ParameterHint, | 728 | kind: ParameterHint, |
734 | label: "param", | 729 | label: "param", |
735 | }, | 730 | }, |
736 | InlayHint { | 731 | InlayHint { |
737 | range: [350; 354), | 732 | range: [358; 362), |
738 | kind: ParameterHint, | 733 | kind: ParameterHint, |
739 | label: "param", | 734 | label: "param", |
740 | }, | 735 | }, |
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index 22f64a9f4..a46e11e1d 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! This is the actual "grammar" of the Rust language. | 1 | //! This is the actual "grammar" of the Rust language. |
2 | //! | 2 | //! |
3 | //! Each function in this module and its children corresponds | 3 | //! Each function in this module and its children corresponds |
4 | //! to a production of the format grammar. Submodules roughly | 4 | //! to a production of the formal grammar. Submodules roughly |
5 | //! correspond to different *areas* of the grammar. By convention, | 5 | //! correspond to different *areas* of the grammar. By convention, |
6 | //! each submodule starts with `use super::*` import and exports | 6 | //! each submodule starts with `use super::*` import and exports |
7 | //! "public" productions via `pub(super)`. | 7 | //! "public" productions via `pub(super)`. |
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index d733499d1..06c92645e 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -19,6 +19,26 @@ pub(super) fn expr(p: &mut Parser) -> (Option<CompletedMarker>, BlockLike) { | |||
19 | expr_bp(p, r, 1) | 19 | expr_bp(p, r, 1) |
20 | } | 20 | } |
21 | 21 | ||
22 | pub(super) fn expr_with_attrs(p: &mut Parser) -> bool { | ||
23 | let m = p.start(); | ||
24 | let has_attrs = p.at(T![#]); | ||
25 | attributes::outer_attributes(p); | ||
26 | |||
27 | let (cm, _block_like) = expr(p); | ||
28 | let success = cm.is_some(); | ||
29 | |||
30 | match (has_attrs, cm) { | ||
31 | (true, Some(cm)) => { | ||
32 | let kind = cm.kind(); | ||
33 | cm.undo_completion(p).abandon(p); | ||
34 | m.complete(p, kind); | ||
35 | } | ||
36 | _ => m.abandon(p), | ||
37 | } | ||
38 | |||
39 | success | ||
40 | } | ||
41 | |||
22 | pub(super) fn expr_stmt(p: &mut Parser) -> (Option<CompletedMarker>, BlockLike) { | 42 | pub(super) fn expr_stmt(p: &mut Parser) -> (Option<CompletedMarker>, BlockLike) { |
23 | let r = Restrictions { forbid_structs: false, prefer_stmt: true }; | 43 | let r = Restrictions { forbid_structs: false, prefer_stmt: true }; |
24 | expr_bp(p, r, 1) | 44 | expr_bp(p, r, 1) |
@@ -540,11 +560,13 @@ fn arg_list(p: &mut Parser) { | |||
540 | let m = p.start(); | 560 | let m = p.start(); |
541 | p.bump(T!['(']); | 561 | p.bump(T!['(']); |
542 | while !p.at(T![')']) && !p.at(EOF) { | 562 | while !p.at(T![')']) && !p.at(EOF) { |
543 | if !p.at_ts(EXPR_FIRST) { | 563 | // test arg_with_attr |
544 | p.error("expected expression"); | 564 | // fn main() { |
565 | // foo(#[attr] 92) | ||
566 | // } | ||
567 | if !expr_with_attrs(p) { | ||
545 | break; | 568 | break; |
546 | } | 569 | } |
547 | expr(p); | ||
548 | if !p.at(T![')']) && !p.expect(T![,]) { | 570 | if !p.at(T![')']) && !p.expect(T![,]) { |
549 | break; | 571 | break; |
550 | } | 572 | } |
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index a98a2a3ef..2cc321473 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -191,19 +191,8 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { | |||
191 | 191 | ||
192 | // test array_attrs | 192 | // test array_attrs |
193 | // const A: &[i64] = &[1, #[cfg(test)] 2]; | 193 | // const A: &[i64] = &[1, #[cfg(test)] 2]; |
194 | let m = p.start(); | 194 | if !expr_with_attrs(p) { |
195 | let has_attrs = p.at(T![#]); | 195 | break; |
196 | attributes::outer_attributes(p); | ||
197 | |||
198 | let cm = expr(p).0; | ||
199 | |||
200 | match (has_attrs, cm) { | ||
201 | (true, Some(cm)) => { | ||
202 | let kind = cm.kind(); | ||
203 | cm.undo_completion(p).abandon(p); | ||
204 | m.complete(p, kind); | ||
205 | } | ||
206 | _ => m.abandon(p), | ||
207 | } | 196 | } |
208 | 197 | ||
209 | if n_exprs == 1 && p.eat(T![;]) { | 198 | if n_exprs == 1 && p.eat(T![;]) { |
diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt index 310a82464..cb45eb2fc 100644 --- a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt +++ b/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.txt | |||
@@ -12,8 +12,8 @@ SOURCE_FILE@[0; 112) | |||
12 | BLOCK@[7; 33) | 12 | BLOCK@[7; 33) |
13 | L_CURLY@[7; 8) "{" | 13 | L_CURLY@[7; 8) "{" |
14 | WHITESPACE@[8; 9) " " | 14 | WHITESPACE@[8; 9) " " |
15 | EXPR_STMT@[9; 26) | 15 | EXPR_STMT@[9; 17) |
16 | ARRAY_EXPR@[9; 26) | 16 | ARRAY_EXPR@[9; 17) |
17 | L_BRACK@[9; 10) "[" | 17 | L_BRACK@[9; 10) "[" |
18 | LITERAL@[10; 11) | 18 | LITERAL@[10; 11) |
19 | INT_NUMBER@[10; 11) "1" | 19 | INT_NUMBER@[10; 11) "1" |
@@ -25,10 +25,13 @@ SOURCE_FILE@[0; 112) | |||
25 | WHITESPACE@[15; 16) " " | 25 | WHITESPACE@[15; 16) " " |
26 | ERROR@[16; 17) | 26 | ERROR@[16; 17) |
27 | AT@[16; 17) "@" | 27 | AT@[16; 17) "@" |
28 | EXPR_STMT@[17; 18) | ||
29 | ERROR@[17; 18) | ||
28 | COMMA@[17; 18) "," | 30 | COMMA@[17; 18) "," |
29 | WHITESPACE@[18; 19) " " | 31 | WHITESPACE@[18; 19) " " |
30 | ERROR@[19; 25) | 32 | STRUCT_DEF@[19; 26) |
31 | STRUCT_KW@[19; 25) "struct" | 33 | STRUCT_KW@[19; 25) "struct" |
34 | ERROR@[25; 26) | ||
32 | COMMA@[25; 26) "," | 35 | COMMA@[25; 26) "," |
33 | WHITESPACE@[26; 27) " " | 36 | WHITESPACE@[26; 27) " " |
34 | LET_STMT@[27; 31) | 37 | LET_STMT@[27; 31) |
@@ -51,14 +54,14 @@ SOURCE_FILE@[0; 112) | |||
51 | BLOCK@[41; 68) | 54 | BLOCK@[41; 68) |
52 | L_CURLY@[41; 42) "{" | 55 | L_CURLY@[41; 42) "{" |
53 | WHITESPACE@[42; 43) " " | 56 | WHITESPACE@[42; 43) " " |
54 | EXPR_STMT@[43; 52) | 57 | EXPR_STMT@[43; 54) |
55 | CALL_EXPR@[43; 52) | 58 | CALL_EXPR@[43; 54) |
56 | PATH_EXPR@[43; 46) | 59 | PATH_EXPR@[43; 46) |
57 | PATH@[43; 46) | 60 | PATH@[43; 46) |
58 | PATH_SEGMENT@[43; 46) | 61 | PATH_SEGMENT@[43; 46) |
59 | NAME_REF@[43; 46) | 62 | NAME_REF@[43; 46) |
60 | IDENT@[43; 46) "foo" | 63 | IDENT@[43; 46) "foo" |
61 | ARG_LIST@[46; 52) | 64 | ARG_LIST@[46; 54) |
62 | L_PAREN@[46; 47) "(" | 65 | L_PAREN@[46; 47) "(" |
63 | LITERAL@[47; 48) | 66 | LITERAL@[47; 48) |
64 | INT_NUMBER@[47; 48) "1" | 67 | INT_NUMBER@[47; 48) "1" |
@@ -67,10 +70,9 @@ SOURCE_FILE@[0; 112) | |||
67 | LITERAL@[50; 51) | 70 | LITERAL@[50; 51) |
68 | INT_NUMBER@[50; 51) "2" | 71 | INT_NUMBER@[50; 51) "2" |
69 | COMMA@[51; 52) "," | 72 | COMMA@[51; 52) "," |
70 | WHITESPACE@[52; 53) " " | 73 | WHITESPACE@[52; 53) " " |
71 | EXPR_STMT@[53; 54) | 74 | ERROR@[53; 54) |
72 | ERROR@[53; 54) | 75 | AT@[53; 54) "@" |
73 | AT@[53; 54) "@" | ||
74 | EXPR_STMT@[54; 55) | 76 | EXPR_STMT@[54; 55) |
75 | ERROR@[54; 55) | 77 | ERROR@[54; 55) |
76 | COMMA@[54; 55) "," | 78 | COMMA@[54; 55) "," |
@@ -101,8 +103,8 @@ SOURCE_FILE@[0; 112) | |||
101 | BLOCK@[76; 111) | 103 | BLOCK@[76; 111) |
102 | L_CURLY@[76; 77) "{" | 104 | L_CURLY@[76; 77) "{" |
103 | WHITESPACE@[77; 78) " " | 105 | WHITESPACE@[77; 78) " " |
104 | EXPR_STMT@[78; 91) | 106 | EXPR_STMT@[78; 93) |
105 | METHOD_CALL_EXPR@[78; 91) | 107 | METHOD_CALL_EXPR@[78; 93) |
106 | PATH_EXPR@[78; 81) | 108 | PATH_EXPR@[78; 81) |
107 | PATH@[78; 81) | 109 | PATH@[78; 81) |
108 | PATH_SEGMENT@[78; 81) | 110 | PATH_SEGMENT@[78; 81) |
@@ -111,7 +113,7 @@ SOURCE_FILE@[0; 112) | |||
111 | DOT@[81; 82) "." | 113 | DOT@[81; 82) "." |
112 | NAME_REF@[82; 85) | 114 | NAME_REF@[82; 85) |
113 | IDENT@[82; 85) "bar" | 115 | IDENT@[82; 85) "bar" |
114 | ARG_LIST@[85; 91) | 116 | ARG_LIST@[85; 93) |
115 | L_PAREN@[85; 86) "(" | 117 | L_PAREN@[85; 86) "(" |
116 | LITERAL@[86; 87) | 118 | LITERAL@[86; 87) |
117 | INT_NUMBER@[86; 87) "1" | 119 | INT_NUMBER@[86; 87) "1" |
@@ -120,10 +122,9 @@ SOURCE_FILE@[0; 112) | |||
120 | LITERAL@[89; 90) | 122 | LITERAL@[89; 90) |
121 | INT_NUMBER@[89; 90) "2" | 123 | INT_NUMBER@[89; 90) "2" |
122 | COMMA@[90; 91) "," | 124 | COMMA@[90; 91) "," |
123 | WHITESPACE@[91; 92) " " | 125 | WHITESPACE@[91; 92) " " |
124 | EXPR_STMT@[92; 93) | 126 | ERROR@[92; 93) |
125 | ERROR@[92; 93) | 127 | AT@[92; 93) "@" |
126 | AT@[92; 93) "@" | ||
127 | EXPR_STMT@[93; 94) | 128 | EXPR_STMT@[93; 94) |
128 | ERROR@[93; 94) | 129 | ERROR@[93; 94) |
129 | COMMA@[93; 94) "," | 130 | COMMA@[93; 94) "," |
@@ -148,15 +149,14 @@ SOURCE_FILE@[0; 112) | |||
148 | R_CURLY@[110; 111) "}" | 149 | R_CURLY@[110; 111) "}" |
149 | WHITESPACE@[111; 112) "\n" | 150 | WHITESPACE@[111; 112) "\n" |
150 | error 16: expected expression | 151 | error 16: expected expression |
151 | error 19: expected expression | 152 | error 17: expected R_BRACK |
152 | error 26: expected expression | 153 | error 17: expected SEMI |
153 | error 26: expected COMMA | 154 | error 17: expected expression |
154 | error 26: expected R_BRACK | 155 | error 18: expected SEMI |
155 | error 26: expected SEMI | 156 | error 25: expected a name |
157 | error 26: expected `;`, `{`, or `(` | ||
156 | error 30: expected pattern | 158 | error 30: expected pattern |
157 | error 31: expected SEMI | 159 | error 31: expected SEMI |
158 | error 52: expected expression | ||
159 | error 52: expected SEMI | ||
160 | error 53: expected expression | 160 | error 53: expected expression |
161 | error 54: expected SEMI | 161 | error 54: expected SEMI |
162 | error 54: expected expression | 162 | error 54: expected expression |
@@ -168,8 +168,6 @@ error 61: expected SEMI | |||
168 | error 65: expected pattern | 168 | error 65: expected pattern |
169 | error 65: expected SEMI | 169 | error 65: expected SEMI |
170 | error 65: expected expression | 170 | error 65: expected expression |
171 | error 91: expected expression | ||
172 | error 91: expected SEMI | ||
173 | error 92: expected expression | 171 | error 92: expected expression |
174 | error 93: expected SEMI | 172 | error 93: expected SEMI |
175 | error 93: expected expression | 173 | error 93: expected expression |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs new file mode 100644 index 000000000..5daf1d7b0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn main() { | ||
2 | foo(#[attr] 92) | ||
3 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt new file mode 100644 index 000000000..8092d7009 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.txt | |||
@@ -0,0 +1,37 @@ | |||
1 | SOURCE_FILE@[0; 34) | ||
2 | FN_DEF@[0; 33) | ||
3 | FN_KW@[0; 2) "fn" | ||
4 | WHITESPACE@[2; 3) " " | ||
5 | NAME@[3; 7) | ||
6 | IDENT@[3; 7) "main" | ||
7 | PARAM_LIST@[7; 9) | ||
8 | L_PAREN@[7; 8) "(" | ||
9 | R_PAREN@[8; 9) ")" | ||
10 | WHITESPACE@[9; 10) " " | ||
11 | BLOCK_EXPR@[10; 33) | ||
12 | BLOCK@[10; 33) | ||
13 | L_CURLY@[10; 11) "{" | ||
14 | WHITESPACE@[11; 16) "\n " | ||
15 | CALL_EXPR@[16; 31) | ||
16 | PATH_EXPR@[16; 19) | ||
17 | PATH@[16; 19) | ||
18 | PATH_SEGMENT@[16; 19) | ||
19 | NAME_REF@[16; 19) | ||
20 | IDENT@[16; 19) "foo" | ||
21 | ARG_LIST@[19; 31) | ||
22 | L_PAREN@[19; 20) "(" | ||
23 | LITERAL@[20; 30) | ||
24 | ATTR@[20; 27) | ||
25 | POUND@[20; 21) "#" | ||
26 | L_BRACK@[21; 22) "[" | ||
27 | PATH@[22; 26) | ||
28 | PATH_SEGMENT@[22; 26) | ||
29 | NAME_REF@[22; 26) | ||
30 | IDENT@[22; 26) "attr" | ||
31 | R_BRACK@[26; 27) "]" | ||
32 | WHITESPACE@[27; 28) " " | ||
33 | INT_NUMBER@[28; 30) "92" | ||
34 | R_PAREN@[30; 31) ")" | ||
35 | WHITESPACE@[31; 32) "\n" | ||
36 | R_CURLY@[32; 33) "}" | ||
37 | WHITESPACE@[33; 34) "\n" | ||
diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el index 8ba98bf61..06db4f15f 100644 --- a/editors/emacs/rust-analyzer.el +++ b/editors/emacs/rust-analyzer.el | |||
@@ -210,9 +210,9 @@ | |||
210 | ;; inlay hints | 210 | ;; inlay hints |
211 | (defun rust-analyzer--update-inlay-hints (buffer) | 211 | (defun rust-analyzer--update-inlay-hints (buffer) |
212 | (if (and (rust-analyzer--initialized?) (eq buffer (current-buffer))) | 212 | (if (and (rust-analyzer--initialized?) (eq buffer (current-buffer))) |
213 | (lsp-send-request-async | 213 | (lsp-request-async |
214 | (lsp-make-request "rust-analyzer/inlayHints" | 214 | "rust-analyzer/inlayHints" |
215 | (list :textDocument (lsp--text-document-identifier))) | 215 | (list :textDocument (lsp--text-document-identifier)) |
216 | (lambda (res) | 216 | (lambda (res) |
217 | (remove-overlays (point-min) (point-max) 'rust-analyzer--inlay-hint t) | 217 | (remove-overlays (point-min) (point-max) 'rust-analyzer--inlay-hint t) |
218 | (dolist (hint res) | 218 | (dolist (hint res) |
@@ -221,9 +221,16 @@ | |||
221 | (overlay (make-overlay beg end))) | 221 | (overlay (make-overlay beg end))) |
222 | (overlay-put overlay 'rust-analyzer--inlay-hint t) | 222 | (overlay-put overlay 'rust-analyzer--inlay-hint t) |
223 | (overlay-put overlay 'evaporate t) | 223 | (overlay-put overlay 'evaporate t) |
224 | (overlay-put overlay 'after-string (propertize (concat ": " label) | 224 | (cond |
225 | 'font-lock-face 'font-lock-comment-face))))) | 225 | ((string= kind "TypeHint") |
226 | 'tick)) | 226 | (overlay-put overlay 'after-string (propertize (concat ": " label) |
227 | 'font-lock-face 'font-lock-comment-face))) | ||
228 | ((string= kind "ParameterHint") | ||
229 | (overlay-put overlay 'before-string (propertize (concat label ": ") | ||
230 | 'font-lock-face 'font-lock-comment-face))) | ||
231 | ) | ||
232 | ))) | ||
233 | :mode 'tick)) | ||
227 | nil) | 234 | nil) |
228 | 235 | ||
229 | (defvar-local rust-analyzer--inlay-hints-timer nil) | 236 | (defvar-local rust-analyzer--inlay-hints-timer nil) |
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 19fea67d8..db05dcebb 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! This module generate AST datatype used by rust-analyzer. | 1 | //! This module generates AST datatype used by rust-analyzer. |
2 | //! | 2 | //! |
3 | //! Specifically, it generates the `SyntaxKind` enum and a number of newtype | 3 | //! Specifically, it generates the `SyntaxKind` enum and a number of newtype |
4 | //! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`. | 4 | //! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`. |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 0a569cf5d..9b0afe8e0 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -53,6 +53,7 @@ fn reformat(text: impl std::fmt::Display) -> Result<String> { | |||
53 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; | 53 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; |
54 | let output = rustfmt.wait_with_output()?; | 54 | let output = rustfmt.wait_with_output()?; |
55 | let stdout = String::from_utf8(output.stdout)?; | 55 | let stdout = String::from_utf8(output.stdout)?; |
56 | // TODO: update the preable: replace ra_tools with the relevant path | ||
56 | let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; | 57 | let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; |
57 | Ok(format!("//! {}\n\n{}", preamble, stdout)) | 58 | Ok(format!("//! {}\n\n{}", preamble, stdout)) |
58 | } | 59 | } |