mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
minor
This commit is contained in:
parent
949a6ec469
commit
24262f9ff6
3 changed files with 34 additions and 44 deletions
|
@ -251,16 +251,6 @@ pub(crate) fn diagnostics(
|
||||||
res
|
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>(
|
fn warning_with_fix<D: DiagnosticWithFixes>(
|
||||||
d: &D,
|
d: &D,
|
||||||
sema: &Semantics<RootDatabase>,
|
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]
|
#[test]
|
||||||
fn test_check_unnecessary_braces_in_use_statement() {
|
fn test_check_unnecessary_braces_in_use_statement() {
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
|
|
|
@ -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]
|
#[test]
|
||||||
fn test_fill_struct_fields_empty() {
|
fn test_fill_struct_fields_empty() {
|
||||||
check_fix(
|
check_fix(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use hir::{db::AstDatabase, Semantics};
|
use hir::db::AstDatabase;
|
||||||
use ide_assists::Assist;
|
use ide_assists::Assist;
|
||||||
use ide_db::source_change::SourceChange;
|
use ide_db::source_change::SourceChange;
|
||||||
use syntax::AstNode;
|
use syntax::AstNode;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue