This commit is contained in:
Aleksey Kladov 2021-06-13 20:20:58 +03:00
parent 949a6ec469
commit 24262f9ff6
3 changed files with 34 additions and 44 deletions

View File

@ -251,16 +251,6 @@ pub(crate) fn diagnostics(
res
}
fn diagnostic_with_fix<D: DiagnosticWithFixes>(
d: &D,
sema: &Semantics<RootDatabase>,
resolve: &AssistResolveStrategy,
) -> Diagnostic {
Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message())
.with_fixes(d.fixes(sema, resolve))
.with_code(Some(d.code()))
}
fn warning_with_fix<D: DiagnosticWithFixes>(
d: &D,
sema: &Semantics<RootDatabase>,
@ -446,39 +436,6 @@ mod tests {
}
}
#[test]
fn range_mapping_out_of_macros() {
// FIXME: this is very wrong, but somewhat tricky to fix.
check_fix(
r#"
fn some() {}
fn items() {}
fn here() {}
macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
fn main() {
let _x = id![Foo { a: $042 }];
}
pub struct Foo { pub a: i32, pub b: i32 }
"#,
r#"
fn some(, b: () ) {}
fn items() {}
fn here() {}
macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
fn main() {
let _x = id![Foo { a: 42 }];
}
pub struct Foo { pub a: i32, pub b: i32 }
"#,
);
}
#[test]
fn test_check_unnecessary_braces_in_use_statement() {
check_diagnostics(

View File

@ -93,6 +93,39 @@ fn baz(s: S) {
);
}
#[test]
fn range_mapping_out_of_macros() {
// FIXME: this is very wrong, but somewhat tricky to fix.
check_fix(
r#"
fn some() {}
fn items() {}
fn here() {}
macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
fn main() {
let _x = id![Foo { a: $042 }];
}
pub struct Foo { pub a: i32, pub b: i32 }
"#,
r#"
fn some(, b: () ) {}
fn items() {}
fn here() {}
macro_rules! id { ($($tt:tt)*) => { $($tt)*}; }
fn main() {
let _x = id![Foo { a: 42 }];
}
pub struct Foo { pub a: i32, pub b: i32 }
"#,
);
}
#[test]
fn test_fill_struct_fields_empty() {
check_fix(

View File

@ -1,4 +1,4 @@
use hir::{db::AstDatabase, Semantics};
use hir::db::AstDatabase;
use ide_assists::Assist;
use ide_db::source_change::SourceChange;
use syntax::AstNode;