Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 737bfef

Browse files
committed
Change to warn by default / fix typo
1 parent 5643a06 commit 737bfef

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

compiler/rustc_lint/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_span::{
1010

1111
declare_lint! {
1212
pub TEMPORARY_CSTRING_AS_PTR,
13-
Deny,
13+
Warn,
1414
"detects getting the inner pointer of a temporary `CString`"
1515
}
1616

library/std/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ impl CStr {
12651265
/// behavior when `ptr` is used inside the `unsafe` block:
12661266
///
12671267
/// ```no_run
1268-
/// # #![allow(unused_must_use)] #![allow(temporary_cstring_as_ptr)]
1268+
/// # #![allow(unused_must_use, temporary_cstring_as_ptr)]
12691269
/// use std::ffi::CString;
12701270
///
12711271
/// let ptr = CString::new("Hello").expect("CString::new failed").as_ptr();

src/test/ui/lint/lint-temporary-cstring-as-ptr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// ignore-tidy-linelength
2+
#![deny(temporary_cstring_as_ptr)]
23

34
use std::ffi::CString;
45

src/test/ui/lint/lint-temporary-cstring-as-ptr.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
error: getting the inner pointer of a temporary `CString`
2-
--> $DIR/lint-temporary-cstring-as-ptr.rs:6:48
2+
--> $DIR/lint-temporary-cstring-as-ptr.rs:7:48
33
|
44
LL | let s = CString::new("some text").unwrap().as_ptr();
55
| ---------------------------------- ^^^^^^ this pointer will be invalid
66
| |
77
| this `CString` is deallocated at the end of the expression, bind it to a variable to extend its lifetime
88
|
9-
= note: `#[deny(temporary_cstring_as_ptr)]` on by default
9+
note: the lint level is defined here
10+
--> $DIR/lint-temporary-cstring-as-ptr.rs:2:9
11+
|
12+
LL | #![deny(temporary_cstring_as_ptr)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1014
= 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
1115

1216
error: aborting due to previous error

0 commit comments

Comments
 (0)