Change to warn by default / fix typo
This commit is contained in:
parent
5643a0662a
commit
737bfeffd2
4 changed files with 9 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// ignore-tidy-linelength
|
||||
#![deny(temporary_cstring_as_ptr)]
|
||||
|
||||
use std::ffi::CString;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
error: getting the inner pointer of a temporary `CString`
|
||||
--> $DIR/lint-temporary-cstring-as-ptr.rs:6:48
|
||||
--> $DIR/lint-temporary-cstring-as-ptr.rs:7:48
|
||||
|
|
||||
LL | let s = CString::new("some text").unwrap().as_ptr();
|
||||
| ---------------------------------- ^^^^^^ this pointer will be invalid
|
||||
| |
|
||||
| this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime
|
||||
|
|
||||
= note: `#[deny(temporary_cstring_as_ptr)]` on by default
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-temporary-cstring-as-ptr.rs:2:9
|
||||
|
|
||||
LL | #![deny(temporary_cstring_as_ptr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: pointers do not have a lifetime; when calling `as_ptr` the `CString` is deallocated because nothing is referencing it as far as the type system is concerned
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue