]> git.lizzy.rs Git - rust.git/commitdiff
Add rust-fix test
authorHirochika Matsumoto <matsujika@gmail.com>
Fri, 29 Jan 2021 07:33:15 +0000 (16:33 +0900)
committerHirochika Matsumoto <matsujika@gmail.com>
Fri, 29 Jan 2021 07:33:15 +0000 (16:33 +0900)
src/test/ui/suggestions/field-access.fixed [new file with mode: 0644]
src/test/ui/suggestions/field-access.rs
src/test/ui/suggestions/field-access.stderr

diff --git a/src/test/ui/suggestions/field-access.fixed b/src/test/ui/suggestions/field-access.fixed
new file mode 100644 (file)
index 0000000..d580902
--- /dev/null
@@ -0,0 +1,26 @@
+// run-rustfix
+#![allow(dead_code)]
+
+struct A {
+    b: B,
+}
+
+enum B {
+    Fst,
+    Snd,
+}
+
+fn main() {
+    let a = A { b: B::Fst };
+    if let B::Fst = a.b {};
+    //~^ ERROR mismatched types [E0308]
+    // note: you might have meant to use field `b` of type `B`
+    match a.b {
+        B::Fst => (),
+        B::Snd => (),
+    }
+    //~^^^ ERROR mismatched types [E0308]
+    // note: you might have meant to use field `b` of type `B`
+    //~^^^^ ERROR mismatched types [E0308]
+    // note: you might have meant to use field `b` of type `B`
+}
index 7bf621c21d39962f6a4c9c68e0c955a9e60c5baa..ed6f9b2112be6faa1f64a9b2be864a50495c7601 100644 (file)
@@ -1,3 +1,6 @@
+// run-rustfix
+#![allow(dead_code)]
+
 struct A {
     b: B,
 }
index a377f8f4deaef9fa75b443972f45d997a2bd66ba..ba7e145c21759acdd3d16a74700e20f61a6224c5 100644 (file)
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/field-access.rs:12:12
+  --> $DIR/field-access.rs:15:12
    |
 LL |     Fst,
    |     --- unit variant defined here
@@ -15,7 +15,7 @@ LL |     if let B::Fst = a.b {};
    |                     ^^^
 
 error[E0308]: mismatched types
-  --> $DIR/field-access.rs:16:9
+  --> $DIR/field-access.rs:19:9
    |
 LL |     Fst,
    |     --- unit variant defined here
@@ -31,7 +31,7 @@ LL |     match a.b {
    |           ^^^
 
 error[E0308]: mismatched types
-  --> $DIR/field-access.rs:17:9
+  --> $DIR/field-access.rs:20:9
    |
 LL |     Snd,
    |     --- unit variant defined here