diff options
Diffstat (limited to 'crates/base_db/src')
-rw-r--r-- | crates/base_db/src/fixture.rs | 60 | ||||
-rw-r--r-- | crates/base_db/src/lib.rs | 3 |
2 files changed, 4 insertions, 59 deletions
diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs index 8d4641355..04e2be390 100644 --- a/crates/base_db/src/fixture.rs +++ b/crates/base_db/src/fixture.rs | |||
@@ -1,62 +1,4 @@ | |||
1 | //! Fixtures are strings containing rust source code with optional metadata. | 1 | //! A set of high-level utility fixture methods to use in tests. |
2 | //! A fixture without metadata is parsed into a single source file. | ||
3 | //! Use this to test functionality local to one file. | ||
4 | //! | ||
5 | //! Simple Example: | ||
6 | //! ``` | ||
7 | //! r#" | ||
8 | //! fn main() { | ||
9 | //! println!("Hello World") | ||
10 | //! } | ||
11 | //! "# | ||
12 | //! ``` | ||
13 | //! | ||
14 | //! Metadata can be added to a fixture after a `//-` comment. | ||
15 | //! The basic form is specifying filenames, | ||
16 | //! which is also how to define multiple files in a single test fixture | ||
17 | //! | ||
18 | //! Example using two files in the same crate: | ||
19 | //! ``` | ||
20 | //! " | ||
21 | //! //- /main.rs | ||
22 | //! mod foo; | ||
23 | //! fn main() { | ||
24 | //! foo::bar(); | ||
25 | //! } | ||
26 | //! | ||
27 | //! //- /foo.rs | ||
28 | //! pub fn bar() {} | ||
29 | //! " | ||
30 | //! ``` | ||
31 | //! | ||
32 | //! Example using two crates with one file each, with one crate depending on the other: | ||
33 | //! ``` | ||
34 | //! r#" | ||
35 | //! //- /main.rs crate:a deps:b | ||
36 | //! fn main() { | ||
37 | //! b::foo(); | ||
38 | //! } | ||
39 | //! //- /lib.rs crate:b | ||
40 | //! pub fn b() { | ||
41 | //! println!("Hello World") | ||
42 | //! } | ||
43 | //! "# | ||
44 | //! ``` | ||
45 | //! | ||
46 | //! Metadata allows specifying all settings and variables | ||
47 | //! that are available in a real rust project: | ||
48 | //! - crate names via `crate:cratename` | ||
49 | //! - dependencies via `deps:dep1,dep2` | ||
50 | //! - configuration settings via `cfg:dbg=false,opt_level=2` | ||
51 | //! - environment variables via `env:PATH=/bin,RUST_LOG=debug` | ||
52 | //! | ||
53 | //! Example using all available metadata: | ||
54 | //! ``` | ||
55 | //! " | ||
56 | //! //- /lib.rs crate:foo deps:bar,baz cfg:foo=a,bar=b env:OUTDIR=path/to,OTHER=foo | ||
57 | //! fn insert_source_code_here() {} | ||
58 | //! " | ||
59 | //! ``` | ||
60 | use std::{mem, str::FromStr, sync::Arc}; | 2 | use std::{mem, str::FromStr, sync::Arc}; |
61 | 3 | ||
62 | use cfg::CfgOptions; | 4 | use cfg::CfgOptions; |
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 5f77a0b1f..980a0ed98 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -59,6 +59,8 @@ pub trait CheckCanceled { | |||
59 | Self: Sized + panic::RefUnwindSafe, | 59 | Self: Sized + panic::RefUnwindSafe, |
60 | F: FnOnce(&Self) -> T + panic::UnwindSafe, | 60 | F: FnOnce(&Self) -> T + panic::UnwindSafe, |
61 | { | 61 | { |
62 | // Uncomment to debug missing cancellations. | ||
63 | // let _span = profile::heartbeat_span(); | ||
62 | panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() { | 64 | panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() { |
63 | Ok(canceled) => *canceled, | 65 | Ok(canceled) => *canceled, |
64 | Err(payload) => panic::resume_unwind(payload), | 66 | Err(payload) => panic::resume_unwind(payload), |
@@ -68,6 +70,7 @@ pub trait CheckCanceled { | |||
68 | 70 | ||
69 | impl<T: salsa::Database> CheckCanceled for T { | 71 | impl<T: salsa::Database> CheckCanceled for T { |
70 | fn check_canceled(&self) { | 72 | fn check_canceled(&self) { |
73 | // profile::heartbeat(); | ||
71 | if self.salsa_runtime().is_current_revision_canceled() { | 74 | if self.salsa_runtime().is_current_revision_canceled() { |
72 | Canceled::throw() | 75 | Canceled::throw() |
73 | } | 76 | } |