about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-11-12 11:31:51 +0100
committerGitHub <noreply@github.com>2020-11-12 11:31:51 +0100
commita2e9e3b6af8fe4b4e32a8406c87ed6849c9797e5 (patch)
tree34d61d0d017885e470c2a6bed012aa9b7fb99920
parentd3244df6b6b7d834d5ba4ac0e7fa7c6be82918a5 (diff)
parent1d3f9d030bcde5e3e5dec3ed4787996a13bf01a6 (diff)
downloadrust-a2e9e3b6af8fe4b4e32a8406c87ed6849c9797e5.tar.gz
rust-a2e9e3b6af8fe4b4e32a8406c87ed6849c9797e5.zip
Rollup merge of #78960 - ethanboxx:const-gen-test-default-error, r=lcnr
Test default values for const parameters.

The last topic on #78433

I originally intended to place these tests in a single file, however, due to them being parser errors that are fatal, they must be in separate files to be detected.

Thanks, ``@lcnr`` for mentoring me on this PR.

r? ``@lcnr``
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_function_param.rs6
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_function_param.stderr8
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_trait_param.rs6
-rw-r--r--src/test/ui/const-generics/min_const_generics/default_trait_param.stderr8
4 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs
new file mode 100644
index 00000000000..7e0c1c2ed9f
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs
@@ -0,0 +1,6 @@
+#![feature(min_const_generics)]
+
+fn foo<const SIZE: usize = 5>() {}
+                      //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
+
+fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr
new file mode 100644
index 00000000000..ed1a83b6a4d
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
+  --> $DIR/default_function_param.rs:3:26
+   |
+LL | fn foo<const SIZE: usize = 5>() {}
+   |                          ^ expected one of 7 possible tokens
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.rs b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs
new file mode 100644
index 00000000000..322ddccbf18
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.rs
@@ -0,0 +1,6 @@
+#![feature(min_const_generics)]
+
+trait Foo<const KIND: bool = true> {}
+                        //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
+
+fn main() {}
diff --git a/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr
new file mode 100644
index 00000000000..49c3ac86744
--- /dev/null
+++ b/src/test/ui/const-generics/min_const_generics/default_trait_param.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `=`
+  --> $DIR/default_trait_param.rs:3:28
+   |
+LL | trait Foo<const KIND: bool = true> {}
+   |                            ^ expected one of 7 possible tokens
+
+error: aborting due to previous error
+