From c692b5d76d7a9c01643f1f4be3fa8c777a9b0adb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Aug 2020 14:47:14 +0200 Subject: :arrow_up: expect-test --- crates/hir_def/Cargo.toml | 2 +- crates/hir_ty/Cargo.toml | 2 +- crates/ide/Cargo.toml | 2 +- .../test_data/highlight_doctest.html | 102 +++++++++++++ .../test_data/highlight_extern_crate.html | 40 +++++ .../test_data/highlight_injection.html | 48 ++++++ .../test_data/highlight_strings.html | 96 ++++++++++++ .../test_data/highlight_unsafe.html | 99 ++++++++++++ .../test_data/highlighting.html | 170 +++++++++++++++++++++ .../test_data/rainbow_highlighting.html | 49 ++++++ crates/ide/src/syntax_highlighting/tests.rs | 14 +- crates/ide/test_data/highlight_doctest.html | 102 ------------- crates/ide/test_data/highlight_extern_crate.html | 40 ----- crates/ide/test_data/highlight_injection.html | 48 ------ crates/ide/test_data/highlight_strings.html | 96 ------------ crates/ide/test_data/highlight_unsafe.html | 99 ------------ crates/ide/test_data/highlighting.html | 170 --------------------- crates/ide/test_data/rainbow_highlighting.html | 49 ------ crates/rust-analyzer/Cargo.toml | 2 +- .../diagnostics/test_data/clippy_pass_by_ref.txt | 67 ++++++++ .../test_data/handles_macro_location.txt | 32 ++++ .../diagnostics/test_data/macro_compiler_error.txt | 47 ++++++ .../rustc_incompatible_type_for_trait.txt | 32 ++++ .../test_data/rustc_mismatched_type.txt | 32 ++++ .../test_data/rustc_unused_variable.txt | 74 +++++++++ .../test_data/rustc_unused_variable_as_hint.txt | 74 +++++++++ .../test_data/rustc_unused_variable_as_info.txt | 74 +++++++++ .../test_data/rustc_wrong_number_of_parameters.txt | 51 +++++++ .../diagnostics/test_data/snap_multi_line_fix.txt | 102 +++++++++++++ crates/rust-analyzer/src/diagnostics/to_proto.rs | 20 +-- .../rust-analyzer/test_data/clippy_pass_by_ref.txt | 67 -------- .../test_data/handles_macro_location.txt | 32 ---- .../test_data/macro_compiler_error.txt | 47 ------ .../rustc_incompatible_type_for_trait.txt | 32 ---- .../test_data/rustc_mismatched_type.txt | 32 ---- .../test_data/rustc_unused_variable.txt | 74 --------- .../test_data/rustc_unused_variable_as_hint.txt | 74 --------- .../test_data/rustc_unused_variable_as_info.txt | 74 --------- .../test_data/rustc_wrong_number_of_parameters.txt | 51 ------- .../test_data/snap_multi_line_fix.txt | 102 ------------- crates/ssr/Cargo.toml | 2 +- crates/syntax/Cargo.toml | 2 +- 42 files changed, 1212 insertions(+), 1212 deletions(-) create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlight_injection.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlight_strings.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/highlighting.html create mode 100644 crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html delete mode 100644 crates/ide/test_data/highlight_doctest.html delete mode 100644 crates/ide/test_data/highlight_extern_crate.html delete mode 100644 crates/ide/test_data/highlight_injection.html delete mode 100644 crates/ide/test_data/highlight_strings.html delete mode 100644 crates/ide/test_data/highlight_unsafe.html delete mode 100644 crates/ide/test_data/highlighting.html delete mode 100644 crates/ide/test_data/rainbow_highlighting.html create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt create mode 100644 crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt delete mode 100644 crates/rust-analyzer/test_data/clippy_pass_by_ref.txt delete mode 100644 crates/rust-analyzer/test_data/handles_macro_location.txt delete mode 100644 crates/rust-analyzer/test_data/macro_compiler_error.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_incompatible_type_for_trait.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_mismatched_type.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_unused_variable.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt delete mode 100644 crates/rust-analyzer/test_data/rustc_wrong_number_of_parameters.txt delete mode 100644 crates/rust-analyzer/test_data/snap_multi_line_fix.txt (limited to 'crates') diff --git a/crates/hir_def/Cargo.toml b/crates/hir_def/Cargo.toml index 011e4612c..a88b5f57e 100644 --- a/crates/hir_def/Cargo.toml +++ b/crates/hir_def/Cargo.toml @@ -33,4 +33,4 @@ cfg = { path = "../cfg", version = "0.0.0" } tt = { path = "../tt", version = "0.0.0" } [dev-dependencies] -expect-test = "0.1" +expect-test = "1.0" diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index 33e155a70..47940c36e 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml @@ -31,7 +31,7 @@ syntax = { path = "../syntax", version = "0.0.0" } test_utils = { path = "../test_utils", version = "0.0.0" } [dev-dependencies] -expect-test = "0.1" +expect-test = "1.0" tracing = "0.1" tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } tracing-tree = { version = "0.1.4" } diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index a15f704ca..f0257403d 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -36,4 +36,4 @@ ssr = { path = "../ssr", version = "0.0.0" } hir = { path = "../hir", version = "0.0.0" } [dev-dependencies] -expect-test = "0.1" +expect-test = "1.0" diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html new file mode 100644 index 000000000..6322d404f --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_doctest.html @@ -0,0 +1,102 @@ + + +
/// ```
+/// let _ = "early doctests should not go boom";
+/// ```
+struct Foo {
+    bar: bool,
+}
+
+impl Foo {
+    pub const bar: bool = true;
+
+    /// Constructs a new `Foo`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// # #![allow(unused_mut)]
+    /// let mut foo: Foo = Foo::new();
+    /// ```
+    pub const fn new() -> Foo {
+        Foo { bar: true }
+    }
+
+    /// `bar` method on `Foo`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use x::y;
+    ///
+    /// let foo = Foo::new();
+    ///
+    /// // calls bar on foo
+    /// assert!(foo.bar());
+    ///
+    /// let bar = foo.bar || Foo::bar;
+    ///
+    /// /* multi-line
+    ///        comment */
+    ///
+    /// let multi_line_string = "Foo
+    ///   bar
+    ///          ";
+    ///
+    /// ```
+    ///
+    /// ```rust,no_run
+    /// let foobar = Foo::new().bar();
+    /// ```
+    ///
+    /// ```sh
+    /// echo 1
+    /// ```
+    pub fn foo(&self) -> bool {
+        true
+    }
+}
+
+/// ```
+/// noop!(1);
+/// ```
+macro_rules! noop {
+    ($expr:expr) => {
+        $expr
+    }
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html b/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html new file mode 100644 index 000000000..800d894c7 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_extern_crate.html @@ -0,0 +1,40 @@ + + +
extern crate std;
+extern crate alloc as abc;
+
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html new file mode 100644 index 000000000..18addd00d --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_injection.html @@ -0,0 +1,48 @@ + + +
fn fixture(ra_fixture: &str) {}
+
+fn main() {
+    fixture(r#"
+        trait Foo {
+            fn foo() {
+                println!("2 + 2 = {}", 4);
+            }
+        }"#
+    );
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html new file mode 100644 index 000000000..1b681b2c6 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_strings.html @@ -0,0 +1,96 @@ + + +
macro_rules! println {
+    ($($arg:tt)*) => ({
+        $crate::io::_print($crate::format_args_nl!($($arg)*));
+    })
+}
+#[rustc_builtin_macro]
+macro_rules! format_args_nl {
+    ($fmt:expr) => {{ /* compiler built-in */ }};
+    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
+}
+
+fn main() {
+    // from https://doc.rust-lang.org/std/fmt/index.html
+    println!("Hello");                 // => "Hello"
+    println!("Hello, {}!", "world");   // => "Hello, world!"
+    println!("The number is {}", 1);   // => "The number is 1"
+    println!("{:?}", (3, 4));          // => "(3, 4)"
+    println!("{value}", value=4);      // => "4"
+    println!("{} {}", 1, 2);           // => "1 2"
+    println!("{:04}", 42);             // => "0042" with leading zerosV
+    println!("{1} {} {0} {}", 1, 2);   // => "2 1 1 2"
+    println!("{argument}", argument = "test");   // => "test"
+    println!("{name} {}", 1, name = 2);          // => "2 1"
+    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
+    println!("{{{}}}", 2);                       // => "{2}"
+    println!("Hello {:5}!", "x");
+    println!("Hello {:1$}!", "x", 5);
+    println!("Hello {1:0$}!", 5, "x");
+    println!("Hello {:width$}!", "x", width = 5);
+    println!("Hello {:<5}!", "x");
+    println!("Hello {:-<5}!", "x");
+    println!("Hello {:^5}!", "x");
+    println!("Hello {:>5}!", "x");
+    println!("Hello {:+}!", 5);
+    println!("{:#x}!", 27);
+    println!("Hello {:05}!", 5);
+    println!("Hello {:05}!", -5);
+    println!("{:#010x}!", 27);
+    println!("Hello {0} is {1:.5}", "x", 0.01);
+    println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
+    println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
+    println!("Hello {} is {:.*}",    "x", 5, 0.01);
+    println!("Hello {} is {2:.*}",   "x", 5, 0.01);
+    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
+    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
+    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
+    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
+    println!("Hello {{}}");
+    println!("{{ Hello");
+
+    println!(r"Hello, {}!", "world");
+
+    // escape sequences
+    println!("Hello\nWorld");
+    println!("\u{48}\x65\x6C\x6C\x6F World");
+
+    println!("{\x41}", A = 92);
+    println!("{ничоси}", ничоси = 92);
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html new file mode 100644 index 000000000..552fea668 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_unsafe.html @@ -0,0 +1,99 @@ + + +
unsafe fn unsafe_fn() {}
+
+union Union {
+    a: u32,
+    b: f32,
+}
+
+struct HasUnsafeFn;
+
+impl HasUnsafeFn {
+    unsafe fn unsafe_method(&self) {}
+}
+
+struct TypeForStaticMut {
+    a: u8
+}
+
+static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
+
+#[repr(packed)]
+struct Packed {
+    a: u16,
+}
+
+trait DoTheAutoref {
+    fn calls_autoref(&self);
+}
+
+impl DoTheAutoref for u16 {
+    fn calls_autoref(&self) {}
+}
+
+fn main() {
+    let x = &5 as *const _ as *const usize;
+    let u = Union { b: 0 };
+    unsafe {
+        // unsafe fn and method calls
+        unsafe_fn();
+        let b = u.b;
+        match u {
+            Union { b: 0 } => (),
+            Union { a } => (),
+        }
+        HasUnsafeFn.unsafe_method();
+
+        // unsafe deref
+        let y = *x;
+
+        // unsafe access to a static mut
+        let a = global_mut.a;
+
+        // unsafe ref of packed fields
+        let packed = Packed { a: 0 };
+        let a = &packed.a;
+        let ref a = packed.a;
+        let Packed { ref a } = packed;
+        let Packed { a: ref _a } = packed;
+
+        // unsafe auto ref of packed field
+        packed.a.calls_autoref();
+    }
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html new file mode 100644 index 000000000..d0df2e0ec --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html @@ -0,0 +1,170 @@ + + +
use inner::{self as inner_mod};
+mod inner {}
+
+// Needed for function consuming vs normal
+pub mod marker {
+    #[lang = "copy"]
+    pub trait Copy {}
+}
+
+#[derive(Clone, Debug)]
+struct Foo {
+    pub x: i32,
+    pub y: i32,
+}
+
+trait Bar {
+    fn bar(&self) -> i32;
+}
+
+impl Bar for Foo {
+    fn bar(&self) -> i32 {
+        self.x
+    }
+}
+
+impl Foo {
+    fn baz(mut self) -> i32 {
+        self.x
+    }
+
+    fn qux(&mut self) {
+        self.x = 0;
+    }
+
+    fn quop(&self) -> i32 {
+        self.x
+    }
+}
+
+#[derive(Copy, Clone)]
+struct FooCopy {
+    x: u32,
+}
+
+impl FooCopy {
+    fn baz(self) -> u32 {
+        self.x
+    }
+
+    fn qux(&mut self) {
+        self.x = 0;
+    }
+
+    fn quop(&self) -> u32 {
+        self.x
+    }
+}
+
+static mut STATIC_MUT: i32 = 0;
+
+fn foo<'a, T>() -> T {
+    foo::<'a, i32>()
+}
+
+macro_rules! def_fn {
+    ($($tt:tt)*) => {$($tt)*}
+}
+
+def_fn! {
+    fn bar() -> u32 {
+        100
+    }
+}
+
+macro_rules! noop {
+    ($expr:expr) => {
+        $expr
+    }
+}
+
+// comment
+fn main() {
+    println!("Hello, {}!", 92);
+
+    let mut vec = Vec::new();
+    if true {
+        let x = 92;
+        vec.push(Foo { x, y: 1 });
+    }
+    unsafe {
+        vec.set_len(0);
+        STATIC_MUT = 1;
+    }
+
+    for e in vec {
+        // Do nothing
+    }
+
+    noop!(noop!(1));
+
+    let mut x = 42;
+    let y = &mut x;
+    let z = &y;
+
+    let Foo { x: z, y } = Foo { x: z, y };
+
+    y;
+
+    let mut foo = Foo { x, y: x };
+    foo.quop();
+    foo.qux();
+    foo.baz();
+
+    let mut copy = FooCopy { x };
+    copy.quop();
+    copy.qux();
+    copy.baz();
+}
+
+enum Option<T> {
+    Some(T),
+    None,
+}
+use Option::*;
+
+impl<T> Option<T> {
+    fn and<U>(self, other: Option<U>) -> Option<(T, U)> {
+        match other {
+            None => unimplemented!(),
+            Nope => Nope,
+        }
+    }
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html b/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html new file mode 100644 index 000000000..401e87a73 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/rainbow_highlighting.html @@ -0,0 +1,49 @@ + + +
fn main() {
+    let hello = "hello";
+    let x = hello.to_string();
+    let y = hello.to_string();
+
+    let x = "other color please!";
+    let y = x.to_string();
+}
+
+fn bar() {
+    let mut hello = "hello";
+}
\ No newline at end of file diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index 1c3fea058..6f72a29bd 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -144,7 +144,7 @@ impl Option { } "# .trim(), - expect_file!["crates/ide/test_data/highlighting.html"], + expect_file!["./test_data/highlighting.html"], false, ); } @@ -167,7 +167,7 @@ fn bar() { } "# .trim(), - expect_file!["crates/ide/test_data/rainbow_highlighting.html"], + expect_file!["./test_data/rainbow_highlighting.html"], true, ); } @@ -220,7 +220,7 @@ fn main() { ); }"## .trim(), - expect_file!["crates/ide/test_data/highlight_injection.html"], + expect_file!["./test_data/highlight_injection.html"], false, ); } @@ -303,7 +303,7 @@ fn main() { println!("{ничоси}", ничоси = 92); }"# .trim(), - expect_file!["crates/ide/test_data/highlight_strings.html"], + expect_file!["./test_data/highlight_strings.html"], false, ); } @@ -376,7 +376,7 @@ fn main() { } "# .trim(), - expect_file!["crates/ide/test_data/highlight_unsafe.html"], + expect_file!["./test_data/highlight_unsafe.html"], false, ); } @@ -452,7 +452,7 @@ macro_rules! noop { } "# .trim(), - expect_file!["crates/ide/test_data/highlight_doctest.html"], + expect_file!["./test_data/highlight_doctest.html"], false, ); } @@ -469,7 +469,7 @@ fn test_extern_crate() { //- /alloc/lib.rs pub struct A "#, - expect_file!["crates/ide/test_data/highlight_extern_crate.html"], + expect_file!["./test_data/highlight_extern_crate.html"], false, ); } diff --git a/crates/ide/test_data/highlight_doctest.html b/crates/ide/test_data/highlight_doctest.html deleted file mode 100644 index 6322d404f..000000000 --- a/crates/ide/test_data/highlight_doctest.html +++ /dev/null @@ -1,102 +0,0 @@ - - -
/// ```
-/// let _ = "early doctests should not go boom";
-/// ```
-struct Foo {
-    bar: bool,
-}
-
-impl Foo {
-    pub const bar: bool = true;
-
-    /// Constructs a new `Foo`.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// # #![allow(unused_mut)]
-    /// let mut foo: Foo = Foo::new();
-    /// ```
-    pub const fn new() -> Foo {
-        Foo { bar: true }
-    }
-
-    /// `bar` method on `Foo`.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// use x::y;
-    ///
-    /// let foo = Foo::new();
-    ///
-    /// // calls bar on foo
-    /// assert!(foo.bar());
-    ///
-    /// let bar = foo.bar || Foo::bar;
-    ///
-    /// /* multi-line
-    ///        comment */
-    ///
-    /// let multi_line_string = "Foo
-    ///   bar
-    ///          ";
-    ///
-    /// ```
-    ///
-    /// ```rust,no_run
-    /// let foobar = Foo::new().bar();
-    /// ```
-    ///
-    /// ```sh
-    /// echo 1
-    /// ```
-    pub fn foo(&self) -> bool {
-        true
-    }
-}
-
-/// ```
-/// noop!(1);
-/// ```
-macro_rules! noop {
-    ($expr:expr) => {
-        $expr
-    }
-}
\ No newline at end of file diff --git a/crates/ide/test_data/highlight_extern_crate.html b/crates/ide/test_data/highlight_extern_crate.html deleted file mode 100644 index 800d894c7..000000000 --- a/crates/ide/test_data/highlight_extern_crate.html +++ /dev/null @@ -1,40 +0,0 @@ - - -
extern crate std;
-extern crate alloc as abc;
-
\ No newline at end of file diff --git a/crates/ide/test_data/highlight_injection.html b/crates/ide/test_data/highlight_injection.html deleted file mode 100644 index 18addd00d..000000000 --- a/crates/ide/test_data/highlight_injection.html +++ /dev/null @@ -1,48 +0,0 @@ - - -
fn fixture(ra_fixture: &str) {}
-
-fn main() {
-    fixture(r#"
-        trait Foo {
-            fn foo() {
-                println!("2 + 2 = {}", 4);
-            }
-        }"#
-    );
-}
\ No newline at end of file diff --git a/crates/ide/test_data/highlight_strings.html b/crates/ide/test_data/highlight_strings.html deleted file mode 100644 index 1b681b2c6..000000000 --- a/crates/ide/test_data/highlight_strings.html +++ /dev/null @@ -1,96 +0,0 @@ - - -
macro_rules! println {
-    ($($arg:tt)*) => ({
-        $crate::io::_print($crate::format_args_nl!($($arg)*));
-    })
-}
-#[rustc_builtin_macro]
-macro_rules! format_args_nl {
-    ($fmt:expr) => {{ /* compiler built-in */ }};
-    ($fmt:expr, $($args:tt)*) => {{ /* compiler built-in */ }};
-}
-
-fn main() {
-    // from https://doc.rust-lang.org/std/fmt/index.html
-    println!("Hello");                 // => "Hello"
-    println!("Hello, {}!", "world");   // => "Hello, world!"
-    println!("The number is {}", 1);   // => "The number is 1"
-    println!("{:?}", (3, 4));          // => "(3, 4)"
-    println!("{value}", value=4);      // => "4"
-    println!("{} {}", 1, 2);           // => "1 2"
-    println!("{:04}", 42);             // => "0042" with leading zerosV
-    println!("{1} {} {0} {}", 1, 2);   // => "2 1 1 2"
-    println!("{argument}", argument = "test");   // => "test"
-    println!("{name} {}", 1, name = 2);          // => "2 1"
-    println!("{a} {c} {b}", a="a", b='b', c=3);  // => "a 3 b"
-    println!("{{{}}}", 2);                       // => "{2}"
-    println!("Hello {:5}!", "x");
-    println!("Hello {:1$}!", "x", 5);
-    println!("Hello {1:0$}!", 5, "x");
-    println!("Hello {:width$}!", "x", width = 5);
-    println!("Hello {:<5}!", "x");
-    println!("Hello {:-<5}!", "x");
-    println!("Hello {:^5}!", "x");
-    println!("Hello {:>5}!", "x");
-    println!("Hello {:+}!", 5);
-    println!("{:#x}!", 27);
-    println!("Hello {:05}!", 5);
-    println!("Hello {:05}!", -5);
-    println!("{:#010x}!", 27);
-    println!("Hello {0} is {1:.5}", "x", 0.01);
-    println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
-    println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
-    println!("Hello {} is {:.*}",    "x", 5, 0.01);
-    println!("Hello {} is {2:.*}",   "x", 5, 0.01);
-    println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
-    println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
-    println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
-    println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
-    println!("Hello {{}}");
-    println!("{{ Hello");
-
-    println!(r"Hello, {}!", "world");
-
-    // escape sequences
-    println!("Hello\nWorld");
-    println!("\u{48}\x65\x6C\x6C\x6F World");
-
-    println!("{\x41}", A = 92);
-    println!("{ничоси}", ничоси = 92);
-}
\ No newline at end of file diff --git a/crates/ide/test_data/highlight_unsafe.html b/crates/ide/test_data/highlight_unsafe.html deleted file mode 100644 index 552fea668..000000000 --- a/crates/ide/test_data/highlight_unsafe.html +++ /dev/null @@ -1,99 +0,0 @@ - - -
unsafe fn unsafe_fn() {}
-
-union Union {
-    a: u32,
-    b: f32,
-}
-
-struct HasUnsafeFn;
-
-impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
-}
-
-struct TypeForStaticMut {
-    a: u8
-}
-
-static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
-
-#[repr(packed)]
-struct Packed {
-    a: u16,
-}
-
-trait DoTheAutoref {
-    fn calls_autoref(&self);
-}
-
-impl DoTheAutoref for u16 {
-    fn calls_autoref(&self) {}
-}
-
-fn main() {
-    let x = &5 as *const _ as *const usize;
-    let u = Union { b: 0 };
-    unsafe {
-        // unsafe fn and method calls
-        unsafe_fn();
-        let b = u.b;
-        match u {
-            Union { b: 0 } => (),
-            Union { a } => (),
-        }
-        HasUnsafeFn.unsafe_method();
-
-        // unsafe deref
-        let y = *x;
-
-        // unsafe access to a static mut
-        let a = global_mut.a;
-
-        // unsafe ref of packed fields
-        let packed = Packed { a: 0 };
-        let a = &packed.a;
-        let ref a = packed.a;
-        let Packed { ref a } = packed;
-        let Packed { a: ref _a } = packed;
-
-        // unsafe auto ref of packed field
-        packed.a.calls_autoref();
-    }
-}
\ No newline at end of file diff --git a/crates/ide/test_data/highlighting.html b/crates/ide/test_data/highlighting.html deleted file mode 100644 index d0df2e0ec..000000000 --- a/crates/ide/test_data/highlighting.html +++ /dev/null @@ -1,170 +0,0 @@ - - -
use inner::{self as inner_mod};
-mod inner {}
-
-// Needed for function consuming vs normal
-pub mod marker {
-    #[lang = "copy"]
-    pub trait Copy {}
-}
-
-#[derive(Clone, Debug)]
-struct Foo {
-    pub x: i32,
-    pub y: i32,
-}
-
-trait Bar {
-    fn bar(&self) -> i32;
-}
-
-impl Bar for Foo {
-    fn bar(&self) -> i32 {
-        self.x
-    }
-}
-
-impl Foo {
-    fn baz(mut self) -> i32 {
-        self.x
-    }
-
-    fn qux(&mut self) {
-        self.x = 0;
-    }
-
-    fn quop(&self) -> i32 {
-        self.x
-    }
-}
-
-#[derive(Copy, Clone)]
-struct FooCopy {
-    x: u32,
-}
-
-impl FooCopy {
-    fn baz(self) -> u32 {
-        self.x
-    }
-
-    fn qux(&mut self) {
-        self.x = 0;
-    }
-
-    fn quop(&self) -> u32 {
-        self.x
-    }
-}
-
-static mut STATIC_MUT: i32 = 0;
-
-fn foo<'a, T>() -> T {
-    foo::<'a, i32>()
-}
-
-macro_rules! def_fn {
-    ($($tt:tt)*) => {$($tt)*}
-}
-
-def_fn! {
-    fn bar() -> u32 {
-        100
-    }
-}
-
-macro_rules! noop {
-    ($expr:expr) => {
-        $expr
-    }
-}
-
-// comment
-fn main() {
-    println!("Hello, {}!", 92);
-
-    let mut vec = Vec::new();
-    if true {
-        let x = 92;
-        vec.push(Foo { x, y: 1 });
-    }
-    unsafe {
-        vec.set_len(0);
-        STATIC_MUT = 1;
-    }
-
-    for e in vec {
-        // Do nothing
-    }
-
-    noop!(noop!(1));
-
-    let mut x = 42;
-    let y = &mut x;
-    let z = &y;
-
-    let Foo { x: z, y } = Foo { x: z, y };
-
-    y;
-
-    let mut foo = Foo { x, y: x };
-    foo.quop();
-    foo.qux();
-    foo.baz();
-
-    let mut copy = FooCopy { x };
-    copy.quop();
-    copy.qux();
-    copy.baz();
-}
-
-enum Option<T> {
-    Some(T),
-    None,
-}
-use Option::*;
-
-impl<T> Option<T> {
-    fn and<U>(self, other: Option<U>) -> Option<(T, U)> {
-        match other {
-            None => unimplemented!(),
-            Nope => Nope,
-        }
-    }
-}
\ No newline at end of file diff --git a/crates/ide/test_data/rainbow_highlighting.html b/crates/ide/test_data/rainbow_highlighting.html deleted file mode 100644 index 401e87a73..000000000 --- a/crates/ide/test_data/rainbow_highlighting.html +++ /dev/null @@ -1,49 +0,0 @@ - - -
fn main() {
-    let hello = "hello";
-    let x = hello.to_string();
-    let y = hello.to_string();
-
-    let x = "other color please!";
-    let y = x.to_string();
-}
-
-fn bar() {
-    let mut hello = "hello";
-}
\ No newline at end of file diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 044686a99..e06956d6c 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -58,7 +58,7 @@ proc_macro_srv = { path = "../proc_macro_srv", version = "0.0.0" } winapi = "0.3.8" [dev-dependencies] -expect-test = "0.1" +expect-test = "1.0" test_utils = { path = "../test_utils" } mbe = { path = "../mbe" } tt = { path = "../tt" } 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 new file mode 100644 index 000000000..d06517126 --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt @@ -0,0 +1,67 @@ +[ + MappedRustDiagnostic { + url: "file:///test/compiler/mir/tagset.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 41, + character: 23, + }, + end: Position { + line: 41, + character: 28, + }, + }, + severity: Some( + Warning, + ), + code: Some( + String( + "trivially_copy_pass_by_ref", + ), + ), + source: Some( + "clippy", + ), + message: "this argument is passed by reference, but would be more efficient if passed by value\n#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: "file:///test/compiler/lib.rs", + range: Range { + start: Position { + line: 0, + character: 8, + }, + end: Position { + line: 0, + character: 19, + }, + }, + }, + message: "lint level defined here", + }, + DiagnosticRelatedInformation { + location: Location { + uri: "file:///test/compiler/mir/tagset.rs", + range: Range { + start: Position { + line: 41, + character: 23, + }, + end: Position { + line: 41, + character: 28, + }, + }, + }, + message: "consider passing by value instead", + }, + ], + ), + tags: None, + }, + fixes: [], + }, +] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt new file mode 100644 index 000000000..f5de2f07f --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/handles_macro_location.txt @@ -0,0 +1,32 @@ +[ + MappedRustDiagnostic { + url: "file:///test/src/main.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 1, + character: 4, + }, + end: Position { + line: 1, + character: 26, + }, + }, + severity: Some( + Error, + ), + code: Some( + String( + "E0277", + ), + ), + source: Some( + "rustc", + ), + message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", + related_information: None, + tags: 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 new file mode 100644 index 000000000..89dae7d5a --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/macro_compiler_error.txt @@ -0,0 +1,47 @@ +[ + MappedRustDiagnostic { + url: "file:///test/crates/hir_def/src/data.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 79, + character: 15, + }, + end: Position { + line: 79, + character: 41, + }, + }, + severity: Some( + Error, + ), + code: None, + source: Some( + "rustc", + ), + message: "Please register your known path in the path module", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: "file:///test/crates/hir_def/src/path.rs", + range: Range { + start: Position { + line: 264, + character: 8, + }, + end: Position { + line: 264, + character: 76, + }, + }, + }, + message: "Error originated from macro here", + }, + ], + ), + tags: None, + }, + fixes: [], + }, +] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt new file mode 100644 index 000000000..fc54440be --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_incompatible_type_for_trait.txt @@ -0,0 +1,32 @@ +[ + MappedRustDiagnostic { + url: "file:///test/compiler/ty/list_iter.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 51, + character: 4, + }, + end: Position { + line: 51, + character: 47, + }, + }, + severity: Some( + Error, + ), + code: Some( + String( + "E0053", + ), + ), + source: Some( + "rustc", + ), + message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref>`", + related_information: None, + tags: None, + }, + fixes: [], + }, +] diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt new file mode 100644 index 000000000..c269af218 --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_mismatched_type.txt @@ -0,0 +1,32 @@ +[ + MappedRustDiagnostic { + url: "file:///test/runtime/compiler_support.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 47, + character: 64, + }, + end: Position { + line: 47, + character: 69, + }, + }, + severity: Some( + Error, + ), + code: Some( + String( + "E0308", + ), + ), + source: Some( + "rustc", + ), + message: "mismatched types\nexpected usize, found u32", + related_information: None, + tags: None, + }, + fixes: [], + }, +] 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 new file mode 100644 index 000000000..74d91bc77 --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt @@ -0,0 +1,74 @@ +[ + MappedRustDiagnostic { + url: "file:///test/driver/subcommand/repl.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Warning, + ), + code: Some( + String( + "unused_variables", + ), + ), + source: Some( + "rustc", + ), + message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", + related_information: None, + tags: Some( + [ + Unnecessary, + ], + ), + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + id: None, + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + "file:///test/driver/subcommand/repl.rs": [ + 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, + ), + }, + ], + }, +] 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 new file mode 100644 index 000000000..8a420c949 --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt @@ -0,0 +1,74 @@ +[ + MappedRustDiagnostic { + url: "file:///test/driver/subcommand/repl.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Hint, + ), + code: Some( + String( + "unused_variables", + ), + ), + source: Some( + "rustc", + ), + message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", + related_information: None, + tags: Some( + [ + Unnecessary, + ], + ), + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + id: None, + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + "file:///test/driver/subcommand/repl.rs": [ + 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, + ), + }, + ], + }, +] 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 new file mode 100644 index 000000000..79910660b --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt @@ -0,0 +1,74 @@ +[ + MappedRustDiagnostic { + url: "file:///test/driver/subcommand/repl.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 290, + character: 8, + }, + end: Position { + line: 290, + character: 11, + }, + }, + severity: Some( + Information, + ), + code: Some( + String( + "unused_variables", + ), + ), + source: Some( + "rustc", + ), + message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", + related_information: None, + tags: Some( + [ + Unnecessary, + ], + ), + }, + fixes: [ + CodeAction { + title: "consider prefixing with an underscore", + id: None, + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + "file:///test/driver/subcommand/repl.rs": [ + 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, + ), + }, + ], + }, +] 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 new file mode 100644 index 000000000..efe37261d --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_wrong_number_of_parameters.txt @@ -0,0 +1,51 @@ +[ + MappedRustDiagnostic { + url: "file:///test/compiler/ty/select.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 103, + character: 17, + }, + end: Position { + line: 103, + character: 29, + }, + }, + severity: Some( + Error, + ), + code: Some( + String( + "E0061", + ), + ), + source: Some( + "rustc", + ), + message: "this function takes 2 parameters but 3 parameters were supplied\nexpected 2 parameters", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: "file:///test/compiler/ty/select.rs", + range: Range { + start: Position { + line: 218, + character: 4, + }, + end: Position { + line: 230, + character: 5, + }, + }, + }, + message: "defined here", + }, + ], + ), + tags: 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 new file mode 100644 index 000000000..4f811ab64 --- /dev/null +++ b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt @@ -0,0 +1,102 @@ +[ + MappedRustDiagnostic { + url: "file:///test/src/main.rs", + diagnostic: Diagnostic { + range: Range { + start: Position { + line: 3, + character: 4, + }, + end: Position { + line: 3, + character: 5, + }, + }, + severity: Some( + Warning, + ), + code: Some( + String( + "let_and_return", + ), + ), + source: Some( + "clippy", + ), + message: "returning the result of a let binding from a block\n`#[warn(clippy::let_and_return)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return", + related_information: Some( + [ + DiagnosticRelatedInformation { + location: Location { + uri: "file:///test/src/main.rs", + range: Range { + start: Position { + line: 2, + character: 4, + }, + end: Position { + line: 2, + character: 30, + }, + }, + }, + message: "unnecessary let binding", + }, + ], + ), + tags: None, + }, + fixes: [ + CodeAction { + title: "return the expression directly", + id: None, + group: None, + kind: Some( + CodeActionKind( + "quickfix", + ), + ), + edit: Some( + SnippetWorkspaceEdit { + changes: Some( + { + "file:///test/src/main.rs": [ + 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, + ), + }, + ], + }, +] diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index e52b97913..f69a949f2 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -315,7 +315,7 @@ mod tests { "rendered": "error[E0053]: method `next` has an incompatible type for trait\n --> compiler/ty/list_iter.rs:52:5\n |\n52 | fn next(&self) -> Option<&'list ty::Ref> {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability\n |\n = note: expected type `fn(&mut ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&ty::Ref>`\n found type `fn(&ty::list_iter::ListIterator<'list, M>) -> std::option::Option<&'list ty::Ref>`\n\n" } "##, - expect_file!["crates/rust-analyzer/test_data/rustc_incompatible_type_for_trait.txt"], + expect_file!["./test_data/rustc_incompatible_type_for_trait.txt"], ); } @@ -394,7 +394,7 @@ mod tests { ], "rendered": "warning: unused variable: `foo`\n --> driver/subcommand/repl.rs:291:9\n |\n291 | let foo = 42;\n | ^^^ help: consider prefixing with an underscore: `_foo`\n |\n = note: #[warn(unused_variables)] on by default\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/rustc_unused_variable.txt"], + expect_file!["./test_data/rustc_unused_variable.txt"], ); } @@ -478,7 +478,7 @@ mod tests { ], "rendered": "warning: unused variable: `foo`\n --> driver/subcommand/repl.rs:291:9\n |\n291 | let foo = 42;\n | ^^^ help: consider prefixing with an underscore: `_foo`\n |\n = note: #[warn(unused_variables)] on by default\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt"], + expect_file!["./test_data/rustc_unused_variable_as_info.txt"], ); } @@ -562,7 +562,7 @@ mod tests { ], "rendered": "warning: unused variable: `foo`\n --> driver/subcommand/repl.rs:291:9\n |\n291 | let foo = 42;\n | ^^^ help: consider prefixing with an underscore: `_foo`\n |\n = note: #[warn(unused_variables)] on by default\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt"], + expect_file!["./test_data/rustc_unused_variable_as_hint.txt"], ); } @@ -683,7 +683,7 @@ mod tests { "children": [], "rendered": "error[E0061]: this function takes 2 parameters but 3 parameters were supplied\n --> compiler/ty/select.rs:104:18\n |\n104 | self.add_evidence(target_fixed, evidence_fixed, false);\n | ^^^^^^^^^^^^ expected 2 parameters\n...\n219 | / pub fn add_evidence(\n220 | | &mut self,\n221 | | target_poly: &ty::Ref,\n222 | | evidence_poly: &ty::Ref,\n... |\n230 | | }\n231 | | }\n | |_____- defined here\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/rustc_wrong_number_of_parameters.txt"], + expect_file!["./test_data/rustc_wrong_number_of_parameters.txt"], ); } @@ -800,7 +800,7 @@ mod tests { ], "rendered": "warning: this argument is passed by reference, but would be more efficient if passed by value\n --> compiler/mir/tagset.rs:42:24\n |\n42 | pub fn is_disjoint(&self, other: Self) -> bool {\n | ^^^^^ help: consider passing by value instead: `self`\n |\nnote: lint level defined here\n --> compiler/lib.rs:1:9\n |\n1 | #![warn(clippy::all)]\n | ^^^^^^^^^^^\n = note: #[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/clippy_pass_by_ref.txt"], + expect_file!["./test_data/clippy_pass_by_ref.txt"], ); } @@ -840,7 +840,7 @@ mod tests { "children": [], "rendered": "error[E0308]: mismatched types\n --> runtime/compiler_support.rs:48:65\n |\n48 | let layout = alloc::Layout::from_size_align_unchecked(size, align);\n | ^^^^^ expected usize, found u32\n\n" }"##, - expect_file!["crates/rust-analyzer/test_data/rustc_mismatched_type.txt"], + expect_file!["./test_data/rustc_mismatched_type.txt"], ); } @@ -1108,7 +1108,7 @@ mod tests { } ] }"##, - expect_file!["crates/rust-analyzer/test_data/handles_macro_location.txt"], + expect_file!["./test_data/handles_macro_location.txt"], ); } @@ -1334,7 +1334,7 @@ mod tests { ] } "##, - expect_file!["crates/rust-analyzer/test_data/macro_compiler_error.txt"], + expect_file!["./test_data/macro_compiler_error.txt"], ); } @@ -1464,7 +1464,7 @@ mod tests { ] } "##, - expect_file!["crates/rust-analyzer/test_data/snap_multi_line_fix.txt"], + expect_file!["./test_data/snap_multi_line_fix.txt"], ); } } diff --git a/crates/rust-analyzer/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/test_data/clippy_pass_by_ref.txt deleted file mode 100644 index d06517126..000000000 --- a/crates/rust-analyzer/test_data/clippy_pass_by_ref.txt +++ /dev/null @@ -1,67 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/compiler/mir/tagset.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 41, - character: 23, - }, - end: Position { - line: 41, - character: 28, - }, - }, - severity: Some( - Warning, - ), - code: Some( - String( - "trivially_copy_pass_by_ref", - ), - ), - source: Some( - "clippy", - ), - message: "this argument is passed by reference, but would be more efficient if passed by value\n#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref", - related_information: Some( - [ - DiagnosticRelatedInformation { - location: Location { - uri: "file:///test/compiler/lib.rs", - range: Range { - start: Position { - line: 0, - character: 8, - }, - end: Position { - line: 0, - character: 19, - }, - }, - }, - message: "lint level defined here", - }, - DiagnosticRelatedInformation { - location: Location { - uri: "file:///test/compiler/mir/tagset.rs", - range: Range { - start: Position { - line: 41, - character: 23, - }, - end: Position { - line: 41, - character: 28, - }, - }, - }, - message: "consider passing by value instead", - }, - ], - ), - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/handles_macro_location.txt b/crates/rust-analyzer/test_data/handles_macro_location.txt deleted file mode 100644 index f5de2f07f..000000000 --- a/crates/rust-analyzer/test_data/handles_macro_location.txt +++ /dev/null @@ -1,32 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/src/main.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 1, - character: 4, - }, - end: Position { - line: 1, - character: 26, - }, - }, - severity: Some( - Error, - ), - code: Some( - String( - "E0277", - ), - ), - source: Some( - "rustc", - ), - message: "can\'t compare `{integer}` with `&str`\nthe trait `std::cmp::PartialEq<&str>` is not implemented for `{integer}`", - related_information: None, - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/macro_compiler_error.txt b/crates/rust-analyzer/test_data/macro_compiler_error.txt deleted file mode 100644 index 89dae7d5a..000000000 --- a/crates/rust-analyzer/test_data/macro_compiler_error.txt +++ /dev/null @@ -1,47 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/crates/hir_def/src/data.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 79, - character: 15, - }, - end: Position { - line: 79, - character: 41, - }, - }, - severity: Some( - Error, - ), - code: None, - source: Some( - "rustc", - ), - message: "Please register your known path in the path module", - related_information: Some( - [ - DiagnosticRelatedInformation { - location: Location { - uri: "file:///test/crates/hir_def/src/path.rs", - range: Range { - start: Position { - line: 264, - character: 8, - }, - end: Position { - line: 264, - character: 76, - }, - }, - }, - message: "Error originated from macro here", - }, - ], - ), - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_incompatible_type_for_trait.txt b/crates/rust-analyzer/test_data/rustc_incompatible_type_for_trait.txt deleted file mode 100644 index fc54440be..000000000 --- a/crates/rust-analyzer/test_data/rustc_incompatible_type_for_trait.txt +++ /dev/null @@ -1,32 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/compiler/ty/list_iter.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 51, - character: 4, - }, - end: Position { - line: 51, - character: 47, - }, - }, - severity: Some( - Error, - ), - code: Some( - String( - "E0053", - ), - ), - source: Some( - "rustc", - ), - message: "method `next` has an incompatible type for trait\nexpected type `fn(&mut ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&ty::Ref>`\n found type `fn(&ty::list_iter::ListIterator<\'list, M>) -> std::option::Option<&\'list ty::Ref>`", - related_information: None, - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_mismatched_type.txt b/crates/rust-analyzer/test_data/rustc_mismatched_type.txt deleted file mode 100644 index c269af218..000000000 --- a/crates/rust-analyzer/test_data/rustc_mismatched_type.txt +++ /dev/null @@ -1,32 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/runtime/compiler_support.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 47, - character: 64, - }, - end: Position { - line: 47, - character: 69, - }, - }, - severity: Some( - Error, - ), - code: Some( - String( - "E0308", - ), - ), - source: Some( - "rustc", - ), - message: "mismatched types\nexpected usize, found u32", - related_information: None, - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/test_data/rustc_unused_variable.txt deleted file mode 100644 index 74d91bc77..000000000 --- a/crates/rust-analyzer/test_data/rustc_unused_variable.txt +++ /dev/null @@ -1,74 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/driver/subcommand/repl.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - severity: Some( - Warning, - ), - code: Some( - String( - "unused_variables", - ), - ), - source: Some( - "rustc", - ), - message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, - tags: Some( - [ - Unnecessary, - ], - ), - }, - fixes: [ - CodeAction { - title: "consider prefixing with an underscore", - id: None, - group: None, - kind: Some( - CodeActionKind( - "quickfix", - ), - ), - edit: Some( - SnippetWorkspaceEdit { - changes: Some( - { - "file:///test/driver/subcommand/repl.rs": [ - 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, - ), - }, - ], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt deleted file mode 100644 index 8a420c949..000000000 --- a/crates/rust-analyzer/test_data/rustc_unused_variable_as_hint.txt +++ /dev/null @@ -1,74 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/driver/subcommand/repl.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - severity: Some( - Hint, - ), - code: Some( - String( - "unused_variables", - ), - ), - source: Some( - "rustc", - ), - message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, - tags: Some( - [ - Unnecessary, - ], - ), - }, - fixes: [ - CodeAction { - title: "consider prefixing with an underscore", - id: None, - group: None, - kind: Some( - CodeActionKind( - "quickfix", - ), - ), - edit: Some( - SnippetWorkspaceEdit { - changes: Some( - { - "file:///test/driver/subcommand/repl.rs": [ - 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, - ), - }, - ], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt deleted file mode 100644 index 79910660b..000000000 --- a/crates/rust-analyzer/test_data/rustc_unused_variable_as_info.txt +++ /dev/null @@ -1,74 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/driver/subcommand/repl.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - severity: Some( - Information, - ), - code: Some( - String( - "unused_variables", - ), - ), - source: Some( - "rustc", - ), - message: "unused variable: `foo`\n#[warn(unused_variables)] on by default", - related_information: None, - tags: Some( - [ - Unnecessary, - ], - ), - }, - fixes: [ - CodeAction { - title: "consider prefixing with an underscore", - id: None, - group: None, - kind: Some( - CodeActionKind( - "quickfix", - ), - ), - edit: Some( - SnippetWorkspaceEdit { - changes: Some( - { - "file:///test/driver/subcommand/repl.rs": [ - 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, - ), - }, - ], - }, -] diff --git a/crates/rust-analyzer/test_data/rustc_wrong_number_of_parameters.txt b/crates/rust-analyzer/test_data/rustc_wrong_number_of_parameters.txt deleted file mode 100644 index efe37261d..000000000 --- a/crates/rust-analyzer/test_data/rustc_wrong_number_of_parameters.txt +++ /dev/null @@ -1,51 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/compiler/ty/select.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 103, - character: 17, - }, - end: Position { - line: 103, - character: 29, - }, - }, - severity: Some( - Error, - ), - code: Some( - String( - "E0061", - ), - ), - source: Some( - "rustc", - ), - message: "this function takes 2 parameters but 3 parameters were supplied\nexpected 2 parameters", - related_information: Some( - [ - DiagnosticRelatedInformation { - location: Location { - uri: "file:///test/compiler/ty/select.rs", - range: Range { - start: Position { - line: 218, - character: 4, - }, - end: Position { - line: 230, - character: 5, - }, - }, - }, - message: "defined here", - }, - ], - ), - tags: None, - }, - fixes: [], - }, -] diff --git a/crates/rust-analyzer/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/test_data/snap_multi_line_fix.txt deleted file mode 100644 index 4f811ab64..000000000 --- a/crates/rust-analyzer/test_data/snap_multi_line_fix.txt +++ /dev/null @@ -1,102 +0,0 @@ -[ - MappedRustDiagnostic { - url: "file:///test/src/main.rs", - diagnostic: Diagnostic { - range: Range { - start: Position { - line: 3, - character: 4, - }, - end: Position { - line: 3, - character: 5, - }, - }, - severity: Some( - Warning, - ), - code: Some( - String( - "let_and_return", - ), - ), - source: Some( - "clippy", - ), - message: "returning the result of a let binding from a block\n`#[warn(clippy::let_and_return)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return", - related_information: Some( - [ - DiagnosticRelatedInformation { - location: Location { - uri: "file:///test/src/main.rs", - range: Range { - start: Position { - line: 2, - character: 4, - }, - end: Position { - line: 2, - character: 30, - }, - }, - }, - message: "unnecessary let binding", - }, - ], - ), - tags: None, - }, - fixes: [ - CodeAction { - title: "return the expression directly", - id: None, - group: None, - kind: Some( - CodeActionKind( - "quickfix", - ), - ), - edit: Some( - SnippetWorkspaceEdit { - changes: Some( - { - "file:///test/src/main.rs": [ - 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, - ), - }, - ], - }, -] diff --git a/crates/ssr/Cargo.toml b/crates/ssr/Cargo.toml index 6f0f53d70..408140014 100644 --- a/crates/ssr/Cargo.toml +++ b/crates/ssr/Cargo.toml @@ -22,4 +22,4 @@ hir = { path = "../hir", version = "0.0.0" } test_utils = { path = "../test_utils", version = "0.0.0" } [dev-dependencies] -expect-test = "0.1" +expect-test = "1.0" diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 2c1bdb295..af61bb658 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -30,6 +30,6 @@ parser = { path = "../parser", version = "0.0.0" } [dev-dependencies] walkdir = "2.3.1" rayon = "1" -expect-test = "0.1" +expect-test = "1.0" test_utils = { path = "../test_utils" } -- cgit v1.2.3