about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-02-16 13:03:58 +0000
committervarkor <github@varkor.com>2019-02-16 13:03:58 +0000
commit425fb58cacb9dbded92e46ee1bdeaa9dda4a219e (patch)
tree59343aa4461b52f4e139406cbe60dabb527b4144
parent2a1b6c52d34aa021a3930fdea954b3228fba0f71 (diff)
downloadrust-425fb58cacb9dbded92e46ee1bdeaa9dda4a219e.tar.gz
rust-425fb58cacb9dbded92e46ee1bdeaa9dda4a219e.zip
Don't abort early when collecting const generics
-rw-r--r--src/librustc_typeck/collect.rs5
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.rs1
-rw-r--r--src/test/ui/const-generics/const-param-before-other-params.stderr8
-rw-r--r--src/test/ui/feature-gates/feature-gate-const_generics.rs1
-rw-r--r--src/test/ui/feature-gates/feature-gate-const_generics.stderr8
5 files changed, 19 insertions, 4 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 8f382243bb5..84de38beafa 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -1053,12 +1053,13 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty
                         );
                     }
 
+                    // Emit an error, but skip the parameter rather than aborting to
+                    // continue to get other errors.
                     tcx.sess.struct_span_err(
                         param.span,
                         "const generics in any position are currently unsupported",
                     ).emit();
-                    tcx.sess.abort_if_errors();
-                    bug!();
+                    None
                 }
                 _ => None,
             }),
diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs
index 3f120cbc4d3..47f826789e0 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.rs
+++ b/src/test/ui/const-generics/const-param-before-other-params.rs
@@ -8,6 +8,7 @@ fn foo<const X: (), T>(_: T) {
 
 fn bar<const X: (), 'a>(_: &'a ()) {
     //~^ ERROR lifetime parameters must be declared prior to const parameters
+    //~^^ ERROR const generics in any position are currently unsupported
 }
 
 fn main() {}
diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.stderr
index aedcaf52e26..a43415d0e5a 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.stderr
+++ b/src/test/ui/const-generics/const-param-before-other-params.stderr
@@ -22,5 +22,11 @@ error: const generics in any position are currently unsupported
 LL | fn foo<const X: (), T>(_: T) {
    |              ^
 
-error: aborting due to 3 previous errors
+error: const generics in any position are currently unsupported
+  --> $DIR/const-param-before-other-params.rs:9:14
+   |
+LL | fn bar<const X: (), 'a>(_: &'a ()) {
+   |              ^
+
+error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.rs b/src/test/ui/feature-gates/feature-gate-const_generics.rs
index a8a4ed57722..907e00b11e5 100644
--- a/src/test/ui/feature-gates/feature-gate-const_generics.rs
+++ b/src/test/ui/feature-gates/feature-gate-const_generics.rs
@@ -2,5 +2,6 @@ fn foo<const X: ()>() {} //~ ERROR const generics are unstable
 //~^ const generics in any position are currently unsupported
 
 struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
+//~^ const generics in any position are currently unsupported
 
 fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.stderr b/src/test/ui/feature-gates/feature-gate-const_generics.stderr
index 905cc07b6a1..3ab1aa2367f 100644
--- a/src/test/ui/feature-gates/feature-gate-const_generics.stderr
+++ b/src/test/ui/feature-gates/feature-gate-const_generics.stderr
@@ -20,6 +20,12 @@ error: const generics in any position are currently unsupported
 LL | fn foo<const X: ()>() {} //~ ERROR const generics are unstable
    |              ^
 
-error: aborting due to 3 previous errors
+error: const generics in any position are currently unsupported
+  --> $DIR/feature-gate-const_generics.rs:4:18
+   |
+LL | struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
+   |                  ^
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0658`.