diff options
28 files changed, 343 insertions, 151 deletions
diff --git a/Cargo.lock b/Cargo.lock index 522ecf2ee..85ea4f178 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -58,9 +58,9 @@ dependencies = [ | |||
58 | 58 | ||
59 | [[package]] | 59 | [[package]] |
60 | name = "backtrace-sys" | 60 | name = "backtrace-sys" |
61 | version = "0.1.36" | 61 | version = "0.1.37" |
62 | source = "registry+https://github.com/rust-lang/crates.io-index" | 62 | source = "registry+https://github.com/rust-lang/crates.io-index" |
63 | checksum = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7" | 63 | checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" |
64 | dependencies = [ | 64 | dependencies = [ |
65 | "cc", | 65 | "cc", |
66 | "libc", | 66 | "libc", |
@@ -170,7 +170,7 @@ dependencies = [ | |||
170 | "chalk-ir", | 170 | "chalk-ir", |
171 | "chalk-macros", | 171 | "chalk-macros", |
172 | "chalk-rust-ir", | 172 | "chalk-rust-ir", |
173 | "ena", | 173 | "ena 0.13.1", |
174 | "itertools", | 174 | "itertools", |
175 | "petgraph", | 175 | "petgraph", |
176 | "rustc-hash", | 176 | "rustc-hash", |
@@ -199,14 +199,15 @@ dependencies = [ | |||
199 | 199 | ||
200 | [[package]] | 200 | [[package]] |
201 | name = "console" | 201 | name = "console" |
202 | version = "0.10.0" | 202 | version = "0.10.3" |
203 | source = "registry+https://github.com/rust-lang/crates.io-index" | 203 | source = "registry+https://github.com/rust-lang/crates.io-index" |
204 | checksum = "6728a28023f207181b193262711102bfbaf47cc9d13bc71d0736607ef8efe88c" | 204 | checksum = "2586208b33573b7f76ccfbe5adb076394c88deaf81b84d7213969805b0a952a7" |
205 | dependencies = [ | 205 | dependencies = [ |
206 | "clicolors-control", | 206 | "clicolors-control", |
207 | "encode_unicode", | 207 | "encode_unicode", |
208 | "lazy_static", | 208 | "lazy_static", |
209 | "libc", | 209 | "libc", |
210 | "terminal_size", | ||
210 | "termios", | 211 | "termios", |
211 | "winapi 0.3.8", | 212 | "winapi 0.3.8", |
212 | ] | 213 | ] |
@@ -316,6 +317,15 @@ dependencies = [ | |||
316 | ] | 317 | ] |
317 | 318 | ||
318 | [[package]] | 319 | [[package]] |
320 | name = "ena" | ||
321 | version = "0.14.0" | ||
322 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
323 | checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" | ||
324 | dependencies = [ | ||
325 | "log", | ||
326 | ] | ||
327 | |||
328 | [[package]] | ||
319 | name = "encode_unicode" | 329 | name = "encode_unicode" |
320 | version = "0.3.6" | 330 | version = "0.3.6" |
321 | source = "registry+https://github.com/rust-lang/crates.io-index" | 331 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -381,9 +391,9 @@ dependencies = [ | |||
381 | 391 | ||
382 | [[package]] | 392 | [[package]] |
383 | name = "fst" | 393 | name = "fst" |
384 | version = "0.4.1" | 394 | version = "0.4.3" |
385 | source = "registry+https://github.com/rust-lang/crates.io-index" | 395 | source = "registry+https://github.com/rust-lang/crates.io-index" |
386 | checksum = "4eaf9ea41cc964d742f7fc7861db75d2d6e83a3ce0d897d5c6f8b621f015ddc8" | 396 | checksum = "81f9cac32c1741cdf6b66be7dcf0d9c7f25ccf12f8aa84c16cfa31f9f14513b3" |
387 | 397 | ||
388 | [[package]] | 398 | [[package]] |
389 | name = "fuchsia-zircon" | 399 | name = "fuchsia-zircon" |
@@ -447,9 +457,9 @@ dependencies = [ | |||
447 | 457 | ||
448 | [[package]] | 458 | [[package]] |
449 | name = "hermit-abi" | 459 | name = "hermit-abi" |
450 | version = "0.1.11" | 460 | version = "0.1.12" |
451 | source = "registry+https://github.com/rust-lang/crates.io-index" | 461 | source = "registry+https://github.com/rust-lang/crates.io-index" |
452 | checksum = "8a0d737e0f947a1864e93d33fdef4af8445a00d1ed8dc0c8ddb73139ea6abf15" | 462 | checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" |
453 | dependencies = [ | 463 | dependencies = [ |
454 | "libc", | 464 | "libc", |
455 | ] | 465 | ] |
@@ -814,9 +824,9 @@ dependencies = [ | |||
814 | 824 | ||
815 | [[package]] | 825 | [[package]] |
816 | name = "paste" | 826 | name = "paste" |
817 | version = "0.1.10" | 827 | version = "0.1.11" |
818 | source = "registry+https://github.com/rust-lang/crates.io-index" | 828 | source = "registry+https://github.com/rust-lang/crates.io-index" |
819 | checksum = "ab4fb1930692d1b6a9cfabdde3d06ea0a7d186518e2f4d67660d8970e2fa647a" | 829 | checksum = "a3c897744f63f34f7ae3a024d9162bb5001f4ad661dd24bea0dc9f075d2de1c6" |
820 | dependencies = [ | 830 | dependencies = [ |
821 | "paste-impl", | 831 | "paste-impl", |
822 | "proc-macro-hack", | 832 | "proc-macro-hack", |
@@ -824,9 +834,9 @@ dependencies = [ | |||
824 | 834 | ||
825 | [[package]] | 835 | [[package]] |
826 | name = "paste-impl" | 836 | name = "paste-impl" |
827 | version = "0.1.10" | 837 | version = "0.1.11" |
828 | source = "registry+https://github.com/rust-lang/crates.io-index" | 838 | source = "registry+https://github.com/rust-lang/crates.io-index" |
829 | checksum = "a62486e111e571b1e93b710b61e8f493c0013be39629b714cb166bdb06aa5a8a" | 839 | checksum = "66fd6f92e3594f2dd7b3fc23e42d82e292f7bcda6d8e5dcd167072327234ab89" |
830 | dependencies = [ | 840 | dependencies = [ |
831 | "proc-macro-hack", | 841 | "proc-macro-hack", |
832 | "proc-macro2", | 842 | "proc-macro2", |
@@ -885,9 +895,9 @@ dependencies = [ | |||
885 | 895 | ||
886 | [[package]] | 896 | [[package]] |
887 | name = "quote" | 897 | name = "quote" |
888 | version = "1.0.3" | 898 | version = "1.0.4" |
889 | source = "registry+https://github.com/rust-lang/crates.io-index" | 899 | source = "registry+https://github.com/rust-lang/crates.io-index" |
890 | checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" | 900 | checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" |
891 | dependencies = [ | 901 | dependencies = [ |
892 | "proc-macro2", | 902 | "proc-macro2", |
893 | ] | 903 | ] |
@@ -1023,7 +1033,7 @@ dependencies = [ | |||
1023 | "chalk-ir", | 1033 | "chalk-ir", |
1024 | "chalk-rust-ir", | 1034 | "chalk-rust-ir", |
1025 | "chalk-solve", | 1035 | "chalk-solve", |
1026 | "ena", | 1036 | "ena 0.14.0", |
1027 | "insta", | 1037 | "insta", |
1028 | "itertools", | 1038 | "itertools", |
1029 | "log", | 1039 | "log", |
@@ -1374,9 +1384,9 @@ dependencies = [ | |||
1374 | 1384 | ||
1375 | [[package]] | 1385 | [[package]] |
1376 | name = "rustc-ap-rustc_lexer" | 1386 | name = "rustc-ap-rustc_lexer" |
1377 | version = "652.0.0" | 1387 | version = "656.0.0" |
1378 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1388 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1379 | checksum = "3a6a43c4d0889218c5e2ae68ffea239f303fc05ab1078c73f74e63feb87f7889" | 1389 | checksum = "9cbba98ec46e96a4663197dfa8c0378752de2006e314e5400c0ca74929d6692f" |
1380 | dependencies = [ | 1390 | dependencies = [ |
1381 | "unicode-xid", | 1391 | "unicode-xid", |
1382 | ] | 1392 | ] |
@@ -1486,18 +1496,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" | |||
1486 | 1496 | ||
1487 | [[package]] | 1497 | [[package]] |
1488 | name = "serde" | 1498 | name = "serde" |
1489 | version = "1.0.104" | 1499 | version = "1.0.106" |
1490 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1500 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1491 | checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" | 1501 | checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" |
1492 | dependencies = [ | 1502 | dependencies = [ |
1493 | "serde_derive", | 1503 | "serde_derive", |
1494 | ] | 1504 | ] |
1495 | 1505 | ||
1496 | [[package]] | 1506 | [[package]] |
1497 | name = "serde_derive" | 1507 | name = "serde_derive" |
1498 | version = "1.0.104" | 1508 | version = "1.0.106" |
1499 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1509 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1500 | checksum = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" | 1510 | checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" |
1501 | dependencies = [ | 1511 | dependencies = [ |
1502 | "proc-macro2", | 1512 | "proc-macro2", |
1503 | "quote", | 1513 | "quote", |
@@ -1506,9 +1516,9 @@ dependencies = [ | |||
1506 | 1516 | ||
1507 | [[package]] | 1517 | [[package]] |
1508 | name = "serde_json" | 1518 | name = "serde_json" |
1509 | version = "1.0.51" | 1519 | version = "1.0.52" |
1510 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1520 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1511 | checksum = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" | 1521 | checksum = "a7894c8ed05b7a3a279aeb79025fdec1d3158080b75b98a08faf2806bb799edd" |
1512 | dependencies = [ | 1522 | dependencies = [ |
1513 | "itoa", | 1523 | "itoa", |
1514 | "ryu", | 1524 | "ryu", |
@@ -1607,6 +1617,16 @@ dependencies = [ | |||
1607 | ] | 1617 | ] |
1608 | 1618 | ||
1609 | [[package]] | 1619 | [[package]] |
1620 | name = "terminal_size" | ||
1621 | version = "0.1.12" | ||
1622 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1623 | checksum = "8038f95fc7a6f351163f4b964af631bd26c9e828f7db085f2a84aca56f70d13b" | ||
1624 | dependencies = [ | ||
1625 | "libc", | ||
1626 | "winapi 0.3.8", | ||
1627 | ] | ||
1628 | |||
1629 | [[package]] | ||
1610 | name = "termios" | 1630 | name = "termios" |
1611 | version = "0.3.2" | 1631 | version = "0.3.2" |
1612 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" |
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 04d3cd6a2..65db6d1b0 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml | |||
@@ -11,7 +11,7 @@ doctest = false | |||
11 | itertools = "0.9.0" | 11 | itertools = "0.9.0" |
12 | arrayvec = "0.5.1" | 12 | arrayvec = "0.5.1" |
13 | smallvec = "1.2.0" | 13 | smallvec = "1.2.0" |
14 | ena = "0.13.1" | 14 | ena = "0.14.0" |
15 | log = "0.4.8" | 15 | log = "0.4.8" |
16 | rustc-hash = "1.1.0" | 16 | rustc-hash = "1.1.0" |
17 | 17 | ||
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 4b081bf6c..d37260e96 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs | |||
@@ -33,7 +33,11 @@ impl ShortLabel for ast::EnumDef { | |||
33 | 33 | ||
34 | impl ShortLabel for ast::TraitDef { | 34 | impl ShortLabel for ast::TraitDef { |
35 | fn short_label(&self) -> Option<String> { | 35 | fn short_label(&self) -> Option<String> { |
36 | short_label_from_node(self, "trait ") | 36 | if self.unsafe_token().is_some() { |
37 | short_label_from_node(self, "unsafe trait ") | ||
38 | } else { | ||
39 | short_label_from_node(self, "trait ") | ||
40 | } | ||
37 | } | 41 | } |
38 | } | 42 | } |
39 | 43 | ||
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a62f598f0..54d318858 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -869,4 +869,15 @@ fn func(foo: i32) { if true { <|>foo; }; } | |||
869 | &[r#"pub(crate) async unsafe extern "C" fn foo()"#], | 869 | &[r#"pub(crate) async unsafe extern "C" fn foo()"#], |
870 | ); | 870 | ); |
871 | } | 871 | } |
872 | |||
873 | #[test] | ||
874 | fn test_hover_trait_show_qualifiers() { | ||
875 | check_hover_result( | ||
876 | " | ||
877 | //- /lib.rs | ||
878 | unsafe trait foo<|>() {} | ||
879 | ", | ||
880 | &["unsafe trait foo"], | ||
881 | ); | ||
882 | } | ||
872 | } | 883 | } |
diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index ac2d156dc..886e14870 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml | |||
@@ -21,4 +21,4 @@ test_utils = { path = "../test_utils" } | |||
21 | cargo_metadata = "0.9.1" | 21 | cargo_metadata = "0.9.1" |
22 | difference = "2.0.0" | 22 | difference = "2.0.0" |
23 | # used as proc macro test target | 23 | # used as proc macro test target |
24 | serde_derive = "=1.0.104" | 24 | serde_derive = "=1.0.106" |
diff --git a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt index 1f5d940fa..6776f5231 100644 --- a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt +++ b/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | |||
@@ -1,6 +1,11 @@ | |||
1 | SUBTREE $ | 1 | SUBTREE $ |
2 | PUNCH # [alone] 4294967295 | 2 | PUNCH # [alone] 4294967295 |
3 | SUBTREE [] 4294967295 | 3 | SUBTREE [] 4294967295 |
4 | IDENT doc 4294967295 | ||
5 | SUBTREE () 4294967295 | ||
6 | IDENT hidden 4294967295 | ||
7 | PUNCH # [alone] 4294967295 | ||
8 | SUBTREE [] 4294967295 | ||
4 | IDENT allow 4294967295 | 9 | IDENT allow 4294967295 |
5 | SUBTREE () 4294967295 | 10 | SUBTREE () 4294967295 |
6 | IDENT non_upper_case_globals 4294967295 | 11 | IDENT non_upper_case_globals 4294967295 |
@@ -184,4 +189,4 @@ SUBTREE $ | |||
184 | IDENT end 4294967295 | 189 | IDENT end 4294967295 |
185 | SUBTREE () 4294967295 | 190 | SUBTREE () 4294967295 |
186 | IDENT __serde_state 4294967295 | 191 | IDENT __serde_state 4294967295 |
187 | PUNCH ; [alone] 4294967295 \ No newline at end of file | 192 | PUNCH ; [alone] 4294967295 |
diff --git a/crates/ra_proc_macro_srv/src/tests/mod.rs b/crates/ra_proc_macro_srv/src/tests/mod.rs index 03f79bc5d..9cf58511c 100644 --- a/crates/ra_proc_macro_srv/src/tests/mod.rs +++ b/crates/ra_proc_macro_srv/src/tests/mod.rs | |||
@@ -10,7 +10,7 @@ fn test_derive_serialize_proc_macro() { | |||
10 | assert_expand( | 10 | assert_expand( |
11 | "serde_derive", | 11 | "serde_derive", |
12 | "Serialize", | 12 | "Serialize", |
13 | "1.0.104", | 13 | "1.0.106", |
14 | r##"struct Foo {}"##, | 14 | r##"struct Foo {}"##, |
15 | include_str!("fixtures/test_serialize_proc_macro.txt"), | 15 | include_str!("fixtures/test_serialize_proc_macro.txt"), |
16 | ); | 16 | ); |
@@ -21,7 +21,7 @@ fn test_derive_serialize_proc_macro_failed() { | |||
21 | assert_expand( | 21 | assert_expand( |
22 | "serde_derive", | 22 | "serde_derive", |
23 | "Serialize", | 23 | "Serialize", |
24 | "1.0.104", | 24 | "1.0.106", |
25 | r##" | 25 | r##" |
26 | struct {} | 26 | struct {} |
27 | "##, | 27 | "##, |
@@ -37,7 +37,7 @@ SUBTREE $ | |||
37 | 37 | ||
38 | #[test] | 38 | #[test] |
39 | fn test_derive_proc_macro_list() { | 39 | fn test_derive_proc_macro_list() { |
40 | let res = list("serde_derive", "1.0.104").join("\n"); | 40 | let res = list("serde_derive", "1.0.106").join("\n"); |
41 | 41 | ||
42 | assert_eq_text!( | 42 | assert_eq_text!( |
43 | &res, | 43 | &res, |
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index b10644b4b..5e651fe70 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -18,7 +18,7 @@ ra_db = { path = "../ra_db" } | |||
18 | ra_cfg = { path = "../ra_cfg" } | 18 | ra_cfg = { path = "../ra_cfg" } |
19 | ra_proc_macro = { path = "../ra_proc_macro" } | 19 | ra_proc_macro = { path = "../ra_proc_macro" } |
20 | 20 | ||
21 | serde = { version = "1.0.104", features = ["derive"] } | 21 | serde = { version = "1.0.106", features = ["derive"] } |
22 | serde_json = "1.0.48" | 22 | serde_json = "1.0.48" |
23 | 23 | ||
24 | anyhow = "1.0.26" | 24 | anyhow = "1.0.26" |
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 7ffe46c69..c07ff488e 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -13,7 +13,7 @@ doctest = false | |||
13 | [dependencies] | 13 | [dependencies] |
14 | itertools = "0.9.0" | 14 | itertools = "0.9.0" |
15 | rowan = "0.10.0" | 15 | rowan = "0.10.0" |
16 | rustc_lexer = { version = "652.0.0", package = "rustc-ap-rustc_lexer" } | 16 | rustc_lexer = { version = "656.0.0", package = "rustc-ap-rustc_lexer" } |
17 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
18 | arrayvec = "0.5.1" | 18 | arrayvec = "0.5.1" |
19 | once_cell = "1.3.1" | 19 | once_cell = "1.3.1" |
@@ -27,7 +27,7 @@ ra_parser = { path = "../ra_parser" } | |||
27 | # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here | 27 | # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here |
28 | # to reduce number of compilations | 28 | # to reduce number of compilations |
29 | smol_str = { version = "0.1.15", features = ["serde"] } | 29 | smol_str = { version = "0.1.15", features = ["serde"] } |
30 | serde = { version = "1.0.104", features = ["derive"] } | 30 | serde = { version = "1.0.106", features = ["derive"] } |
31 | 31 | ||
32 | [dev-dependencies] | 32 | [dev-dependencies] |
33 | test_utils = { path = "../test_utils" } | 33 | test_utils = { path = "../test_utils" } |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index f2ea5088e..45e3dd2d3 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -407,7 +407,7 @@ impl ast::Visibility { | |||
407 | } else if self.super_token().is_some() { | 407 | } else if self.super_token().is_some() { |
408 | VisibilityKind::PubSuper | 408 | VisibilityKind::PubSuper |
409 | } else if self.self_token().is_some() { | 409 | } else if self.self_token().is_some() { |
410 | VisibilityKind::PubSuper | 410 | VisibilityKind::PubSelf |
411 | } else { | 411 | } else { |
412 | VisibilityKind::Pub | 412 | VisibilityKind::Pub |
413 | } | 413 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 81260680f..3f16592b6 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -1241,6 +1241,8 @@ pub struct PathSegment { | |||
1241 | impl PathSegment { | 1241 | impl PathSegment { |
1242 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } | 1242 | pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) } |
1243 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } | 1243 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } |
1244 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) } | ||
1245 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) } | ||
1244 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } | 1246 | pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) } |
1245 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 1247 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
1246 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | 1248 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } |
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs index f450ef4a2..1a5a6dc06 100644 --- a/crates/ra_syntax/src/parsing/lexer.rs +++ b/crates/ra_syntax/src/parsing/lexer.rs | |||
@@ -180,7 +180,7 @@ fn rustc_token_kind_to_syntax_kind( | |||
180 | return (syntax_kind, None); | 180 | return (syntax_kind, None); |
181 | 181 | ||
182 | fn match_literal_kind(kind: &rustc_lexer::LiteralKind) -> (SyntaxKind, Option<&'static str>) { | 182 | fn match_literal_kind(kind: &rustc_lexer::LiteralKind) -> (SyntaxKind, Option<&'static str>) { |
183 | use rustc_lexer::LiteralKind as LK; | 183 | use rustc_lexer::{LexRawStrError, LiteralKind as LK}; |
184 | 184 | ||
185 | #[rustfmt::skip] | 185 | #[rustfmt::skip] |
186 | let syntax_kind = match *kind { | 186 | let syntax_kind = match *kind { |
@@ -215,21 +215,28 @@ fn rustc_token_kind_to_syntax_kind( | |||
215 | return (BYTE_STRING, Some("Missing trailing `\"` symbol to terminate the byte string literal")) | 215 | return (BYTE_STRING, Some("Missing trailing `\"` symbol to terminate the byte string literal")) |
216 | } | 216 | } |
217 | 217 | ||
218 | LK::RawStr { started: true, terminated: true, .. } => RAW_STRING, | 218 | LK::RawStr(str) => match str.validate() { |
219 | LK::RawStr { started: true, terminated: false, .. } => { | 219 | Ok(_) => RAW_STRING, |
220 | return (RAW_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw string literal")) | 220 | Err(LexRawStrError::InvalidStarter) => return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal")), |
221 | } | 221 | Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found { |
222 | LK::RawStr { started: false, .. } => { | 222 | return (RAW_STRING, Some("Missing trailing `\"` to terminate the raw string literal")) |
223 | return (RAW_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw string literal")) | 223 | } else { |
224 | } | 224 | return (RAW_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw string literal")) |
225 | |||
226 | }, | ||
227 | Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_STRING, Some("Too many `#` symbols: raw strings may be delimited by up to 65535 `#` symbols")), | ||
228 | }, | ||
229 | LK::RawByteStr(str) => match str.validate() { | ||
230 | Ok(_) => RAW_BYTE_STRING, | ||
231 | Err(LexRawStrError::InvalidStarter) => return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal")), | ||
232 | Err(LexRawStrError::NoTerminator { expected, found, .. }) => if expected == found { | ||
233 | return (RAW_BYTE_STRING, Some("Missing trailing `\"` to terminate the raw byte string literal")) | ||
234 | } else { | ||
235 | return (RAW_BYTE_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw byte string literal")) | ||
225 | 236 | ||
226 | LK::RawByteStr { started: true, terminated: true, .. } => RAW_BYTE_STRING, | 237 | }, |
227 | LK::RawByteStr { started: true, terminated: false, .. } => { | 238 | Err(LexRawStrError::TooManyDelimiters { .. }) => return (RAW_BYTE_STRING, Some("Too many `#` symbols: raw byte strings may be delimited by up to 65535 `#` symbols")), |
228 | return (RAW_BYTE_STRING, Some("Missing trailing `\"` with `#` symbols to terminate the raw byte string literal")) | 239 | }, |
229 | } | ||
230 | LK::RawByteStr { started: false, .. } => { | ||
231 | return (RAW_BYTE_STRING, Some("Missing `\"` symbol after `#` symbols to begin the raw byte string literal")) | ||
232 | } | ||
233 | }; | 240 | }; |
234 | 241 | ||
235 | (syntax_kind, None) | 242 | (syntax_kind, None) |
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index f0b3dec63..e075cd801 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs | |||
@@ -96,7 +96,7 @@ pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> { | |||
96 | ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), | 96 | ast::RecordField(it) => validate_numeric_name(it.name_ref(), &mut errors), |
97 | ast::Visibility(it) => validate_visibility(it, &mut errors), | 97 | ast::Visibility(it) => validate_visibility(it, &mut errors), |
98 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), | 98 | ast::RangeExpr(it) => validate_range_expr(it, &mut errors), |
99 | ast::PathSegment(it) => validate_crate_keyword_in_path_segment(it, &mut errors), | 99 | ast::PathSegment(it) => validate_path_keywords(it, &mut errors), |
100 | _ => (), | 100 | _ => (), |
101 | } | 101 | } |
102 | } | 102 | } |
@@ -224,59 +224,82 @@ fn validate_range_expr(expr: ast::RangeExpr, errors: &mut Vec<SyntaxError>) { | |||
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | fn validate_crate_keyword_in_path_segment( | 227 | fn validate_path_keywords(segment: ast::PathSegment, errors: &mut Vec<SyntaxError>) { |
228 | segment: ast::PathSegment, | 228 | use ast::PathSegmentKind; |
229 | errors: &mut Vec<SyntaxError>, | ||
230 | ) { | ||
231 | const ERR_MSG: &str = "The `crate` keyword is only allowed as the first segment of a path"; | ||
232 | 229 | ||
233 | let crate_token = match segment.crate_token() { | 230 | let path = segment.parent_path(); |
234 | None => return, | 231 | let is_path_start = segment.coloncolon_token().is_none() && path.qualifier().is_none(); |
235 | Some(it) => it, | 232 | |
236 | }; | 233 | if let Some(token) = segment.self_token() { |
234 | if !is_path_start { | ||
235 | errors.push(SyntaxError::new( | ||
236 | "The `self` keyword is only allowed as the first segment of a path", | ||
237 | token.text_range(), | ||
238 | )); | ||
239 | } | ||
240 | } else if let Some(token) = segment.crate_token() { | ||
241 | if !is_path_start || use_prefix(path).is_some() { | ||
242 | errors.push(SyntaxError::new( | ||
243 | "The `crate` keyword is only allowed as the first segment of a path", | ||
244 | token.text_range(), | ||
245 | )); | ||
246 | } | ||
247 | } else if let Some(token) = segment.super_token() { | ||
248 | if !all_supers(&path) { | ||
249 | errors.push(SyntaxError::new( | ||
250 | "The `super` keyword may only be preceded by other `super`s", | ||
251 | token.text_range(), | ||
252 | )); | ||
253 | return; | ||
254 | } | ||
237 | 255 | ||
238 | // Disallow both ::crate and foo::crate | 256 | let mut curr_path = path; |
239 | let mut path = segment.parent_path(); | 257 | while let Some(prefix) = use_prefix(curr_path) { |
240 | if segment.coloncolon_token().is_some() || path.qualifier().is_some() { | 258 | if !all_supers(&prefix) { |
241 | errors.push(SyntaxError::new(ERR_MSG, crate_token.text_range())); | 259 | errors.push(SyntaxError::new( |
242 | return; | 260 | "The `super` keyword may only be preceded by other `super`s", |
261 | token.text_range(), | ||
262 | )); | ||
263 | return; | ||
264 | } | ||
265 | curr_path = prefix; | ||
266 | } | ||
243 | } | 267 | } |
244 | 268 | ||
245 | // For expressions and types, validation is complete, but we still have | 269 | fn use_prefix(mut path: ast::Path) -> Option<ast::Path> { |
246 | // to handle invalid UseItems like this: | 270 | for node in path.syntax().ancestors().skip(1) { |
247 | // | 271 | match_ast! { |
248 | // use foo:{crate::bar::baz}; | 272 | match node { |
249 | // | 273 | ast::UseTree(it) => if let Some(tree_path) = it.path() { |
250 | // To handle this we must inspect the parent `UseItem`s and `UseTree`s | 274 | // Even a top-level path exists within a `UseTree` so we must explicitly |
251 | // but right now we're looking deep inside the nested `Path` nodes because | 275 | // allow our path but disallow anything else |
252 | // `Path`s are left-associative: | 276 | if tree_path != path { |
253 | // | 277 | return Some(tree_path); |
254 | // ((crate)::bar)::baz) | 278 | } |
255 | // ^ current value of path | 279 | }, |
256 | // | 280 | ast::UseTreeList(_it) => continue, |
257 | // So we need to climb to the top | 281 | ast::Path(parent) => path = parent, |
258 | while let Some(parent) = path.parent_path() { | 282 | _ => return None, |
259 | path = parent; | 283 | } |
284 | }; | ||
285 | } | ||
286 | return None; | ||
260 | } | 287 | } |
261 | 288 | ||
262 | // Now that we've found the whole path we need to see if there's a prefix | 289 | fn all_supers(path: &ast::Path) -> bool { |
263 | // somewhere in the UseTree hierarchy. This check is arbitrarily deep | 290 | let segment = match path.segment() { |
264 | // because rust allows arbitrary nesting like so: | 291 | Some(it) => it, |
265 | // | 292 | None => return false, |
266 | // use {foo::{{{{crate::bar::baz}}}}}; | ||
267 | for node in path.syntax().ancestors().skip(1) { | ||
268 | match_ast! { | ||
269 | match node { | ||
270 | ast::UseTree(it) => if let Some(tree_path) = it.path() { | ||
271 | // Even a top-level path exists within a `UseTree` so we must explicitly | ||
272 | // allow our path but disallow anything else | ||
273 | if tree_path != path { | ||
274 | errors.push(SyntaxError::new(ERR_MSG, crate_token.text_range())); | ||
275 | } | ||
276 | }, | ||
277 | ast::UseTreeList(_it) => continue, | ||
278 | _ => return, | ||
279 | } | ||
280 | }; | 293 | }; |
294 | |||
295 | if segment.kind() != Some(PathSegmentKind::SuperKw) { | ||
296 | return false; | ||
297 | } | ||
298 | |||
299 | if let Some(ref subpath) = path.qualifier() { | ||
300 | return all_supers(subpath); | ||
301 | } | ||
302 | |||
303 | return true; | ||
281 | } | 304 | } |
282 | } | 305 | } |
diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast new file mode 100644 index 000000000..d0360c467 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast | |||
@@ -0,0 +1,70 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "use" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] | ||
7 | [email protected] | ||
8 | [email protected] "::" | ||
9 | [email protected] "super" | ||
10 | [email protected] ";" | ||
11 | [email protected] "\n" | ||
12 | [email protected] | ||
13 | [email protected] "use" | ||
14 | [email protected] " " | ||
15 | [email protected] | ||
16 | [email protected] | ||
17 | [email protected] | ||
18 | [email protected] | ||
19 | [email protected] | ||
20 | [email protected] "a" | ||
21 | [email protected] "::" | ||
22 | [email protected] | ||
23 | [email protected] "super" | ||
24 | [email protected] ";" | ||
25 | [email protected] "\n" | ||
26 | [email protected] | ||
27 | [email protected] "use" | ||
28 | [email protected] " " | ||
29 | [email protected] | ||
30 | [email protected] | ||
31 | [email protected] | ||
32 | [email protected] | ||
33 | [email protected] | ||
34 | [email protected] "super" | ||
35 | [email protected] "::" | ||
36 | [email protected] | ||
37 | [email protected] | ||
38 | [email protected] "a" | ||
39 | [email protected] "::" | ||
40 | [email protected] | ||
41 | [email protected] "super" | ||
42 | [email protected] ";" | ||
43 | [email protected] "\n" | ||
44 | [email protected] | ||
45 | [email protected] "use" | ||
46 | [email protected] " " | ||
47 | [email protected] | ||
48 | [email protected] | ||
49 | [email protected] | ||
50 | [email protected] | ||
51 | [email protected] "a" | ||
52 | [email protected] "::" | ||
53 | [email protected] | ||
54 | [email protected] "{" | ||
55 | [email protected] | ||
56 | [email protected] | ||
57 | [email protected] | ||
58 | [email protected] | ||
59 | [email protected] "super" | ||
60 | [email protected] "::" | ||
61 | [email protected] | ||
62 | [email protected] | ||
63 | [email protected] "b" | ||
64 | [email protected] "}" | ||
65 | [email protected] ";" | ||
66 | [email protected] "\n" | ||
67 | error 6..11: The `super` keyword may only be preceded by other `super`s | ||
68 | error 20..25: The `super` keyword may only be preceded by other `super`s | ||
69 | error 41..46: The `super` keyword may only be preceded by other `super`s | ||
70 | error 56..61: The `super` keyword may only be preceded by other `super`s | ||
diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs new file mode 100644 index 000000000..bd4d58042 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | use ::super; | ||
2 | use a::super; | ||
3 | use super::a::super; | ||
4 | use a::{super::b}; | ||
diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast new file mode 100644 index 000000000..4f382b06c --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast | |||
@@ -0,0 +1,27 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "use" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] | ||
7 | [email protected] | ||
8 | [email protected] "::" | ||
9 | [email protected] "self" | ||
10 | [email protected] ";" | ||
11 | [email protected] "\n" | ||
12 | [email protected] | ||
13 | [email protected] "use" | ||
14 | [email protected] " " | ||
15 | [email protected] | ||
16 | [email protected] | ||
17 | [email protected] | ||
18 | [email protected] | ||
19 | [email protected] | ||
20 | [email protected] "a" | ||
21 | [email protected] "::" | ||
22 | [email protected] | ||
23 | [email protected] "self" | ||
24 | [email protected] ";" | ||
25 | [email protected] "\n" | ||
26 | error 6..10: The `self` keyword is only allowed as the first segment of a path | ||
27 | error 19..23: The `self` keyword is only allowed as the first segment of a path | ||
diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs new file mode 100644 index 000000000..b9e1d7d8b --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs | |||
@@ -0,0 +1,2 @@ | |||
1 | use ::self; | ||
2 | use a::self; | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast index a5a90df7b..05d9c05ad 100644 --- a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast +++ b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@0..65 | 1 | SOURCE_FILE@0..38 |
2 | [email protected] | 2 | [email protected] |
3 | [email protected] "use" | 3 | [email protected] "use" |
4 | [email protected] " " | 4 | [email protected] " " |
@@ -31,27 +31,3 @@ [email protected] | |||
31 | [email protected] "bar" | 31 | [email protected] "bar" |
32 | [email protected] ";" | 32 | [email protected] ";" |
33 | [email protected] "\n" | 33 | [email protected] "\n" |
34 | [email protected] | ||
35 | [email protected] "use" | ||
36 | [email protected] " " | ||
37 | [email protected] | ||
38 | [email protected] | ||
39 | [email protected] | ||
40 | [email protected] | ||
41 | [email protected] | ||
42 | [email protected] | ||
43 | [email protected] "::" | ||
44 | [email protected] "self" | ||
45 | [email protected] "::" | ||
46 | [email protected] | ||
47 | [email protected] | ||
48 | [email protected] "a" | ||
49 | [email protected] "::" | ||
50 | [email protected] | ||
51 | [email protected] "super" | ||
52 | [email protected] "::" | ||
53 | [email protected] | ||
54 | [email protected] | ||
55 | [email protected] "bar" | ||
56 | [email protected] ";" | ||
57 | [email protected] "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs index faf6a42c7..9d9eb9917 100644 --- a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs +++ b/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs | |||
@@ -1,3 +1,2 @@ | |||
1 | use self::foo; | 1 | use self::foo; |
2 | use super::super::bar; | 2 | use super::super::bar; |
3 | use ::self::a::super::bar; | ||
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 0459807fc..8c94f430a 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -26,7 +26,7 @@ pico-args = "0.3.1" | |||
26 | rand = { version = "0.7.3", features = ["small_rng"] } | 26 | rand = { version = "0.7.3", features = ["small_rng"] } |
27 | relative-path = "1.0.0" | 27 | relative-path = "1.0.0" |
28 | rustc-hash = "1.1.0" | 28 | rustc-hash = "1.1.0" |
29 | serde = { version = "1.0.104", features = ["derive"] } | 29 | serde = { version = "1.0.106", features = ["derive"] } |
30 | serde_json = "1.0.48" | 30 | serde_json = "1.0.48" |
31 | threadpool = "1.7.1" | 31 | threadpool = "1.7.1" |
32 | 32 | ||
diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index e22ab8402..c0d320926 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs | |||
@@ -3,13 +3,13 @@ | |||
3 | use crate::semantic_tokens; | 3 | use crate::semantic_tokens; |
4 | 4 | ||
5 | use lsp_types::{ | 5 | use lsp_types::{ |
6 | CallHierarchyServerCapability, CodeActionProviderCapability, CodeLensOptions, | 6 | CallHierarchyServerCapability, CodeActionOptions, CodeActionProviderCapability, |
7 | CompletionOptions, DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, | 7 | CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, |
8 | ImplementationProviderCapability, RenameOptions, RenameProviderCapability, SaveOptions, | 8 | FoldingRangeProviderCapability, ImplementationProviderCapability, RenameOptions, |
9 | SelectionRangeProviderCapability, SemanticTokensDocumentProvider, SemanticTokensLegend, | 9 | RenameProviderCapability, SaveOptions, SelectionRangeProviderCapability, |
10 | SemanticTokensOptions, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, | 10 | SemanticTokensDocumentProvider, SemanticTokensLegend, SemanticTokensOptions, |
11 | TextDocumentSyncKind, TextDocumentSyncOptions, TypeDefinitionProviderCapability, | 11 | ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, |
12 | WorkDoneProgressOptions, | 12 | TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | pub fn server_capabilities() -> ServerCapabilities { | 15 | pub fn server_capabilities() -> ServerCapabilities { |
@@ -40,7 +40,20 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
40 | document_highlight_provider: Some(true), | 40 | document_highlight_provider: Some(true), |
41 | document_symbol_provider: Some(true), | 41 | document_symbol_provider: Some(true), |
42 | workspace_symbol_provider: Some(true), | 42 | workspace_symbol_provider: Some(true), |
43 | code_action_provider: Some(CodeActionProviderCapability::Simple(true)), | 43 | code_action_provider: Some(CodeActionProviderCapability::Options(CodeActionOptions { |
44 | // Advertise support for all built-in CodeActionKinds | ||
45 | code_action_kinds: Some(vec![ | ||
46 | String::new(), | ||
47 | lsp_types::code_action_kind::QUICKFIX.to_string(), | ||
48 | lsp_types::code_action_kind::REFACTOR.to_string(), | ||
49 | lsp_types::code_action_kind::REFACTOR_EXTRACT.to_string(), | ||
50 | lsp_types::code_action_kind::REFACTOR_INLINE.to_string(), | ||
51 | lsp_types::code_action_kind::REFACTOR_REWRITE.to_string(), | ||
52 | lsp_types::code_action_kind::SOURCE.to_string(), | ||
53 | lsp_types::code_action_kind::SOURCE_ORGANIZE_IMPORTS.to_string(), | ||
54 | ]), | ||
55 | work_done_progress_options: Default::default(), | ||
56 | })), | ||
44 | code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }), | 57 | code_lens_provider: Some(CodeLensOptions { resolve_provider: Some(true) }), |
45 | document_formatting_provider: Some(true), | 58 | document_formatting_provider: Some(true), |
46 | document_range_formatting_provider: None, | 59 | document_range_formatting_provider: None, |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 74a63e32a..177da94cc 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -70,6 +70,7 @@ pub struct ClientCapsConfig { | |||
70 | pub location_link: bool, | 70 | pub location_link: bool, |
71 | pub line_folding_only: bool, | 71 | pub line_folding_only: bool, |
72 | pub hierarchical_symbols: bool, | 72 | pub hierarchical_symbols: bool, |
73 | pub code_action_literals: bool, | ||
73 | } | 74 | } |
74 | 75 | ||
75 | impl Default for Config { | 76 | impl Default for Config { |
@@ -221,6 +222,11 @@ impl Config { | |||
221 | { | 222 | { |
222 | self.client_caps.hierarchical_symbols = value | 223 | self.client_caps.hierarchical_symbols = value |
223 | } | 224 | } |
225 | if let Some(value) = | ||
226 | caps.code_action.as_ref().and_then(|it| Some(it.code_action_literal_support.is_some())) | ||
227 | { | ||
228 | self.client_caps.code_action_literals = value; | ||
229 | } | ||
224 | self.completion.allow_snippets(false); | 230 | self.completion.allow_snippets(false); |
225 | if let Some(completion) = &caps.completion { | 231 | if let Some(completion) = &caps.completion { |
226 | if let Some(completion_item) = &completion.completion_item { | 232 | if let Some(completion_item) = &completion.completion_item { |
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 8db2dfa0c..0f623949e 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs | |||
@@ -19,8 +19,7 @@ use lsp_types::{ | |||
19 | TextEdit, Url, WorkspaceEdit, | 19 | TextEdit, Url, WorkspaceEdit, |
20 | }; | 20 | }; |
21 | use ra_ide::{ | 21 | use ra_ide::{ |
22 | Assist, AssistId, FileId, FilePosition, FileRange, Query, RangeInfo, Runnable, RunnableKind, | 22 | Assist, FileId, FilePosition, FileRange, Query, RangeInfo, Runnable, RunnableKind, SearchScope, |
23 | SearchScope, | ||
24 | }; | 23 | }; |
25 | use ra_prof::profile; | 24 | use ra_prof::profile; |
26 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextSize}; | 25 | use ra_syntax::{AstNode, SyntaxKind, TextRange, TextSize}; |
@@ -702,15 +701,9 @@ fn create_single_code_action(assist: Assist, world: &WorldSnapshot) -> Result<Co | |||
702 | arguments: Some(vec![arg]), | 701 | arguments: Some(vec![arg]), |
703 | }; | 702 | }; |
704 | 703 | ||
705 | let kind = match assist.id { | ||
706 | AssistId("introduce_variable") => Some("refactor.extract.variable".to_string()), | ||
707 | AssistId("add_custom_impl") => Some("refactor.rewrite.add_custom_impl".to_string()), | ||
708 | _ => None, | ||
709 | }; | ||
710 | |||
711 | Ok(CodeAction { | 704 | Ok(CodeAction { |
712 | title, | 705 | title, |
713 | kind, | 706 | kind: Some(String::new()), |
714 | diagnostics: None, | 707 | diagnostics: None, |
715 | edit: None, | 708 | edit: None, |
716 | command: Some(command), | 709 | command: Some(command), |
@@ -812,6 +805,23 @@ pub fn handle_code_action( | |||
812 | } | 805 | } |
813 | } | 806 | } |
814 | 807 | ||
808 | // If the client only supports commands then filter the list | ||
809 | // and remove and actions that depend on edits. | ||
810 | if !world.config.client_caps.code_action_literals { | ||
811 | // FIXME: use drain_filter once it hits stable. | ||
812 | res = res | ||
813 | .into_iter() | ||
814 | .filter_map(|it| match it { | ||
815 | cmd @ lsp_types::CodeActionOrCommand::Command(_) => Some(cmd), | ||
816 | lsp_types::CodeActionOrCommand::CodeAction(action) => match action.command { | ||
817 | Some(cmd) if action.edit.is_none() => { | ||
818 | Some(lsp_types::CodeActionOrCommand::Command(cmd)) | ||
819 | } | ||
820 | _ => None, | ||
821 | }, | ||
822 | }) | ||
823 | .collect(); | ||
824 | } | ||
815 | Ok(Some(res)) | 825 | Ok(Some(res)) |
816 | } | 826 | } |
817 | 827 | ||
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs index e4fe3411a..8d47ee4f6 100644 --- a/crates/rust-analyzer/tests/heavy_tests/support.rs +++ b/crates/rust-analyzer/tests/heavy_tests/support.rs | |||
@@ -77,7 +77,11 @@ impl<'a> Project<'a> { | |||
77 | let roots = self.roots.into_iter().map(|root| tmp_dir.path().join(root)).collect(); | 77 | let roots = self.roots.into_iter().map(|root| tmp_dir.path().join(root)).collect(); |
78 | 78 | ||
79 | let mut config = Config { | 79 | let mut config = Config { |
80 | client_caps: ClientCapsConfig { location_link: true, ..Default::default() }, | 80 | client_caps: ClientCapsConfig { |
81 | location_link: true, | ||
82 | code_action_literals: true, | ||
83 | ..Default::default() | ||
84 | }, | ||
81 | with_sysroot: self.with_sysroot, | 85 | with_sysroot: self.with_sysroot, |
82 | ..Config::default() | 86 | ..Config::default() |
83 | }; | 87 | }; |
diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 3a337c574..cee916c09 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md | |||
@@ -46,7 +46,7 @@ can be quickly updated for small modifications. | |||
46 | 46 | ||
47 | Some of the components of this repository are generated through automatic | 47 | Some of the components of this repository are generated through automatic |
48 | processes. `cargo xtask codegen` runs all generation tasks. Generated code is | 48 | processes. `cargo xtask codegen` runs all generation tasks. Generated code is |
49 | commited to the git repository. | 49 | committed to the git repository. |
50 | 50 | ||
51 | In particular, `cargo xtask codegen` generates: | 51 | In particular, `cargo xtask codegen` generates: |
52 | 52 | ||
@@ -114,7 +114,7 @@ is responsible for guessing a HIR for a particular source position. | |||
114 | Underneath, HIR works on top of salsa, using a `HirDatabase` trait. | 114 | Underneath, HIR works on top of salsa, using a `HirDatabase` trait. |
115 | 115 | ||
116 | `ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and | 116 | `ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and |
117 | directly query the databse. | 117 | directly query the database. |
118 | 118 | ||
119 | The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API. | 119 | The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API. |
120 | 120 | ||
diff --git a/docs/dev/guide.md b/docs/dev/guide.md index abbe4c154..c3252f1f6 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md | |||
@@ -26,7 +26,7 @@ properties hold: | |||
26 | 26 | ||
27 | ## IDE API | 27 | ## IDE API |
28 | 28 | ||
29 | To see the bigger picture of how the IDE features works, let's take a look at the [`AnalysisHost`] and | 29 | To see the bigger picture of how the IDE features work, let's take a look at the [`AnalysisHost`] and |
30 | [`Analysis`] pair of types. `AnalysisHost` has three methods: | 30 | [`Analysis`] pair of types. `AnalysisHost` has three methods: |
31 | 31 | ||
32 | * `default()` for creating an empty analysis instance | 32 | * `default()` for creating an empty analysis instance |
@@ -131,7 +131,7 @@ mapping between `SourceRoot` IDs (which are assigned by the client) and actual | |||
131 | analyzer. | 131 | analyzer. |
132 | 132 | ||
133 | Note that `mod`, `#[path]` and `include!()` can only reference files from the | 133 | Note that `mod`, `#[path]` and `include!()` can only reference files from the |
134 | same source root. It is of course is possible to explicitly add extra files to | 134 | same source root. It is of course possible to explicitly add extra files to |
135 | the source root, even `/dev/random`. | 135 | the source root, even `/dev/random`. |
136 | 136 | ||
137 | ## Language Server Protocol | 137 | ## Language Server Protocol |
@@ -192,7 +192,7 @@ task will be canceled as soon as the main loop calls `apply_change` on the | |||
192 | [`schedule`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L426-L455 | 192 | [`schedule`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L426-L455 |
193 | [The task]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L205-L223 | 193 | [The task]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop/handlers.rs#L205-L223 |
194 | 194 | ||
195 | This concludes the overview of the analyzer's programing *interface*. Next, lets | 195 | This concludes the overview of the analyzer's programing *interface*. Next, let's |
196 | dig into the implementation! | 196 | dig into the implementation! |
197 | 197 | ||
198 | ## Salsa | 198 | ## Salsa |
@@ -480,7 +480,7 @@ throughout the analyzer: | |||
480 | ## Source Map pattern | 480 | ## Source Map pattern |
481 | 481 | ||
482 | Due to an obscure edge case in completion, IDE needs to know the syntax node of | 482 | Due to an obscure edge case in completion, IDE needs to know the syntax node of |
483 | an use statement which imported the given completion candidate. We can't just | 483 | a use statement which imported the given completion candidate. We can't just |
484 | store the syntax node as a part of name resolution: this will break | 484 | store the syntax node as a part of name resolution: this will break |
485 | incrementality, due to the fact that syntax changes after every file | 485 | incrementality, due to the fact that syntax changes after every file |
486 | modification. | 486 | modification. |
diff --git a/docs/user/readme.adoc b/docs/user/readme.adoc index 4cb1e23e8..b1af72ce6 100644 --- a/docs/user/readme.adoc +++ b/docs/user/readme.adoc | |||
@@ -201,7 +201,7 @@ let g:LanguageClient_serverCommands = { | |||
201 | 201 | ||
202 | 2. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): | 202 | 2. Configure by adding this to your vim/neovim config file (replacing the existing Rust-specific line if it exists): |
203 | + | 203 | + |
204 | [source,vim] | 204 | [source,vim] |
205 | ---- | 205 | ---- |
206 | let g:ycm_language_server = | 206 | let g:ycm_language_server = |
207 | \ [ | 207 | \ [ |
@@ -252,6 +252,15 @@ If it worked, you should see "rust-analyzer, Line X, Column Y" on the left side | |||
252 | 252 | ||
253 | If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>> section on installing the language server binary. | 253 | If you get an error saying `No such file or directory: 'rust-analyzer'`, see the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>> section on installing the language server binary. |
254 | 254 | ||
255 | === Gnome Builder | ||
256 | |||
257 | Prerequisites: You have installed the <<rust-analyzer-language-server-binary,`rust-analyzer` binary>>. | ||
258 | |||
259 | Gnome Builder currently has support for RLS, and there's no way to configure the language server executable. A future version might support `rust-analyzer` out of the box. | ||
260 | |||
261 | 1. Rename, symlink or copy the `rust-analyzer` binary to `rls` and place it somewhere Builder can find (in `PATH`, or under `~/.cargo/bin`). | ||
262 | 2. Enable the Rust Builder plugin. | ||
263 | |||
255 | == Usage | 264 | == Usage |
256 | 265 | ||
257 | See https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/features.md[features.md]. | 266 | See https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/features.md[features.md]. |
diff --git a/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index bdd42cb76..703fb9be9 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -593,7 +593,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
593 | qualifier: Path, | 593 | qualifier: Path, |
594 | } | 594 | } |
595 | struct PathSegment { | 595 | struct PathSegment { |
596 | T![::], T![crate], T![<], NameRef, TypeArgList, ParamList, RetType, PathType, T![>] | 596 | T![::], T![crate], T![self], T![super], T![<], NameRef, TypeArgList, ParamList, RetType, PathType, T![>] |
597 | } | 597 | } |
598 | struct TypeArgList { | 598 | struct TypeArgList { |
599 | T![::], | 599 | T![::], |