]> git.lizzy.rs Git - rust.git/commitdiff
Add tests checking taht "priority" of qpath recovery is higher than unary and binary...
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Mon, 18 Dec 2017 20:42:58 +0000 (23:42 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Wed, 20 Dec 2017 19:43:47 +0000 (22:43 +0300)
src/test/ui/did_you_mean/bad-assoc-expr.rs
src/test/ui/did_you_mean/bad-assoc-expr.stderr
src/test/ui/did_you_mean/bad-assoc-pat.rs
src/test/ui/did_you_mean/bad-assoc-pat.stderr
src/test/ui/did_you_mean/bad-assoc-ty.rs
src/test/ui/did_you_mean/bad-assoc-ty.stderr

index 72b616ddd69c61075c20467c903cceafb126ab58..779aa952c81b9d0848c34355f8aa4aebfcb2e399 100644 (file)
@@ -21,4 +21,10 @@ fn main() {
 
     (u8, u8)::clone(&(0, 0));
     //~^ ERROR missing angle brackets in associated item path
+
+    &(u8)::clone(&0);
+    //~^ ERROR missing angle brackets in associated item path
+
+    10 + (u8)::clone(&0);
+    //~^ ERROR missing angle brackets in associated item path
 }
index 1f8fc118f78a130ddb8301e12328c4f463088d7a..1affdc5fda208965baab0b33f5fcc0a9874c5d17 100644 (file)
@@ -22,5 +22,17 @@ error: missing angle brackets in associated item path
 22 |     (u8, u8)::clone(&(0, 0));
    |     ^^^^^^^^^^^^^^^ help: try: `<(u8, u8)>::clone`
 
-error: aborting due to 4 previous errors
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-expr.rs:25:6
+   |
+25 |     &(u8)::clone(&0);
+   |      ^^^^^^^^^^^ help: try: `<(u8)>::clone`
+
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-expr.rs:28:10
+   |
+28 |     10 + (u8)::clone(&0);
+   |          ^^^^^^^^^^^ help: try: `<(u8)>::clone`
+
+error: aborting due to 6 previous errors
 
index e6b7127f1005262a7304f5616040b1f92da2903b..bf6be0ee98545c9749672222438346791ecb9fb2 100644 (file)
@@ -20,4 +20,9 @@ fn main() {
         //~^ ERROR missing angle brackets in associated item path
         //~| ERROR no associated item named `AssocItem` found for type `_` in the current scope
     }
+    match &0u8 {
+        &(u8,)::AssocItem => {}
+        //~^ ERROR missing angle brackets in associated item path
+        //~| ERROR no associated item named `AssocItem` found for type `(u8,)` in the current scope
+    }
 }
index 20f9b96dbaa792f7d34a7435b59440d238bc71bb..1ca4576d88f609203ec8359d0a0bbfdd2708074f 100644 (file)
@@ -16,6 +16,12 @@ error: missing angle brackets in associated item path
 19 |         _::AssocItem => {}
    |         ^^^^^^^^^^^^ help: try: `<_>::AssocItem`
 
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-pat.rs:24:10
+   |
+24 |         &(u8,)::AssocItem => {}
+   |          ^^^^^^^^^^^^^^^^ help: try: `<(u8,)>::AssocItem`
+
 error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the current scope
   --> $DIR/bad-assoc-pat.rs:13:9
    |
@@ -34,5 +40,11 @@ error[E0599]: no associated item named `AssocItem` found for type `_` in the cur
 19 |         _::AssocItem => {}
    |         ^^^^^^^^^^^^ associated item not found in `_`
 
-error: aborting due to 6 previous errors
+error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope
+  --> $DIR/bad-assoc-pat.rs:24:10
+   |
+24 |         &(u8,)::AssocItem => {}
+   |          ^^^^^^^^^^^^^^^^ associated item not found in `(u8,)`
+
+error: aborting due to 8 previous errors
 
index 45a52936738823719b39ca4d1fc1dcc664b11d07..74305b73f99c0ab337517871c4f523086df3eac3 100644 (file)
 //~^ ERROR missing angle brackets in associated item path
 //~| ERROR the type placeholder `_` is not allowed within types on item signatures
 
+type F = &'static (u8)::AssocTy;
+//~^ ERROR missing angle brackets in associated item path
+//~| ERROR ambiguous associated type
+
+// Qualified paths cannot appear in bounds, so the recovery
+// should apply to the whole sum and not `(Send)`.
+type G = 'static + (Send)::AssocTy;
+//~^ ERROR missing angle brackets in associated item path
+//~| ERROR ambiguous associated type
+
+// FIXME
+// This is actually a legal path with fn-like generic arguments in the middle!
+// Recovery should not apply in this context.
+type H = Fn(u8) -> (u8)::Output;
+//~^ ERROR missing angle brackets in associated item path
+//~| ERROR ambiguous associated type
+
 fn main() {}
index 617339a7d92d664feea42beb446b22d6f6ee490b..a11be411fed9d1017c8aee776ed9f1db8f21c542 100644 (file)
@@ -28,6 +28,24 @@ error: missing angle brackets in associated item path
 27 | type E = _::AssocTy;
    |          ^^^^^^^^^^ help: try: `<_>::AssocTy`
 
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-ty.rs:31:19
+   |
+31 | type F = &'static (u8)::AssocTy;
+   |                   ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy`
+
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-ty.rs:37:10
+   |
+37 | type G = 'static + (Send)::AssocTy;
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `< 'static + Send>::AssocTy`
+
+error: missing angle brackets in associated item path
+  --> $DIR/bad-assoc-ty.rs:44:20
+   |
+44 | type H = Fn(u8) -> (u8)::Output;
+   |                    ^^^^^^^^^^^^ help: try: `<(u8)>::Output`
+
 error[E0223]: ambiguous associated type
   --> $DIR/bad-assoc-ty.rs:11:10
    |
@@ -66,5 +84,29 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa
 27 | type E = _::AssocTy;
    |          ^ not allowed in type signatures
 
-error: aborting due to 10 previous errors
+error[E0223]: ambiguous associated type
+  --> $DIR/bad-assoc-ty.rs:31:19
+   |
+31 | type F = &'static (u8)::AssocTy;
+   |                   ^^^^^^^^^^^^^ ambiguous associated type
+   |
+   = note: specify the type using the syntax `<u8 as Trait>::AssocTy`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/bad-assoc-ty.rs:37:10
+   |
+37 | type G = 'static + (Send)::AssocTy;
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
+   |
+   = note: specify the type using the syntax `<std::marker::Send + 'static as Trait>::AssocTy`
+
+error[E0223]: ambiguous associated type
+  --> $DIR/bad-assoc-ty.rs:44:20
+   |
+44 | type H = Fn(u8) -> (u8)::Output;
+   |                    ^^^^^^^^^^^^ ambiguous associated type
+   |
+   = note: specify the type using the syntax `<u8 as Trait>::Output`
+
+error: aborting due to 16 previous errors