]> git.lizzy.rs Git - rust.git/commitdiff
Accept parenthesized type args for error recovery
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 20 Jan 2019 02:44:20 +0000 (18:44 -0800)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 20 Jan 2019 03:27:49 +0000 (19:27 -0800)
src/librustc/hir/lowering.rs
src/libsyntax/ast.rs
src/test/ui/error-codes/E0214.stderr
src/test/ui/issues/issue-23589.rs
src/test/ui/issues/issue-23589.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-3.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.rs

index b8aeb6032ba65d7afab0e4fdeda66c945d0ffdc9..b7624b09eeea97d3e7b506b9fbfa8a63dee551f6 100644 (file)
@@ -1826,7 +1826,11 @@ fn lower_path_segment(
                         struct_span_err!(self.sess, data.span, E0214, "{}", msg)
                             .span_label(data.span, "only traits may use parentheses")
                             .emit();
-                        (hir::GenericArgs::none(), false)
+                        (self.lower_angle_bracketed_parameter_data(
+                            &data.as_angle_bracketed_args(),
+                            param_mode,
+                            itctx).0,
+                         false)
                     }
                 },
             }
index bbcaaacbab52337380f17da188adaa78bc520346..d57f9247c0520f3bd995fca9d1e53bb0b5feff32 100644 (file)
@@ -192,6 +192,16 @@ pub struct ParenthesisedArgs {
     pub output: Option<P<Ty>>,
 }
 
+impl ParenthesisedArgs {
+    pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
+        AngleBracketedArgs {
+            span: self.span,
+            args: self.inputs.iter().cloned().map(|input| GenericArg::Type(input)).collect(),
+            bindings: vec![],
+        }
+    }
+}
+
 // hack to ensure that we don't try to access the private parts of `NodeId` in this module
 mod node_id_inner {
     use rustc_data_structures::indexed_vec::Idx;
index f87502efe1b10ac3b40faed202af61ae45d1e7d2..08a98b1c3bf3def31cf86e50a32aa7b02939e5e3 100644 (file)
@@ -4,13 +4,6 @@ error[E0214]: parenthesized parameters may only be used with a trait
 LL |     let v: Vec(&str) = vec!["foo"];
    |               ^^^^^^ only traits may use parentheses
 
-error[E0107]: wrong number of type arguments: expected 1, found 0
-  --> $DIR/E0214.rs:2:12
-   |
-LL |     let v: Vec(&str) = vec!["foo"];
-   |            ^^^^^^^^^ expected 1 type argument
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
-Some errors occurred: E0107, E0214.
-For more information about an error, try `rustc --explain E0107`.
+For more information about this error, try `rustc --explain E0214`.
index a59710a1a3cdeb3db06ba7a3354280e413b7c208..fb765e453dcd64b7826c7c8bdb8304002a18037b 100644 (file)
@@ -1,4 +1,5 @@
 fn main() {
     let v: Vec(&str) = vec!['1', '2'];
     //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| ERROR mismatched types
 }
index 15f2c524a7a9f25aedf9f15a0366723fdf268bdc..c71061606df51e2ad11fef9b40efaaabc72c6662 100644 (file)
@@ -4,13 +4,16 @@ error[E0214]: parenthesized parameters may only be used with a trait
 LL |     let v: Vec(&str) = vec!['1', '2'];
    |               ^^^^^^ only traits may use parentheses
 
-error[E0107]: wrong number of type arguments: expected 1, found 0
-  --> $DIR/issue-23589.rs:2:12
+error[E0308]: mismatched types
+  --> $DIR/issue-23589.rs:2:29
    |
 LL |     let v: Vec(&str) = vec!['1', '2'];
-   |            ^^^^^^^^^ expected 1 type argument
+   |                             ^^^ expected &str, found char
+   |
+   = note: expected type `&str`
+              found type `char`
 
 error: aborting due to 2 previous errors
 
-Some errors occurred: E0107, E0214.
-For more information about an error, try `rustc --explain E0107`.
+Some errors occurred: E0214, E0308.
+For more information about an error, try `rustc --explain E0214`.
index 5387dcb218cb92e5cf90af8b21a968b75fb89676..2827e6eead5fd160218a5d3643415f2d26520898 100644 (file)
@@ -7,6 +7,7 @@ struct Bar<A> {
 fn bar() {
     let x: Box<Bar()> = panic!();
     //~^ ERROR parenthesized parameters may only be used with a trait
+    //~| ERROR wrong number of type arguments: expected 1, found 0
 }
 
 fn main() { }
index b4f7a97c3e5fb8213927e9887e1298a8a374ec1a..395f6596cfd838987fb9757950c3b2a511876864 100644 (file)
@@ -4,13 +4,6 @@ error[E0214]: parenthesized parameters may only be used with a trait
 LL |     let b = Bar::(isize, usize)::new(); // OK too (for the parser)
    |                ^^^^^^^^^^^^^^^^ only traits may use parentheses
 
-error[E0107]: wrong number of type arguments: expected 2, found 0
-  --> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:14:13
-   |
-LL |     let b = Bar::(isize, usize)::new(); // OK too (for the parser)
-   |             ^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 type arguments
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
-Some errors occurred: E0107, E0214.
-For more information about an error, try `rustc --explain E0107`.
+For more information about this error, try `rustc --explain E0214`.
index e795650447cc40b643ecd9a997d997de47df2858..6da53585c9c4c7042dacec8260a23b5f307153d1 100644 (file)
@@ -6,7 +6,7 @@ struct Bar<A> {
 
 fn foo(b: Box<Bar()>) {
     //~^ ERROR parenthesized parameters may only be used with a trait
-    //~| ERROR the type placeholder `_` is not allowed within types on item signatures
+    //~| ERROR wrong number of type arguments: expected 1, found 0
 }
 
 fn main() { }