From 2a6c246184536761971b5338d5638e4bfff6ce64 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 6 Dec 2020 01:39:52 +0100 Subject: Update expect tests --- .../diagnostics/test_data/clippy_pass_by_ref.txt | 164 +++++++++++ .../diagnostics/test_data/macro_compiler_error.txt | 60 ++-- .../test_data/rustc_unused_variable.txt | 138 +++++++++- .../test_data/rustc_unused_variable_as_hint.txt | 138 +++++++++- .../test_data/rustc_unused_variable_as_info.txt | 138 +++++++++- .../test_data/rustc_wrong_number_of_parameters.txt | 82 ++++++ .../diagnostics/test_data/snap_multi_line_fix.txt | 303 +++++++++++++++++++++ 7 files changed, 977 insertions(+), 46 deletions(-) diff --git a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt index 72f6c5725..7576097b3 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt @@ -104,4 +104,168 @@ }, fixes: [], }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/lib.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 0, + character: 8, + }, + end: Position { + line: 0, + character: 19, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "trivially_copy_pass_by_ref", + ), + ), + code_description: Some( + CodeDescription { + href: Url { + scheme: "https", + host: Some( + Domain( + "rust-lang.github.io", + ), + ), + port: None, + path: "/rust-clippy/master/index.html", + query: None, + fragment: Some( + "trivially_copy_pass_by_ref", + ), + }, + }, + ), + source: Some( + "clippy", + ), + message: "lint level defined here", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/mir/tagset.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 41, + character: 23, + }, + end: Position { + line: 41, + character: 28, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [], + }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/mir/tagset.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 41, + character: 23, + }, + end: Position { + line: 41, + character: 28, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "trivially_copy_pass_by_ref", + ), + ), + code_description: Some( + CodeDescription { + href: Url { + scheme: "https", + host: Some( + Domain( + "rust-lang.github.io", + ), + ), + port: None, + path: "/rust-clippy/master/index.html", + query: None, + fragment: Some( + "trivially_copy_pass_by_ref", + ), + }, + }, + ), + source: Some( + "clippy", + ), + message: "consider passing by value instead", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/mir/tagset.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 41, + character: 23, + }, + end: Position { + line: 41, + character: 28, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [], + }, ] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt index bbec6a796..8f8953cd2 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt @@ -4,19 +4,19 @@ scheme: "file", host: None, port: None, - path: "/test/crates/hir_def/src/data.rs", + path: "/test/crates/hir_def/src/path.rs", query: None, fragment: None, }, diagnostic: Diagnostic { range: Range { start: Position { - line: 79, - character: 15, + line: 264, + character: 8, }, end: Position { - line: 79, - character: 41, + line: 264, + character: 76, }, }, severity: Some( @@ -36,22 +36,22 @@ scheme: "file", host: None, port: None, - path: "/test/crates/hir_def/src/path.rs", + path: "/test/crates/hir_def/src/data.rs", query: None, fragment: None, }, range: Range { start: Position { - line: 264, - character: 8, + line: 79, + character: 15, }, end: Position { - line: 264, - character: 76, + line: 79, + character: 41, }, }, }, - message: "Error originated from macro here", + message: "Exact error occured here", }, ], ), @@ -65,19 +65,19 @@ scheme: "file", host: None, port: None, - path: "/test/crates/hir_def/src/path.rs", + path: "/test/crates/hir_def/src/data.rs", query: None, fragment: None, }, diagnostic: Diagnostic { range: Range { start: Position { - line: 264, - character: 8, + line: 79, + character: 15, }, end: Position { - line: 264, - character: 76, + line: 79, + character: 41, }, }, severity: Some( @@ -89,33 +89,7 @@ "rustc", ), message: "Please register your known path in the path module", - related_information: Some( - [ - DiagnosticRelatedInformation { - location: Location { - uri: Url { - scheme: "file", - host: None, - port: None, - path: "/test/crates/hir_def/src/data.rs", - query: None, - fragment: None, - }, - range: Range { - start: Position { - line: 79, - character: 15, - }, - end: Position { - line: 79, - character: 41, - }, - }, - }, - message: "Exact error occured here", - }, - ], - ), + related_information: None, tags: None, data: None, }, diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt index c709de95f..23d42b4d0 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt @@ -32,7 +32,33 @@ "rustc", ), message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "consider prefixing with an underscore", + }, + ], + ), tags: Some( [ Unnecessary, @@ -87,4 +113,114 @@ }, ], }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "unused_variables", + ), + ), + code_description: None, + source: Some( + "rustc", + ), + message: "consider prefixing with an underscore", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }: [ + TextEdit { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + new_text: "_foo", + }, + ], + }, + ), + document_changes: None, + }, + ), + is_preferred: Some( + true, + ), + data: None, + }, + ], + }, ] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt index 632f438d7..4e428bedc 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt @@ -32,7 +32,33 @@ "rustc", ), message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "consider prefixing with an underscore", + }, + ], + ), tags: Some( [ Unnecessary, @@ -87,4 +113,114 @@ }, ], }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "unused_variables", + ), + ), + code_description: None, + source: Some( + "rustc", + ), + message: "consider prefixing with an underscore", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }: [ + TextEdit { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + new_text: "_foo", + }, + ], + }, + ), + document_changes: None, + }, + ), + is_preferred: Some( + true, + ), + data: None, + }, + ], + }, ] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt index c0b79428d..4ddd7efae 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt @@ -32,7 +32,33 @@ "rustc", ), message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "consider prefixing with an underscore", + }, + ], + ), tags: Some( [ Unnecessary, @@ -87,4 +113,114 @@ }, ], }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "unused_variables", + ), + ), + code_description: None, + source: Some( + "rustc", + ), + message: "consider prefixing with an underscore", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + Url { + scheme: "file", + host: None, + port: None, + path: "/test/driver/subcommand/repl.rs", + query: None, + fragment: None, + }: [ + TextEdit { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + new_text: "_foo", + }, + ], + }, + ), + document_changes: None, + }, + ), + is_preferred: Some( + true, + ), + data: None, + }, + ], + }, ] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt index b9650f3e4..f455cf25e 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt @@ -81,4 +81,86 @@ }, fixes: [], }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/ty/select.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 218, + character: 4, + }, + end: Position { + line: 230, + character: 5, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "E0061", + ), + ), + code_description: Some( + CodeDescription { + href: Url { + scheme: "https", + host: Some( + Domain( + "doc.rust-lang.org", + ), + ), + port: None, + path: "/error-index.html", + query: None, + fragment: Some( + "E0061", + ), + }, + }, + ), + source: Some( + "rustc", + ), + message: "defined here", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/compiler/ty/select.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 103, + character: 17, + }, + end: Position { + line: 103, + character: 29, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [], + }, ] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt index c45f68a91..4cbdb3b92 100644 --- a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt +++ b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt @@ -74,6 +74,309 @@ }, message: "unnecessary let binding", }, + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + }, + message: "return the expression directly", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [ + CodeAction { + title: "return the expression directly", + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }: [ + TextEdit { + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + new_text: "", + }, + TextEdit { + range: Range { + start: Position { + line: 3, + character: 4, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "(0..10).collect()", + }, + ], + }, + ), + document_changes: None, + }, + ), + is_preferred: Some( + true, + ), + data: None, + }, + ], + }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "let_and_return", + ), + ), + code_description: Some( + CodeDescription { + href: Url { + scheme: "https", + host: Some( + Domain( + "rust-lang.github.io", + ), + ), + port: None, + path: "/rust-clippy/master/index.html", + query: None, + fragment: Some( + "let_and_return", + ), + }, + }, + ), + source: Some( + "clippy", + ), + message: "unnecessary let binding", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 3, + character: 4, + }, + end: Position { + line: 3, + character: 5, + }, + }, + }, + message: "original diagnostic", + }, + ], + ), + tags: None, + data: None, + }, + fixes: [ + CodeAction { + title: "return the expression directly", + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }: [ + TextEdit { + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + new_text: "", + }, + TextEdit { + range: Range { + start: Position { + line: 3, + character: 4, + }, + end: Position { + line: 3, + character: 5, + }, + }, + new_text: "(0..10).collect()", + }, + ], + }, + ), + document_changes: None, + }, + ), + is_preferred: Some( + true, + ), + data: None, + }, + ], + }, + MappedRustDiagnostic { + url: Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }, + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "let_and_return", + ), + ), + code_description: Some( + CodeDescription { + href: Url { + scheme: "https", + host: Some( + Domain( + "rust-lang.github.io", + ), + ), + port: None, + path: "/rust-clippy/master/index.html", + query: None, + fragment: Some( + "let_and_return", + ), + }, + }, + ), + source: Some( + "clippy", + ), + message: "return the expression directly", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: Url { + scheme: "file", + host: None, + port: None, + path: "/test/src/main.rs", + query: None, + fragment: None, + }, + range: Range { + start: Position { + line: 3, + character: 4, + }, + end: Position { + line: 3, + character: 5, + }, + }, + }, + message: "original diagnostic", + }, ], ), tags: None, -- cgit v1.2.3