This is now done declaratively via `minicore`.
use crate::fixture;
- use super::*;
-
fn check_hover_no_result(ra_fixture: &str) {
let (analysis, position) = fixture::position(ra_fixture);
assert!(analysis.hover(position, true, true).unwrap().is_none());
#[test]
fn hover_keyword() {
- let ra_fixture = r#"//- /main.rs crate:main deps:std
-fn f() { retur$0n; }"#;
- let fixture = format!("{}\n{}", ra_fixture, FamousDefs::FIXTURE);
check(
- &fixture,
+ r#"
+//- /main.rs crate:main deps:std
+fn f() { retur$0n; }
+//- /libstd.rs crate:std
+/// Docs for return_keyword
+mod return_keyword {}
+"#,
expect![[r#"
*return*
#[test]
fn hover_builtin() {
- let ra_fixture = r#"//- /main.rs crate:main deps:std
-cosnt _: &str$0 = ""; }"#;
- let fixture = format!("{}\n{}", ra_fixture, FamousDefs::FIXTURE);
check(
- &fixture,
+ r#"
+//- /main.rs crate:main deps:std
+cosnt _: &str$0 = ""; }
+
+//- /libstd.rs crate:std
+/// Docs for prim_str
+mod prim_str {}
+"#,
expect![[r#"
*str*
/// somewhat similar to the known paths infra inside hir, but it different; We
/// want to make sure that IDE specific paths don't become interesting inside
/// the compiler itself as well.
+///
+/// Note that, by default, rust-analyzer tests **do not** include core or std
+/// libraries. If you are writing tests for functionality using [`FamousDefs`],
+/// you'd want to include [minicore](test_utils::MiniCore) declaration at the
+/// start of your tests:
+///
+/// ```
+/// //- minicore: iterator, ord, derive
+/// ```
pub struct FamousDefs<'a, 'b>(pub &'a Semantics<'b, RootDatabase>, pub Option<Crate>);
#[allow(non_snake_case)]
impl FamousDefs<'_, '_> {
- pub const FIXTURE: &'static str = include_str!("helpers/famous_defs_fixture.rs");
-
pub fn std(&self) -> Option<Crate> {
self.find_crate("std")
}
+++ /dev/null
-//- /libcore.rs crate:core
-//! Signatures of traits, types and functions from the core lib for use in tests.
-pub mod prelude {
- pub mod rust_2018 {
- pub use crate::{
- cmp::Ord,
- convert::{From, Into},
- default::Default,
- iter::{IntoIterator, Iterator},
- ops::{Fn, FnMut, FnOnce},
- option::Option::{self, *},
- };
- }
-}
-#[prelude_import]
-pub use prelude::rust_2018::*;
-//- /libstd.rs crate:std deps:core
-//! Signatures of traits, types and functions from the std lib for use in tests.
-
-/// Docs for return_keyword
-mod return_keyword {}
-
-/// Docs for prim_str
-mod prim_str {}
-
-pub use core::ops;