diff options
-rw-r--r-- | Cargo.lock | 33 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_db/src/cancellation.rs | 4 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 51 |
6 files changed, 61 insertions, 43 deletions
diff --git a/Cargo.lock b/Cargo.lock index d2d37f0c7..eb053a09c 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -66,11 +66,10 @@ dependencies = [ | |||
66 | 66 | ||
67 | [[package]] | 67 | [[package]] |
68 | name = "base64" | 68 | name = "base64" |
69 | version = "0.9.3" | 69 | version = "0.10.0" |
70 | source = "registry+https://github.com/rust-lang/crates.io-index" | 70 | source = "registry+https://github.com/rust-lang/crates.io-index" |
71 | dependencies = [ | 71 | dependencies = [ |
72 | "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", | 72 | "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", |
73 | "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
74 | ] | 73 | ] |
75 | 74 | ||
76 | [[package]] | 75 | [[package]] |
@@ -139,7 +138,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
139 | dependencies = [ | 138 | dependencies = [ |
140 | "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", | 139 | "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", |
141 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", | 140 | "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", |
142 | "time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", | 141 | "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", |
143 | ] | 142 | ] |
144 | 143 | ||
145 | [[package]] | 144 | [[package]] |
@@ -661,7 +660,7 @@ dependencies = [ | |||
661 | "ra_syntax 0.1.0", | 660 | "ra_syntax 0.1.0", |
662 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 661 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
663 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 662 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
664 | "salsa 0.9.1", | 663 | "salsa 0.9.1 (git+https://github.com/matklad/salsa?branch=panic-hooks)", |
665 | "test_utils 0.1.0", | 664 | "test_utils 0.1.0", |
666 | ] | 665 | ] |
667 | 666 | ||
@@ -680,7 +679,7 @@ dependencies = [ | |||
680 | "ra_syntax 0.1.0", | 679 | "ra_syntax 0.1.0", |
681 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 680 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
682 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 681 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
683 | "salsa 0.9.1", | 682 | "salsa 0.9.1 (git+https://github.com/matklad/salsa?branch=panic-hooks)", |
684 | "test_utils 0.1.0", | 683 | "test_utils 0.1.0", |
685 | ] | 684 | ] |
686 | 685 | ||
@@ -700,7 +699,7 @@ dependencies = [ | |||
700 | "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", | 699 | "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", |
701 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 700 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
702 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 701 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
703 | "salsa 0.9.1", | 702 | "salsa 0.9.1 (git+https://github.com/matklad/salsa?branch=panic-hooks)", |
704 | "test_utils 0.1.0", | 703 | "test_utils 0.1.0", |
705 | "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 704 | "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
706 | ] | 705 | ] |
@@ -967,10 +966,10 @@ dependencies = [ | |||
967 | 966 | ||
968 | [[package]] | 967 | [[package]] |
969 | name = "ron" | 968 | name = "ron" |
970 | version = "0.4.0" | 969 | version = "0.4.1" |
971 | source = "registry+https://github.com/rust-lang/crates.io-index" | 970 | source = "registry+https://github.com/rust-lang/crates.io-index" |
972 | dependencies = [ | 971 | dependencies = [ |
973 | "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", | 972 | "base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", |
974 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", | 973 | "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", |
975 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", | 974 | "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", |
976 | ] | 975 | ] |
@@ -1023,13 +1022,9 @@ version = "0.2.7" | |||
1023 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1022 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1024 | 1023 | ||
1025 | [[package]] | 1024 | [[package]] |
1026 | name = "safemem" | ||
1027 | version = "0.3.0" | ||
1028 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1029 | |||
1030 | [[package]] | ||
1031 | name = "salsa" | 1025 | name = "salsa" |
1032 | version = "0.9.1" | 1026 | version = "0.9.1" |
1027 | source = "git+https://github.com/matklad/salsa?branch=panic-hooks#add15d83eaa865571cd33e60b2eb611a366ca3ff" | ||
1033 | dependencies = [ | 1028 | dependencies = [ |
1034 | "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1029 | "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1035 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1030 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1206,7 +1201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1206 | dependencies = [ | 1201 | dependencies = [ |
1207 | "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1202 | "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1208 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1203 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1209 | "ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1204 | "ron 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1210 | "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", | 1205 | "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", |
1211 | ] | 1206 | ] |
1212 | 1207 | ||
@@ -1273,7 +1268,7 @@ dependencies = [ | |||
1273 | 1268 | ||
1274 | [[package]] | 1269 | [[package]] |
1275 | name = "time" | 1270 | name = "time" |
1276 | version = "0.1.41" | 1271 | version = "0.1.42" |
1277 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1272 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1278 | dependencies = [ | 1273 | dependencies = [ |
1279 | "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", | 1274 | "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1488,7 +1483,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1488 | "checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" | 1483 | "checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" |
1489 | "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" | 1484 | "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" |
1490 | "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" | 1485 | "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" |
1491 | "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" | 1486 | "checksum base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "621fc7ecb8008f86d7fb9b95356cd692ce9514b80a86d85b397f32a22da7b9e2" |
1492 | "checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a" | 1487 | "checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a" |
1493 | "checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf" | 1488 | "checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf" |
1494 | "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" | 1489 | "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" |
@@ -1578,14 +1573,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1578 | "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" | 1573 | "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" |
1579 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 1574 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
1580 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" | 1575 | "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" |
1581 | "checksum ron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c48677d8a9247a4e0d1f3f9cb4b0a8e29167fdc3c04f383a5e669cd7a960ae0f" | 1576 | "checksum ron 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d9cb28ade964585205aaca1f3d41a6297f72e1ad097b49c4bbde033ef86b38d7" |
1582 | "checksum rowan 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9ae7dba5e703f423ceb8646d636c73e6d858a2f8c834808b4565e42ccda9e2" | 1577 | "checksum rowan 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9ae7dba5e703f423ceb8646d636c73e6d858a2f8c834808b4565e42ccda9e2" |
1583 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" | 1578 | "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" |
1584 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 1579 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
1585 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1580 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
1586 | "checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" | 1581 | "checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" |
1587 | "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" | 1582 | "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" |
1588 | "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" | 1583 | "checksum salsa 0.9.1 (git+https://github.com/matklad/salsa?branch=panic-hooks)" = "<none>" |
1589 | "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" | 1584 | "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" |
1590 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" | 1585 | "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" |
1591 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 1586 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" |
@@ -1610,7 +1605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1610 | "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" | 1605 | "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" |
1611 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" | 1606 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" |
1612 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" | 1607 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" |
1613 | "checksum time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "847da467bf0db05882a9e2375934a8a55cffdc9db0d128af1518200260ba1f6c" | 1608 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" |
1614 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" | 1609 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" |
1615 | "checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77" | 1610 | "checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77" |
1616 | "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" | 1611 | "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" |
diff --git a/Cargo.toml b/Cargo.toml index 57896078e..85aaa23b9 100644 --- a/Cargo.toml +++ b/Cargo.toml | |||
@@ -7,4 +7,4 @@ debug = true | |||
7 | 7 | ||
8 | [patch.'crates-io'] | 8 | [patch.'crates-io'] |
9 | cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata.git", rev="f73e27b24e" } | 9 | cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata.git", rev="f73e27b24e" } |
10 | salsa = { path = "/home/matklad/projects/salsa" } | 10 | salsa = { git = "https://github.com/matklad/salsa", branch = "panic-hooks" } |
diff --git a/crates/ra_db/src/cancellation.rs b/crates/ra_db/src/cancellation.rs index 8d38eebfb..f7077b992 100644 --- a/crates/ra_db/src/cancellation.rs +++ b/crates/ra_db/src/cancellation.rs | |||
@@ -27,6 +27,10 @@ impl Canceled { | |||
27 | pub(crate) fn new() -> Canceled { | 27 | pub(crate) fn new() -> Canceled { |
28 | Canceled { _private: () } | 28 | Canceled { _private: () } |
29 | } | 29 | } |
30 | |||
31 | pub fn throw() -> ! { | ||
32 | std::panic::resume_unwind(Box::new(Canceled::new())) | ||
33 | } | ||
30 | } | 34 | } |
31 | 35 | ||
32 | impl std::fmt::Display for Canceled { | 36 | impl std::fmt::Display for Canceled { |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index abe6430fb..00d2d5ae9 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -20,10 +20,10 @@ pub use crate::{ | |||
20 | loc2id::LocationIntener, | 20 | loc2id::LocationIntener, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | 23 | pub trait BaseDatabase: salsa::Database { |
24 | fn check_canceled(&self) -> Cancelable<()> { | 24 | fn check_canceled(&self) -> Cancelable<()> { |
25 | self.salsa_runtime() | 25 | self.salsa_runtime() |
26 | .unwind_if_current_revision_is_canceled(); | 26 | .if_current_revision_is_canceled(Canceled::throw); |
27 | Ok(()) | 27 | Ok(()) |
28 | } | 28 | } |
29 | 29 | ||
@@ -31,8 +31,9 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | |||
31 | &self, | 31 | &self, |
32 | f: F, | 32 | f: F, |
33 | ) -> Result<T, Canceled> { | 33 | ) -> Result<T, Canceled> { |
34 | panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<salsa::Canceled>() { | 34 | let me = panic::AssertUnwindSafe(self); |
35 | Ok(_) => Canceled::new(), | 35 | panic::catch_unwind(|| f(me.0)).map_err(|err| match err.downcast::<Canceled>() { |
36 | Ok(canceled) => *canceled, | ||
36 | Err(payload) => panic::resume_unwind(payload), | 37 | Err(payload) => panic::resume_unwind(payload), |
37 | }) | 38 | }) |
38 | } | 39 | } |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 9d46609ec..a2e06f5db 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::{fmt, sync::Arc}; | 1 | use std::{fmt, sync::Arc}; |
2 | 2 | ||
3 | use salsa::{self, Database}; | 3 | use salsa::{self, Database}; |
4 | use ra_db::{LocationIntener, BaseDatabase, FileId}; | 4 | use ra_db::{LocationIntener, BaseDatabase, FileId, Canceled}; |
5 | 5 | ||
6 | use crate::{symbol_index, LineIndex}; | 6 | use crate::{symbol_index, LineIndex}; |
7 | 7 | ||
@@ -29,6 +29,9 @@ impl salsa::Database for RootDatabase { | |||
29 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { | 29 | fn salsa_runtime(&self) -> &salsa::Runtime<RootDatabase> { |
30 | &self.runtime | 30 | &self.runtime |
31 | } | 31 | } |
32 | fn on_propagated_panic(&self) -> ! { | ||
33 | Canceled::throw() | ||
34 | } | ||
32 | } | 35 | } |
33 | 36 | ||
34 | impl Default for RootDatabase { | 37 | impl Default for RootDatabase { |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index fbe1421a4..f505959ce 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -35,7 +35,7 @@ use std::{fmt, sync::Arc}; | |||
35 | 35 | ||
36 | use ra_syntax::{SmolStr, SourceFile, TreePtr, SyntaxKind, TextRange, TextUnit}; | 36 | use ra_syntax::{SmolStr, SourceFile, TreePtr, SyntaxKind, TextRange, TextUnit}; |
37 | use ra_text_edit::TextEdit; | 37 | use ra_text_edit::TextEdit; |
38 | use ra_db::{SyntaxDatabase, FilesDatabase, LocalSyntaxPtr}; | 38 | use ra_db::{SyntaxDatabase, FilesDatabase, LocalSyntaxPtr, BaseDatabase}; |
39 | use rayon::prelude::*; | 39 | use rayon::prelude::*; |
40 | use relative_path::RelativePathBuf; | 40 | use relative_path::RelativePathBuf; |
41 | use rustc_hash::FxHashMap; | 41 | use rustc_hash::FxHashMap; |
@@ -420,43 +420,47 @@ impl Analysis { | |||
420 | 420 | ||
421 | /// Fuzzy searches for a symbol. | 421 | /// Fuzzy searches for a symbol. |
422 | pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> { | 422 | pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> { |
423 | let res = symbol_index::world_symbols(&*self.db, query)? | 423 | self.with_db(|db| { |
424 | .into_iter() | 424 | let res = symbol_index::world_symbols(db, query)? |
425 | .map(NavigationTarget::from_symbol) | 425 | .into_iter() |
426 | .collect(); | 426 | .map(NavigationTarget::from_symbol) |
427 | Ok(res) | 427 | .collect::<Vec<_>>(); |
428 | Ok(res) | ||
429 | })? | ||
428 | } | 430 | } |
429 | 431 | ||
430 | pub fn goto_definition( | 432 | pub fn goto_definition( |
431 | &self, | 433 | &self, |
432 | position: FilePosition, | 434 | position: FilePosition, |
433 | ) -> Cancelable<Option<Vec<NavigationTarget>>> { | 435 | ) -> Cancelable<Option<Vec<NavigationTarget>>> { |
434 | goto_definition::goto_definition(&*self.db, position) | 436 | self.db |
437 | .catch_canceled(|db| goto_definition::goto_definition(db, position))? | ||
435 | } | 438 | } |
436 | 439 | ||
437 | /// Finds all usages of the reference at point. | 440 | /// Finds all usages of the reference at point. |
438 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { | 441 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |
439 | self.db.find_all_refs(position) | 442 | self.with_db(|db| db.find_all_refs(position))? |
440 | } | 443 | } |
441 | 444 | ||
442 | /// Returns a short text descrbing element at position. | 445 | /// Returns a short text descrbing element at position. |
443 | pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> { | 446 | pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> { |
444 | hover::hover(&*self.db, position) | 447 | self.with_db(|db| hover::hover(db, position))? |
445 | } | 448 | } |
446 | 449 | ||
447 | /// Computes parameter information for the given call expression. | 450 | /// Computes parameter information for the given call expression. |
448 | pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { | 451 | pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { |
449 | call_info::call_info(&*self.db, position) | 452 | self.db |
453 | .catch_canceled(|db| call_info::call_info(db, position))? | ||
450 | } | 454 | } |
451 | 455 | ||
452 | /// Returns a `mod name;` declaration which created the current module. | 456 | /// Returns a `mod name;` declaration which created the current module. |
453 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> { | 457 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> { |
454 | self.db.parent_module(position) | 458 | self.with_db(|db| db.parent_module(position))? |
455 | } | 459 | } |
456 | 460 | ||
457 | /// Returns crates this file belongs too. | 461 | /// Returns crates this file belongs too. |
458 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { | 462 | pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { |
459 | self.db.crate_for(file_id) | 463 | self.with_db(|db| db.crate_for(file_id))? |
460 | } | 464 | } |
461 | 465 | ||
462 | /// Returns the root file of the given crate. | 466 | /// Returns the root file of the given crate. |
@@ -466,17 +470,21 @@ impl Analysis { | |||
466 | 470 | ||
467 | /// Returns the set of possible targets to run for the current file. | 471 | /// Returns the set of possible targets to run for the current file. |
468 | pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { | 472 | pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { |
469 | runnables::runnables(&*self.db, file_id) | 473 | self.db |
474 | .catch_canceled(|db| runnables::runnables(db, file_id))? | ||
470 | } | 475 | } |
471 | 476 | ||
472 | /// Computes syntax highlighting for the given file. | 477 | /// Computes syntax highlighting for the given file. |
473 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { | 478 | pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { |
474 | syntax_highlighting::highlight(&*self.db, file_id) | 479 | self.db |
480 | .catch_canceled(|db| syntax_highlighting::highlight(db, file_id))? | ||
475 | } | 481 | } |
476 | 482 | ||
477 | /// Computes completions at the given position. | 483 | /// Computes completions at the given position. |
478 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { | 484 | pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { |
479 | let completions = completion::completions(&self.db, position)?; | 485 | let completions = self |
486 | .db | ||
487 | .catch_canceled(|db| completion::completions(db, position))??; | ||
480 | Ok(completions.map(|it| it.into())) | 488 | Ok(completions.map(|it| it.into())) |
481 | } | 489 | } |
482 | 490 | ||
@@ -488,12 +496,12 @@ impl Analysis { | |||
488 | 496 | ||
489 | /// Computes the set of diagnostics for the given file. | 497 | /// Computes the set of diagnostics for the given file. |
490 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { | 498 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { |
491 | self.db.diagnostics(file_id) | 499 | self.with_db(|db| db.diagnostics(file_id))? |
492 | } | 500 | } |
493 | 501 | ||
494 | /// Computes the type of the expression at the given position. | 502 | /// Computes the type of the expression at the given position. |
495 | pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { | 503 | pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { |
496 | hover::type_of(&*self.db, frange) | 504 | self.with_db(|db| hover::type_of(db, frange))? |
497 | } | 505 | } |
498 | 506 | ||
499 | /// Returns the edit required to rename reference at the position to the new | 507 | /// Returns the edit required to rename reference at the position to the new |
@@ -503,7 +511,14 @@ impl Analysis { | |||
503 | position: FilePosition, | 511 | position: FilePosition, |
504 | new_name: &str, | 512 | new_name: &str, |
505 | ) -> Cancelable<Vec<SourceFileEdit>> { | 513 | ) -> Cancelable<Vec<SourceFileEdit>> { |
506 | self.db.rename(position, new_name) | 514 | self.with_db(|db| db.rename(position, new_name))? |
515 | } | ||
516 | |||
517 | fn with_db<F: FnOnce(&db::RootDatabase) -> T + std::panic::UnwindSafe, T>( | ||
518 | &self, | ||
519 | f: F, | ||
520 | ) -> Cancelable<T> { | ||
521 | self.db.catch_canceled(f) | ||
507 | } | 522 | } |
508 | } | 523 | } |
509 | 524 | ||