File tree Expand file tree Collapse file tree 4 files changed +30
-21
lines changed Expand file tree Collapse file tree 4 files changed +30
-21
lines changed Original file line number Diff line number Diff line change
1
+ fn main ( ) { }
2
+
3
+ #[ allow( result_unwrap_used) ]
4
+ fn temporary_cstring ( ) {
5
+ use std:: ffi:: CString ;
6
+
7
+ CString :: new ( "foo" ) . unwrap ( ) . as_ptr ( ) ;
8
+ }
Original file line number Diff line number Diff line change
1
+ error: function is never used: `temporary_cstring`
2
+ --> $DIR/cstring.rs:4:1
3
+ |
4
+ 4 | fn temporary_cstring() {
5
+ | ^^^^^^^^^^^^^^^^^^^^^^
6
+ |
7
+ = note: `-D dead-code` implied by `-D warnings`
8
+
9
+ error: you are getting the inner pointer of a temporary `CString`
10
+ --> $DIR/cstring.rs:7:5
11
+ |
12
+ 7 | CString::new("foo").unwrap().as_ptr();
13
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
+ |
15
+ = note: `-D temporary-cstring-as-ptr` implied by `-D warnings`
16
+ = note: that pointer will be invalid outside this expression
17
+ help: assign the `CString` to a variable to extend its lifetime
18
+ --> $DIR/cstring.rs:7:5
19
+ |
20
+ 7 | CString::new("foo").unwrap().as_ptr();
21
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
+
Original file line number Diff line number Diff line change @@ -453,10 +453,3 @@ fn str_extend_chars() {
453
453
let f = HasChars ;
454
454
s. extend ( f. chars ( ) ) ;
455
455
}
456
-
457
- #[ allow( result_unwrap_used) ]
458
- fn temporary_cstring ( ) {
459
- use std:: ffi:: CString ;
460
-
461
- CString :: new ( "foo" ) . unwrap ( ) . as_ptr ( ) ;
462
- }
Original file line number Diff line number Diff line change @@ -567,17 +567,3 @@ error: calling `.extend(_.chars())`
567
567
447 | s.extend(def.chars());
568
568
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)`
569
569
570
- error: you are getting the inner pointer of a temporary `CString`
571
- --> $DIR/methods.rs:461:5
572
- |
573
- 461 | CString::new("foo").unwrap().as_ptr();
574
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
575
- |
576
- = note: `-D temporary-cstring-as-ptr` implied by `-D warnings`
577
- = note: that pointer will be invalid outside this expression
578
- help: assign the `CString` to a variable to extend its lifetime
579
- --> $DIR/methods.rs:461:5
580
- |
581
- 461 | CString::new("foo").unwrap().as_ptr();
582
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
583
-
You can’t perform that action at this time.
0 commit comments