diff options
| author | bors <bors@rust-lang.org> | 2020-10-27 22:59:13 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-10-27 22:59:13 +0000 |
| commit | 90e6d0d46bae511aecea04ac5eeb3c387f0c04f4 (patch) | |
| tree | 377ed837d5c0484e2b59bdd47e6be583567b0171 /library/std/src | |
| parent | 07e968b640e8ff76fa8be4b48b70ab80ea577800 (diff) | |
| parent | 572cd358d379e4e641ad44bc693cdf48ceaf3581 (diff) | |
| download | rust-90e6d0d46bae511aecea04ac5eeb3c387f0c04f4.tar.gz rust-90e6d0d46bae511aecea04ac5eeb3c387f0c04f4.zip | |
Auto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk
Uplift `temporary-cstring-as-ptr` lint from `clippy` into rustc The general consensus seems to be that this lint covers a common enough mistake to warrant inclusion in rustc. The diagnostic message might need some tweaking, as I'm not sure the use of second-person perspective matches the rest of rustc, but I'd like to hear others' thoughts on that. (cc #53224). r? `@oli-obk`
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/ffi/c_str.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 6df4eb99259..8c6d6c80402 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -110,6 +110,7 @@ use crate::sys; /// of `CString` instances can lead to invalid memory accesses, memory leaks, /// and other memory errors. #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone)] +#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_type")] #[stable(feature = "rust1", since = "1.0.0")] pub struct CString { // Invariant 1: the slice ends with a zero byte and has a length of at least one. @@ -1265,7 +1266,7 @@ impl CStr { /// behavior when `ptr` is used inside the `unsafe` block: /// /// ```no_run - /// # #![allow(unused_must_use)] + /// # #![allow(unused_must_use)] #![cfg_attr(not(bootstrap), allow(temporary_cstring_as_ptr))] /// use std::ffi::CString; /// /// let ptr = CString::new("Hello").expect("CString::new failed").as_ptr(); |
