mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-18 03:13:31 +00:00
Add missing #[rust_analyzer::rust_fixture] annotations
This commit is contained in:
parent
9c7d8bbdc0
commit
3e2848dc59
10 changed files with 104 additions and 35 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue