Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/tests.rs')
-rw-r--r--crates/ide-diagnostics/src/tests.rs39
1 files changed, 29 insertions, 10 deletions
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index 605a6f69fc..fc2a7db717 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -18,7 +18,10 @@ use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
/// * the first diagnostic fix trigger range touches the input cursor position
/// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied
#[track_caller]
-pub(crate) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
check_nth_fix(0, ra_fixture_before, ra_fixture_after);
}
/// Takes a multi-file input fixture with annotated cursor positions,
@@ -26,14 +29,21 @@ pub(crate) fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
/// * a diagnostic is produced
/// * every diagnostic fixes trigger range touches the input cursor position
/// * that the contents of the file containing the cursor match `after` after each diagnostic fix is applied
-pub(crate) fn check_fixes(ra_fixture_before: &str, ra_fixtures_after: Vec<&str>) {
+pub(crate) fn check_fixes(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ ra_fixtures_after: Vec<&str>,
+) {
for (i, ra_fixture_after) in ra_fixtures_after.iter().enumerate() {
check_nth_fix(i, ra_fixture_before, ra_fixture_after)
}
}
#[track_caller]
-fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
+fn check_nth_fix(
+ nth: usize,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let mut config = DiagnosticsConfig::test_sample();
config.expr_fill_default = ExprFillDefaultMode::Default;
check_nth_fix_with_config(config, nth, ra_fixture_before, ra_fixture_after)
@@ -41,8 +51,8 @@ fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
#[track_caller]
pub(crate) fn check_fix_with_disabled(
- ra_fixture_before: &str,
- ra_fixture_after: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
disabled: impl Iterator<Item = String>,
) {
let mut config = DiagnosticsConfig::test_sample();
@@ -55,8 +65,8 @@ pub(crate) fn check_fix_with_disabled(
fn check_nth_fix_with_config(
config: DiagnosticsConfig,
nth: usize,
- ra_fixture_before: &str,
- ra_fixture_after: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
) {
let after = trim_indent(ra_fixture_after);
@@ -95,14 +105,20 @@ fn check_nth_fix_with_config(
assert_eq_text!(&after, &actual);
}
-pub(crate) fn check_fixes_unordered(ra_fixture_before: &str, ra_fixtures_after: Vec<&str>) {
+pub(crate) fn check_fixes_unordered(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ ra_fixtures_after: Vec<&str>,
+) {
for ra_fixture_after in ra_fixtures_after.iter() {
check_has_fix(ra_fixture_before, ra_fixture_after)
}
}
#[track_caller]
-pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_has_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let after = trim_indent(ra_fixture_after);
let (db, file_position) = RootDatabase::with_position(ra_fixture_before);
@@ -145,7 +161,10 @@ pub(crate) fn check_has_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
}
#[track_caller]
-pub(crate) fn check_has_single_fix(ra_fixture_before: &str, ra_fixture_after: &str) {
+pub(crate) fn check_has_single_fix(
+ #[rust_analyzer::rust_fixture] ra_fixture_before: &str,
+ #[rust_analyzer::rust_fixture] ra_fixture_after: &str,
+) {
let after = trim_indent(ra_fixture_after);
let (db, file_position) = RootDatabase::with_position(ra_fixture_before);