You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
2
+
--> $DIR/ptr_to_temporary.rs:6:5
3
+
|
4
+
LL | clippy::temporary_cstring_as_ptr,
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
6
+
|
7
+
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
8
+
1
9
error: returning a raw pointer to a temporary value that cannot be promoted to a constant
2
-
--> $DIR/ptr_to_temporary.rs:10:5
10
+
--> $DIR/ptr_to_temporary.rs:22:5
3
11
|
4
12
LL | &(100 + *&0) as *const i32
5
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6
14
|
7
-
= note: usage of this pointer by callers will cause Undefined Behavior
15
+
= note: usage of this pointer by callers will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
8
16
= note: `-D clippy::ptr-to-temporary` implied by `-D warnings`
9
17
10
18
error: returning a raw pointer to a temporary value that cannot be promoted to a constant
11
-
--> $DIR/ptr_to_temporary.rs:15:5
19
+
--> $DIR/ptr_to_temporary.rs:27:5
12
20
|
13
21
LL | &(*&a) as *const i32
14
22
| ^^^^^^^^^^^^^^^^^^^^
15
23
|
16
-
= note: usage of this pointer by callers will cause Undefined Behavior
24
+
= note: usage of this pointer by callers will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
17
25
18
26
error: returning a raw pointer to a temporary value that cannot be promoted to a constant
19
-
--> $DIR/ptr_to_temporary.rs:20:5
27
+
--> $DIR/ptr_to_temporary.rs:32:5
20
28
|
21
29
LL | &a as *const i32
22
30
| ^^^^^^^^^^^^^^^^
23
31
|
24
-
= note: usage of this pointer by callers will cause Undefined Behavior
32
+
= note: usage of this pointer by callers will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
25
33
26
34
error: returning a raw pointer to a temporary value that cannot be promoted to a constant
27
-
--> $DIR/ptr_to_temporary.rs:25:5
35
+
--> $DIR/ptr_to_temporary.rs:37:5
28
36
|
29
37
LL | &a as *const i32
30
38
| ^^^^^^^^^^^^^^^^
31
39
|
32
-
= note: usage of this pointer by callers will cause Undefined Behavior
40
+
= note: usage of this pointer by callers will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
33
41
34
42
error: returning a raw pointer to a temporary value that cannot be promoted to a constant
35
-
--> $DIR/ptr_to_temporary.rs:35:5
43
+
--> $DIR/ptr_to_temporary.rs:47:5
36
44
|
37
45
LL | &a as *const i32
38
46
| ^^^^^^^^^^^^^^^^
39
47
|
40
-
= note: usage of this pointer by callers will cause Undefined Behavior
48
+
= note: usage of this pointer by callers will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
49
+
50
+
error: calling `as_ptr` on a temporary value
51
+
--> $DIR/ptr_to_temporary.rs:51:14
52
+
|
53
+
LL | let pv = vec![1].as_ptr();
54
+
| ^^^^^^^^^^^^^^^^
55
+
|
56
+
= note: usage of this pointer will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
57
+
58
+
error: calling `as_ptr` on a temporary value
59
+
--> $DIR/ptr_to_temporary.rs:63:14
60
+
|
61
+
LL | let pc = Cell::new("oops ub").as_ptr();
62
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
+
|
64
+
= note: usage of this pointer will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
65
+
66
+
error: calling `as_ptr` on a temporary value
67
+
--> $DIR/ptr_to_temporary.rs:67:15
68
+
|
69
+
LL | let prc = RefCell::new("oops more ub").as_ptr();
70
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71
+
|
72
+
= note: usage of this pointer will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
73
+
74
+
error: calling `as_ptr` on a temporary value
75
+
--> $DIR/ptr_to_temporary.rs:71:26
76
+
|
77
+
LL | let pcstr = unsafe { CString::new(vec![]).unwrap().as_ptr() };
78
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79
+
|
80
+
= note: usage of this pointer will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
81
+
82
+
error: calling `as_ptr` on a temporary value
83
+
--> $DIR/ptr_to_temporary.rs:75:24
84
+
|
85
+
LL | let pab = unsafe { AtomicBool::new(true).as_ptr() };
86
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
+
|
88
+
= note: usage of this pointer will cause Undefined Behavior as the temporary will be deallocated at the end of the statement, yet the pointer will continue pointing to it, resulting in a dangling pointer
0 commit comments