about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-15 10:14:52 +0000
committerbors <bors@rust-lang.org>2020-09-15 10:14:52 +0000
commit90b1f5ae59291dd69d72fad41a22277df19dc953 (patch)
tree48be81f25a8a51daf3a29911988d58044341f67f /src
parentc1589cc819ba7cf289c3ccbab30c215f0a6ba7d7 (diff)
parent62effcbd5bfaf74e99def3e9a660dba9728b0b47 (diff)
downloadrust-90b1f5ae59291dd69d72fad41a22277df19dc953.tar.gz
rust-90b1f5ae59291dd69d72fad41a22277df19dc953.zip
Auto merge of #76171 - estebank:turbofish-the-revenge, r=davidtwco
Detect turbofish with multiple type params missing leading `::`

Fix #76072.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/did_you_mean/issue-40396.rs21
-rw-r--r--src/test/ui/did_you_mean/issue-40396.stderr83
2 files changed, 101 insertions, 3 deletions
diff --git a/src/test/ui/did_you_mean/issue-40396.rs b/src/test/ui/did_you_mean/issue-40396.rs
index e4e94bb9492..5497ba2e11f 100644
--- a/src/test/ui/did_you_mean/issue-40396.rs
+++ b/src/test/ui/did_you_mean/issue-40396.rs
@@ -1,8 +1,29 @@
 fn main() {
     (0..13).collect<Vec<i32>>();
     //~^ ERROR comparison operators cannot be chained
+    //~| HELP use `::<...>` instead
     Vec<i32>::new();
     //~^ ERROR comparison operators cannot be chained
+    //~| HELP use `::<...>` instead
     (0..13).collect<Vec<i32>();
     //~^ ERROR comparison operators cannot be chained
+    //~| HELP use `::<...>` instead
+    let x = std::collections::HashMap<i128, i128>::new(); //~ ERROR expected one of
+    //~^ HELP use `::<...>` instead
+    let x: () = 42; //~ ERROR mismatched types
+    let x = {
+        std::collections::HashMap<i128, i128>::new() //~ ERROR expected one of
+        //~^ HELP use `::<...>` instead
+    };
+    let x: () = 42; //~ ERROR mismatched types
+    let x = {
+        std::collections::HashMap<i128, i128>::new(); //~ ERROR expected one of
+        //~^ HELP use `::<...>` instead
+        let x: () = 42; //~ ERROR mismatched types
+    };
+    {
+        std::collections::HashMap<i128, i128>::new(1, 2); //~ ERROR expected one of
+        //~^ HELP use `::<...>` instead
+        let x: () = 32; //~ ERROR mismatched types
+    };
 }
diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr
index 10972697f9f..184bcf0c74b 100644
--- a/src/test/ui/did_you_mean/issue-40396.stderr
+++ b/src/test/ui/did_you_mean/issue-40396.stderr
@@ -10,7 +10,7 @@ LL |     (0..13).collect::<Vec<i32>>();
    |                    ^^
 
 error: comparison operators cannot be chained
-  --> $DIR/issue-40396.rs:4:8
+  --> $DIR/issue-40396.rs:5:8
    |
 LL |     Vec<i32>::new();
    |        ^   ^
@@ -21,7 +21,7 @@ LL |     Vec::<i32>::new();
    |        ^^
 
 error: comparison operators cannot be chained
-  --> $DIR/issue-40396.rs:6:20
+  --> $DIR/issue-40396.rs:8:20
    |
 LL |     (0..13).collect<Vec<i32>();
    |                    ^   ^
@@ -31,5 +31,82 @@ help: use `::<...>` instead of `<...>` to specify type arguments
 LL |     (0..13).collect::<Vec<i32>();
    |                    ^^
 
-error: aborting due to 3 previous errors
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+  --> $DIR/issue-40396.rs:11:43
+   |
+LL |     let x = std::collections::HashMap<i128, i128>::new();
+   |                                           ^ expected one of 7 possible tokens
+   |
+help: use `::<...>` instead of `<...>` to specify type arguments
+   |
+LL |     let x = std::collections::HashMap::<i128, i128>::new();
+   |                                      ^^
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `,`
+  --> $DIR/issue-40396.rs:15:39
+   |
+LL |         std::collections::HashMap<i128, i128>::new()
+   |                                       ^ expected one of 8 possible tokens
+   |
+help: use `::<...>` instead of `<...>` to specify type arguments
+   |
+LL |         std::collections::HashMap::<i128, i128>::new()
+   |                                  ^^
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `,`
+  --> $DIR/issue-40396.rs:20:39
+   |
+LL |         std::collections::HashMap<i128, i128>::new();
+   |                                       ^ expected one of 8 possible tokens
+   |
+help: use `::<...>` instead of `<...>` to specify type arguments
+   |
+LL |         std::collections::HashMap::<i128, i128>::new();
+   |                                  ^^
+
+error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `,`
+  --> $DIR/issue-40396.rs:25:39
+   |
+LL |         std::collections::HashMap<i128, i128>::new(1, 2);
+   |                                       ^ expected one of 8 possible tokens
+   |
+help: use `::<...>` instead of `<...>` to specify type arguments
+   |
+LL |         std::collections::HashMap::<i128, i128>::new(1, 2);
+   |                                  ^^
+
+error[E0308]: mismatched types
+  --> $DIR/issue-40396.rs:13:17
+   |
+LL |     let x: () = 42;
+   |            --   ^^ expected `()`, found integer
+   |            |
+   |            expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/issue-40396.rs:18:17
+   |
+LL |     let x: () = 42;
+   |            --   ^^ expected `()`, found integer
+   |            |
+   |            expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/issue-40396.rs:22:21
+   |
+LL |         let x: () = 42;
+   |                --   ^^ expected `()`, found integer
+   |                |
+   |                expected due to this
+
+error[E0308]: mismatched types
+  --> $DIR/issue-40396.rs:27:21
+   |
+LL |         let x: () = 32;
+   |                --   ^^ expected `()`, found integer
+   |                |
+   |                expected due to this
+
+error: aborting due to 11 previous errors
 
+For more information about this error, try `rustc --explain E0308`.