diff options
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/helpers.rs | 11 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/famous_defs_fixture.rs | 59 |
2 files changed, 9 insertions, 61 deletions
diff --git a/crates/ide_db/src/helpers.rs b/crates/ide_db/src/helpers.rs index 00900cdc2..d96028cbc 100644 --- a/crates/ide_db/src/helpers.rs +++ b/crates/ide_db/src/helpers.rs | |||
@@ -74,12 +74,19 @@ pub fn visit_file_defs( | |||
74 | /// somewhat similar to the known paths infra inside hir, but it different; We | 74 | /// somewhat similar to the known paths infra inside hir, but it different; We |
75 | /// want to make sure that IDE specific paths don't become interesting inside | 75 | /// want to make sure that IDE specific paths don't become interesting inside |
76 | /// the compiler itself as well. | 76 | /// the compiler itself as well. |
77 | /// | ||
78 | /// Note that, by default, rust-analyzer tests **do not** include core or std | ||
79 | /// libraries. If you are writing tests for functionality using [`FamousDefs`], | ||
80 | /// you'd want to include [minicore](test_utils::MiniCore) declaration at the | ||
81 | /// start of your tests: | ||
82 | /// | ||
83 | /// ``` | ||
84 | /// //- minicore: iterator, ord, derive | ||
85 | /// ``` | ||
77 | pub struct FamousDefs<'a, 'b>(pub &'a Semantics<'b, RootDatabase>, pub Option<Crate>); | 86 | pub struct FamousDefs<'a, 'b>(pub &'a Semantics<'b, RootDatabase>, pub Option<Crate>); |
78 | 87 | ||
79 | #[allow(non_snake_case)] | 88 | #[allow(non_snake_case)] |
80 | impl FamousDefs<'_, '_> { | 89 | impl FamousDefs<'_, '_> { |
81 | pub const FIXTURE: &'static str = include_str!("helpers/famous_defs_fixture.rs"); | ||
82 | |||
83 | pub fn std(&self) -> Option<Crate> { | 90 | pub fn std(&self) -> Option<Crate> { |
84 | self.find_crate("std") | 91 | self.find_crate("std") |
85 | } | 92 | } |
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs deleted file mode 100644 index 551203936..000000000 --- a/crates/ide_db/src/helpers/famous_defs_fixture.rs +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | //- /libcore.rs crate:core | ||
2 | //! Signatures of traits, types and functions from the core lib for use in tests. | ||
3 | pub mod cmp { | ||
4 | |||
5 | pub trait Ord { | ||
6 | fn cmp(&self, other: &Self) -> Ordering; | ||
7 | fn max(self, other: Self) -> Self; | ||
8 | fn min(self, other: Self) -> Self; | ||
9 | fn clamp(self, min: Self, max: Self) -> Self; | ||
10 | } | ||
11 | } | ||
12 | |||
13 | pub mod convert { | ||
14 | pub trait From<T> { | ||
15 | fn from(t: T) -> Self; | ||
16 | } | ||
17 | |||
18 | pub trait Into<T> { | ||
19 | pub fn into(self) -> T; | ||
20 | } | ||
21 | } | ||
22 | |||
23 | pub mod default { | ||
24 | pub trait Default { | ||
25 | fn default() -> Self; | ||
26 | } | ||
27 | } | ||
28 | |||
29 | pub mod option { | ||
30 | pub enum Option<T> { | ||
31 | None, | ||
32 | Some(T), | ||
33 | } | ||
34 | } | ||
35 | |||
36 | pub mod prelude { | ||
37 | pub mod rust_2018 { | ||
38 | pub use crate::{ | ||
39 | cmp::Ord, | ||
40 | convert::{From, Into}, | ||
41 | default::Default, | ||
42 | iter::{IntoIterator, Iterator}, | ||
43 | ops::{Fn, FnMut, FnOnce}, | ||
44 | option::Option::{self, *}, | ||
45 | }; | ||
46 | } | ||
47 | } | ||
48 | #[prelude_import] | ||
49 | pub use prelude::rust_2018::*; | ||
50 | //- /libstd.rs crate:std deps:core | ||
51 | //! Signatures of traits, types and functions from the std lib for use in tests. | ||
52 | |||
53 | /// Docs for return_keyword | ||
54 | mod return_keyword {} | ||
55 | |||
56 | /// Docs for prim_str | ||
57 | mod prim_str {} | ||
58 | |||
59 | pub use core::ops; | ||