File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ fn main() {
4747 let _: *const _ = "foo".as_ptr(); // not a C-string
4848 let _: *const _ = "".as_ptr();
4949 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();
5055
5156 // Macro cases, don't lint:
5257 cstr!("foo");
Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ fn main() {
4747 let _: * const _ = "foo" . as_ptr ( ) ; // not a C-string
4848 let _: * const _ = "" . as_ptr ( ) ;
4949 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 ( ) ;
5055
5156 // Macro cases, don't lint:
5257 cstr ! ( "foo" ) ;
Original file line number Diff line number Diff line change @@ -61,5 +61,23 @@ error: manually constructing a nul-terminated string
6161LL | let _: *const _ = b"foo\0".as_ptr().cast::<i8>();
6262 | ^^^^^^^^ help: use a `c""` literal: `c"foo"`
6363
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
6583
You can’t perform that action at this time.
0 commit comments