about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-17 15:27:29 +0000
committerbors <bors@rust-lang.org>2020-11-17 15:27:29 +0000
commitc919f490bbcd2b29b74016101f7ec71aaa24bdbb (patch)
treece8406ee4a726bc8db7c864518f3d8ea16ea8c6e /src/test
parente0ef0fc392963438af5f0343bf7caa46fb9c3ec3 (diff)
parentf698505177eb1853b3d905bbe1005140acd50d53 (diff)
downloadrust-c919f490bbcd2b29b74016101f7ec71aaa24bdbb.tar.gz
rust-c919f490bbcd2b29b74016101f7ec71aaa24bdbb.zip
Auto merge of #79138 - m-ou-se:rollup-owel5ld, r=m-ou-se
Rollup of 8 pull requests

Successful merges:

 - #74293 (Rustdoc test compiler output color)
 - #78702 ([self-profiling] Include the estimated size of each cgu in the profile)
 - #79069 (Get rid of `highlight::Class::None`)
 - #79072 (Fix exhaustiveness in case a byte string literal is used at slice type)
 - #79120 (update rustfmt to v1.4.27)
 - #79125 (Get rid of clean::{Method, TyMethod})
 - #79126 (Remove duplicate `Trait::auto` field)
 - #79130 (extend macro braces test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/const-generics/macro_rules-braces.full.stderr13
-rw-r--r--src/test/ui/const-generics/macro_rules-braces.min.stderr13
-rw-r--r--src/test/ui/const-generics/macro_rules-braces.rs20
-rw-r--r--src/test/ui/match/type_polymorphic_byte_str_literals.rs36
-rw-r--r--src/test/ui/match/type_polymorphic_byte_str_literals.stderr21
-rw-r--r--src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr4
6 files changed, 103 insertions, 4 deletions
diff --git a/src/test/ui/const-generics/macro_rules-braces.full.stderr b/src/test/ui/const-generics/macro_rules-braces.full.stderr
index f6e9aabd907..e5b67f61a25 100644
--- a/src/test/ui/const-generics/macro_rules-braces.full.stderr
+++ b/src/test/ui/const-generics/macro_rules-braces.full.stderr
@@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
 LL |     let _: baz!({ N });
    |                 ^   ^
 
+error: expressions must be enclosed in braces to be used as const generic arguments
+  --> $DIR/macro_rules-braces.rs:54:17
+   |
+LL |     let _: baz!(10 + 7);
+   |                 ^^^^^^
+   |
+help: enclose the `const` expression in braces
+   |
+LL |     let _: baz!({ 10 + 7 });
+   |                 ^        ^
+
 error: constant expression depends on a generic parameter
   --> $DIR/macro_rules-braces.rs:10:13
    |
@@ -57,5 +68,5 @@ LL |     let _: biz!({ N });
    = note: this may fail depending on what value the parameter takes
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 5 previous errors
+error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/const-generics/macro_rules-braces.min.stderr b/src/test/ui/const-generics/macro_rules-braces.min.stderr
index 1fe18e3fc02..a4ef732017d 100644
--- a/src/test/ui/const-generics/macro_rules-braces.min.stderr
+++ b/src/test/ui/const-generics/macro_rules-braces.min.stderr
@@ -9,6 +9,17 @@ help: enclose the `const` expression in braces
 LL |     let _: baz!({ N });
    |                 ^   ^
 
+error: expressions must be enclosed in braces to be used as const generic arguments
+  --> $DIR/macro_rules-braces.rs:54:17
+   |
+LL |     let _: baz!(10 + 7);
+   |                 ^^^^^^
+   |
+help: enclose the `const` expression in braces
+   |
+LL |     let _: baz!({ 10 + 7 });
+   |                 ^        ^
+
 error: generic parameters may not be used in const operations
   --> $DIR/macro_rules-braces.rs:31:20
    |
@@ -41,5 +52,5 @@ LL |     let _: biz!({ N });
    |
    = help: const parameters may only be used as standalone arguments, i.e. `N`
 
-error: aborting due to 5 previous errors
+error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/const-generics/macro_rules-braces.rs b/src/test/ui/const-generics/macro_rules-braces.rs
index c3e2c8ba203..bc67d464f11 100644
--- a/src/test/ui/const-generics/macro_rules-braces.rs
+++ b/src/test/ui/const-generics/macro_rules-braces.rs
@@ -36,6 +36,26 @@ fn test<const N: usize>() {
     let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
     let _: biz!(N);
     let _: biz!({ N }); //[min]~ ERROR generic parameters may not
+    let _: foo!(3);
+    let _: foo!({ 3 });
+    let _: foo!({{ 3 }});
+    let _: bar!(3);
+    let _: bar!({ 3 });
+    let _: baz!(3);
+    let _: baz!({ 3 });
+    let _: baz!({{ 3 }});
+    let _: biz!(3);
+    let _: biz!({ 3 });
+    let _: foo!(10 + 7);
+    let _: foo!({ 10 + 7 });
+    let _: foo!({{ 10 + 7 }});
+    let _: bar!(10 + 7);
+    let _: bar!({ 10 + 7 });
+    let _: baz!(10 + 7); //~ ERROR expressions must be enclosed in braces
+    let _: baz!({ 10 + 7 });
+    let _: baz!({{ 10 + 7 }});
+    let _: biz!(10 + 7);
+    let _: biz!({ 10 + 7 });
 }
 
 fn main() {
diff --git a/src/test/ui/match/type_polymorphic_byte_str_literals.rs b/src/test/ui/match/type_polymorphic_byte_str_literals.rs
new file mode 100644
index 00000000000..cb44c1da76b
--- /dev/null
+++ b/src/test/ui/match/type_polymorphic_byte_str_literals.rs
@@ -0,0 +1,36 @@
+#[deny(unreachable_patterns)]
+
+fn parse_data1(data: &[u8]) -> u32 {
+    match data {
+        b"" => 1,
+        _ => 2,
+    }
+}
+
+fn parse_data2(data: &[u8]) -> u32 {
+    match data { //~ ERROR non-exhaustive patterns: `&[_, ..]` not covered
+        b"" => 1,
+    }
+}
+
+fn parse_data3(data: &[u8; 0]) -> u8 {
+    match data {
+        b"" => 1,
+    }
+}
+
+fn parse_data4(data: &[u8]) -> u8 {
+    match data { //~ ERROR non-exhaustive patterns
+        b"aaa" => 0,
+        [_, _, _] => 1,
+    }
+}
+
+fn parse_data5(data: &[u8; 3]) -> u8 {
+    match data {
+        b"aaa" => 0,
+        [_, _, _] => 1,
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/match/type_polymorphic_byte_str_literals.stderr b/src/test/ui/match/type_polymorphic_byte_str_literals.stderr
new file mode 100644
index 00000000000..6ce53a4f21e
--- /dev/null
+++ b/src/test/ui/match/type_polymorphic_byte_str_literals.stderr
@@ -0,0 +1,21 @@
+error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
+  --> $DIR/type_polymorphic_byte_str_literals.rs:11:11
+   |
+LL |     match data {
+   |           ^^^^ pattern `&[_, ..]` not covered
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+   = note: the matched value is of type `&[u8]`
+
+error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 1 more not covered
+  --> $DIR/type_polymorphic_byte_str_literals.rs:23:11
+   |
+LL |     match data {
+   |           ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+   = note: the matched value is of type `&[u8]`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
index 7968f9713ff..ffc8433403f 100644
--- a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
+++ b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
@@ -7,11 +7,11 @@ LL |     match buf {
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
    = note: the matched value is of type `&[u8; 4]`
 
-error[E0004]: non-exhaustive patterns: `&[0_u8..=64_u8, _, _, _]` and `&[66_u8..=u8::MAX, _, _, _]` not covered
+error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 2 more not covered
   --> $DIR/match-byte-array-patterns-2.rs:10:11
    |
 LL |     match buf {
-   |           ^^^ patterns `&[0_u8..=64_u8, _, _, _]` and `&[66_u8..=u8::MAX, _, _, _]` not covered
+   |           ^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 2 more not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
    = note: the matched value is of type `&[u8]`