File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ fn main() {
47
47
let _: *const _ = "foo".as_ptr(); // not a C-string
48
48
let _: *const _ = "".as_ptr();
49
49
let _: *const _ = c"foo".as_ptr().cast::<i8>();
50
+ let _ = "电脑".as_ptr();
51
+ let _ = "电脑\\".as_ptr();
52
+ let _ = c"电脑\\".as_ptr();
53
+ let _ = c"电脑".as_ptr();
54
+ let _ = c"电脑".as_ptr();
50
55
51
56
// Macro cases, don't lint:
52
57
cstr!("foo");
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ fn main() {
47
47
let _: * const _ = "foo" . as_ptr ( ) ; // not a C-string
48
48
let _: * const _ = "" . as_ptr ( ) ;
49
49
let _: * const _ = b"foo\0 " . as_ptr ( ) . cast :: < i8 > ( ) ;
50
+ let _ = "电脑" . as_ptr ( ) ;
51
+ let _ = "电脑\\ " . as_ptr ( ) ;
52
+ let _ = "电脑\\ \0 " . as_ptr ( ) ;
53
+ let _ = "电脑\0 " . as_ptr ( ) ;
54
+ let _ = "电脑\x00 " . as_ptr ( ) ;
50
55
51
56
// Macro cases, don't lint:
52
57
cstr ! ( "foo" ) ;
Original file line number Diff line number Diff line change @@ -61,5 +61,23 @@ error: manually constructing a nul-terminated string
61
61
LL | let _: *const _ = b"foo\0".as_ptr().cast::<i8>();
62
62
| ^^^^^^^^ help: use a `c""` literal: `c"foo"`
63
63
64
- error: aborting due to 10 previous errors
64
+ error: manually constructing a nul-terminated string
65
+ --> $DIR/manual_c_str_literals.rs:52:13
66
+ |
67
+ LL | let _ = "电脑\\\0".as_ptr();
68
+ | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑\\"`
69
+
70
+ error: manually constructing a nul-terminated string
71
+ --> $DIR/manual_c_str_literals.rs:53:13
72
+ |
73
+ LL | let _ = "电脑\0".as_ptr();
74
+ | ^^^^^^^^ help: use a `c""` literal: `c"电脑"`
75
+
76
+ error: manually constructing a nul-terminated string
77
+ --> $DIR/manual_c_str_literals.rs:54:13
78
+ |
79
+ LL | let _ = "电脑\x00".as_ptr();
80
+ | ^^^^^^^^^^ help: use a `c""` literal: `c"电脑"`
81
+
82
+ error: aborting due to 13 previous errors
65
83
You can’t perform that action at this time.
0 commit comments