]> git.lizzy.rs Git - rust.git/commitdiff
Move FamousDefs fixture out into its own file
authorLukas Wirth <lukastw97@gmail.com>
Tue, 12 Jan 2021 16:26:08 +0000 (17:26 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Tue, 12 Jan 2021 16:26:08 +0000 (17:26 +0100)
crates/ide_db/src/helpers.rs
crates/ide_db/src/helpers/famous_defs_fixture.rs [new file with mode: 0644]

index e3e5670f180bc37d15f696a290a3199cb9de3663..c6763ae369e57e41957e1ef6a967f4f4be247d05 100644 (file)
@@ -38,94 +38,7 @@ pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path {
 
 #[allow(non_snake_case)]
 impl FamousDefs<'_, '_> {
-    pub const FIXTURE: &'static str = r#"//- /libcore.rs crate:core
-pub mod convert {
-    pub trait From<T> {
-        fn from(t: T) -> Self;
-    }
-}
-
-pub mod default {
-    pub trait Default {
-       fn default() -> Self;
-    }
-}
-
-pub mod iter {
-    pub use self::traits::{collect::IntoIterator, iterator::Iterator};
-    mod traits {
-        pub(crate) mod iterator {
-            use crate::option::Option;
-            pub trait Iterator {
-                type Item;
-                fn next(&mut self) -> Option<Self::Item>;
-                fn by_ref(&mut self) -> &mut Self {
-                    self
-                }
-                fn take(self, n: usize) -> crate::iter::Take<Self> {
-                    crate::iter::Take { inner: self }
-                }
-            }
-
-            impl<I: Iterator> Iterator for &mut I {
-                type Item = I::Item;
-                fn next(&mut self) -> Option<I::Item> {
-                    (**self).next()
-                }
-            }
-        }
-        pub(crate) mod collect {
-            pub trait IntoIterator {
-                type Item;
-            }
-        }
-    }
-
-    pub use self::sources::*;
-    pub(crate) mod sources {
-        use super::Iterator;
-        use crate::option::Option::{self, *};
-        pub struct Repeat<A> {
-            element: A,
-        }
-
-        pub fn repeat<T>(elt: T) -> Repeat<T> {
-            Repeat { element: elt }
-        }
-
-        impl<A> Iterator for Repeat<A> {
-            type Item = A;
-
-            fn next(&mut self) -> Option<A> {
-                None
-            }
-        }
-    }
-
-    pub use self::adapters::*;
-    pub(crate) mod adapters {
-        use super::Iterator;
-        use crate::option::Option::{self, *};
-        pub struct Take<I> { pub(crate) inner: I }
-        impl<I> Iterator for Take<I> where I: Iterator {
-            type Item = <I as Iterator>::Item;
-            fn next(&mut self) -> Option<<I as Iterator>::Item> {
-                None
-            }
-        }
-    }
-}
-
-pub mod option {
-    pub enum Option<T> { None, Some(T)}
-}
-
-pub mod prelude {
-    pub use crate::{convert::From, iter::{IntoIterator, Iterator}, option::Option::{self, *}, default::Default};
-}
-#[prelude_import]
-pub use prelude::*;
-"#;
+    pub const FIXTURE: &'static str = include_str!("helpers/famous_defs_fixture.rs");
 
     pub fn core(&self) -> Option<Crate> {
         self.find_crate("core")
diff --git a/crates/ide_db/src/helpers/famous_defs_fixture.rs b/crates/ide_db/src/helpers/famous_defs_fixture.rs
new file mode 100644 (file)
index 0000000..f3d3558
--- /dev/null
@@ -0,0 +1,119 @@
+//- /libcore.rs crate:core
+pub mod convert {
+    pub trait From<T> {
+        fn from(t: T) -> Self;
+    }
+}
+
+pub mod default {
+    pub trait Default {
+        fn default() -> Self;
+    }
+}
+
+pub mod iter {
+    pub use self::traits::{collect::IntoIterator, iterator::Iterator};
+    mod traits {
+        pub(crate) mod iterator {
+            use crate::option::Option;
+            pub trait Iterator {
+                type Item;
+                fn next(&mut self) -> Option<Self::Item>;
+                fn by_ref(&mut self) -> &mut Self {
+                    self
+                }
+                fn take(self, n: usize) -> crate::iter::Take<Self> {
+                    crate::iter::Take { inner: self }
+                }
+            }
+
+            impl<I: Iterator> Iterator for &mut I {
+                type Item = I::Item;
+                fn next(&mut self) -> Option<I::Item> {
+                    (**self).next()
+                }
+            }
+        }
+        pub(crate) mod collect {
+            pub trait IntoIterator {
+                type Item;
+            }
+        }
+    }
+
+    pub use self::sources::*;
+    pub(crate) mod sources {
+        use super::Iterator;
+        use crate::option::Option::{self, *};
+        pub struct Repeat<A> {
+            element: A,
+        }
+
+        pub fn repeat<T>(elt: T) -> Repeat<T> {
+            Repeat { element: elt }
+        }
+
+        impl<A> Iterator for Repeat<A> {
+            type Item = A;
+
+            fn next(&mut self) -> Option<A> {
+                None
+            }
+        }
+    }
+
+    pub use self::adapters::*;
+    pub(crate) mod adapters {
+        use super::Iterator;
+        use crate::option::Option::{self, *};
+        pub struct Take<I> {
+            pub(crate) inner: I,
+        }
+        impl<I> Iterator for Take<I>
+        where
+            I: Iterator,
+        {
+            type Item = <I as Iterator>::Item;
+            fn next(&mut self) -> Option<<I as Iterator>::Item> {
+                None
+            }
+        }
+    }
+}
+
+pub mod ops {
+    #[lang = "fn"]
+    pub trait Fn<Args>: FnMut<Args> {
+        extern "rust-call" fn call(&self, args: Args) -> Self::Output;
+    }
+
+    #[lang = "fn_mut"]
+    pub trait FnMut<Args>: FnOnce<Args> {
+        extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
+    }
+    #[lang = "fn_once"]
+    pub trait FnOnce<Args> {
+        #[lang = "fn_once_output"]
+        type Output;
+        extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+    }
+}
+
+pub mod option {
+    pub enum Option<T> {
+        None,
+        Some(T),
+    }
+}
+
+pub mod prelude {
+    pub use crate::{
+        convert::From,
+        default::Default,
+        iter::{IntoIterator, Iterator},
+        ops::{Fn, FnMut, FnOnce},
+        option::Option::{self, *},
+    };
+}
+#[prelude_import]
+pub use prelude::*;