-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also lint some
as_ptr
methods as well
- Loading branch information
Showing
4 changed files
with
239 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,91 @@ | ||
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` | ||
Check failure on line 1 in tests/ui/ptr_to_temporary.stderr GitHub Actions / baseactual output differs from expected
|
||
--> $DIR/ptr_to_temporary.rs:6:5 | ||
| | ||
LL | clippy::temporary_cstring_as_ptr, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` | ||
| | ||
= note: `-D renamed-and-removed-lints` implied by `-D warnings` | ||
|
||
error: returning a raw pointer to a temporary value that cannot be promoted to a constant | ||
--> $DIR/ptr_to_temporary.rs:10:5 | ||
--> $DIR/ptr_to_temporary.rs:22:5 | ||
| | ||
LL | &(100 + *&0) as *const i32 | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: usage of this pointer by callers will cause Undefined Behavior | ||
= 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 | ||
= note: `-D clippy::ptr-to-temporary` implied by `-D warnings` | ||
|
||
error: returning a raw pointer to a temporary value that cannot be promoted to a constant | ||
--> $DIR/ptr_to_temporary.rs:15:5 | ||
--> $DIR/ptr_to_temporary.rs:27:5 | ||
| | ||
LL | &(*&a) as *const i32 | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: usage of this pointer by callers will cause Undefined Behavior | ||
= 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 | ||
|
||
error: returning a raw pointer to a temporary value that cannot be promoted to a constant | ||
--> $DIR/ptr_to_temporary.rs:20:5 | ||
--> $DIR/ptr_to_temporary.rs:32:5 | ||
| | ||
LL | &a as *const i32 | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: usage of this pointer by callers will cause Undefined Behavior | ||
= 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 | ||
|
||
error: returning a raw pointer to a temporary value that cannot be promoted to a constant | ||
--> $DIR/ptr_to_temporary.rs:25:5 | ||
--> $DIR/ptr_to_temporary.rs:37:5 | ||
| | ||
LL | &a as *const i32 | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: usage of this pointer by callers will cause Undefined Behavior | ||
= 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 | ||
|
||
error: returning a raw pointer to a temporary value that cannot be promoted to a constant | ||
--> $DIR/ptr_to_temporary.rs:35:5 | ||
--> $DIR/ptr_to_temporary.rs:47:5 | ||
| | ||
LL | &a as *const i32 | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: usage of this pointer by callers will cause Undefined Behavior | ||
= 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 | ||
|
||
error: calling `as_ptr` on a temporary value | ||
--> $DIR/ptr_to_temporary.rs:51:14 | ||
| | ||
LL | let pv = vec![1].as_ptr(); | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
||
error: calling `as_ptr` on a temporary value | ||
--> $DIR/ptr_to_temporary.rs:63:14 | ||
| | ||
LL | let pc = Cell::new("oops ub").as_ptr(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
||
error: calling `as_ptr` on a temporary value | ||
--> $DIR/ptr_to_temporary.rs:67:15 | ||
| | ||
LL | let prc = RefCell::new("oops more ub").as_ptr(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
||
error: calling `as_ptr` on a temporary value | ||
--> $DIR/ptr_to_temporary.rs:71:26 | ||
| | ||
LL | let pcstr = unsafe { CString::new(vec![]).unwrap().as_ptr() }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
||
error: calling `as_ptr` on a temporary value | ||
--> $DIR/ptr_to_temporary.rs:75:24 | ||
| | ||
LL | let pab = unsafe { AtomicBool::new(true).as_ptr() }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
||
error: aborting due to 5 previous errors | ||
error: aborting due to 11 previous errors | ||
|