Skip to content

Commit 35bdb94

Browse files
committed
Move concat test to ui and unify with new test
1 parent 29a63fb commit 35bdb94

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

src/test/compile-fail/concat.rs

-16
This file was deleted.

src/test/ui/byte-concat.stderr

-18
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -9,7 +9,14 @@
99
// except according to those terms.
1010

1111
fn main() {
12-
let _ = concat!(b"abc", b"def");
13-
let _ = concat!("abc", b"def", "ghi", b"jkl");
12+
concat!(b'f'); // b'' concat is supported
13+
concat!(b"foo"); // b"" concat is supported
14+
concat!(foo);
15+
//~^ ERROR: expected a literal
16+
concat!(foo());
17+
//~^ ERROR: expected a literal
18+
concat!(b'a', b"bc", b"def");
19+
concat!("abc", b"def", 'g', "hi", b"jkl");
1420
//~^ ERROR cannot concatenate a byte string literal with string literals
21+
// `concat!()` cannot mix "" and b"" literals (it might allow it in the future)
1522
}

src/test/ui/concat.stderr

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error: expected a literal
2+
--> $DIR/concat.rs:14:13
3+
|
4+
LL | concat!(foo);
5+
| ^^^
6+
|
7+
= note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()`
8+
9+
error: expected a literal
10+
--> $DIR/concat.rs:16:13
11+
|
12+
LL | concat!(foo());
13+
| ^^^^^
14+
|
15+
= note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()`
16+
17+
error: cannot concatenate a byte string literal with string literals
18+
--> $DIR/concat.rs:19:20
19+
|
20+
LL | concat!("abc", b"def", 'g', "hi", b"jkl");
21+
| ----- ^^^^^^ --- ---- ^^^^^^ byte string literal
22+
| | | | |
23+
| | | | string literal
24+
| | | string literal
25+
| | byte string literal
26+
| string literal
27+
|
28+
= help: do not mix byte string literals and string literals
29+
help: you can use byte string literals
30+
|
31+
LL | concat!(b"abc", b"def", b'g', b"hi", b"jkl");
32+
| ^ ^ ^
33+
34+
error: aborting due to 3 previous errors
35+

0 commit comments

Comments
 (0)