Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs39
1 files changed, 35 insertions, 4 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 8198701d68..4e84127c29 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -1,13 +1,13 @@
use std::time::Instant;
use expect_test::{ExpectFile, expect_file};
-use ide_db::SymbolKind;
+use ide_db::{MiniCore, SymbolKind};
use span::Edition;
use test_utils::{AssertLinear, bench, bench_fixture, skip_slow_tests};
use crate::{FileRange, HighlightConfig, HlTag, TextRange, fixture};
-const HL_CONFIG: HighlightConfig = HighlightConfig {
+const HL_CONFIG: HighlightConfig<'_> = HighlightConfig {
strings: true,
comments: true,
punctuation: true,
@@ -17,6 +17,7 @@ const HL_CONFIG: HighlightConfig = HighlightConfig {
inject_doc_comment: true,
macro_bang: true,
syntactic_name_ref_highlighting: false,
+ minicore: MiniCore::default(),
};
#[test]
@@ -1017,6 +1018,35 @@ impl t for foo {
}
#[test]
+fn test_injection_2() {
+ check_highlighting(
+ r##"
+fn fixture(#[rust_analyzer::rust_fixture] ra_fixture: &str) {}
+
+fn main() {
+ fixture(r#"
+@@- /main.rs crate:main deps:other_crate
+fn test() {
+ let x = other_crate::foo::S::thing();
+ x;
+} //^ i128
+
+@@- /lib.rs crate:other_crate
+pub mod foo {
+ pub struct S;
+ impl S {
+ pub fn thing() -> i128 { 0 }
+ }
+}
+ "#);
+}
+"##,
+ expect_file!["./test_data/highlight_injection_2.html"],
+ false,
+ );
+}
+
+#[test]
fn test_injection() {
check_highlighting(
r##"
@@ -1024,7 +1054,8 @@ fn fixture(#[rust_analyzer::rust_fixture] ra_fixture: &str) {}
fn main() {
fixture(r#"
-trait Foo {
+@@- minicore: sized
+trait Foo: Sized {
fn foo() {
println!("2 + 2 = {}", 4);
}
@@ -1223,7 +1254,7 @@ fn foo(x: &fn(&dyn Trait)) {}
/// Note that the `snapshot` file is overwritten by the rendered HTML.
fn check_highlighting_with_config(
#[rust_analyzer::rust_fixture] ra_fixture: &str,
- config: HighlightConfig,
+ config: HighlightConfig<'_>,
expect: ExpectFile,
rainbow: bool,
) {