Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #122283

Merged
merged 30 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1ea6cd7
Add std::ffi::c_str modules
clarfonthey Aug 19, 2023
05a6f65
Update a test to support Symbol Mangling V0
TimNN Feb 16, 2024
70639c8
Fixing shellcheck comments on lvi test script
raoulstrackx Feb 27, 2024
3e675bd
add myself to rotation
fee1-dead Feb 29, 2024
c3954b3
Add a tidy check that checks whether the fluent slugs only appear once
mu001999 Mar 2, 2024
d88c7ff
Remove unused fluent messages
mu001999 Mar 2, 2024
fbb97ed
Avoid some interning in bootstrap
Noratrieb Feb 24, 2024
d416a22
std::rand: enable getrandom for dragonflybsd too.
devnexen Mar 3, 2024
9da004e
Dynamically size sigaltstk in std
workingjubilee Jul 10, 2023
c7a48a5
Revert back to Git-for-Windows for MinGW CI builds
majaha Mar 7, 2024
7843e46
Factor out non-branch-related pattern data
Nadrieril Mar 9, 2024
594cf1d
review
Nadrieril Mar 9, 2024
092a1ab
fix: remove memory leak due to missing drop implementation for local …
tvallotton Mar 9, 2024
ff1459a
Add test to check unused_lifetimes don't duplicate "parameter is neve…
jieyouxu Mar 9, 2024
1bad698
doc/rustc: Move loongarch64-unknown-linux-musl to Tier 3
heiher Mar 10, 2024
83590ac
fix legacy numeric constant diag items
pitaj Mar 10, 2024
1b44889
Rollup merge of #112136 - clarfonthey:ffi-c_str, r=cuviper
matthiaskrgr Mar 10, 2024
b81678e
Rollup merge of #113525 - workingjubilee:handle-dynamic-minsigstksz, …
matthiaskrgr Mar 10, 2024
0f89fae
Rollup merge of #121567 - Nilstrieb:less-interning, r=albertlarsan68
matthiaskrgr Mar 10, 2024
e8e4187
Rollup merge of #121642 - TimNN:test-v0, r=Mark-Simulacrum
matthiaskrgr Mar 10, 2024
8b9b83b
Rollup merge of #121685 - fortanix:raoul/shellcheck_on_lvi_test_scrip…
matthiaskrgr Mar 10, 2024
fdcd051
Rollup merge of #121860 - mu001999:master, r=Nilstrieb
matthiaskrgr Mar 10, 2024
f6d47dd
Rollup merge of #121942 - devnexen:getrandom_for_dfbsd, r=joboet
matthiaskrgr Mar 10, 2024
44c8a6a
Rollup merge of #122125 - majaha:mingw_ci_new, r=Mark-Simulacrum
matthiaskrgr Mar 10, 2024
163573a
Rollup merge of #122221 - Nadrieril:patextradata, r=oli-obk
matthiaskrgr Mar 10, 2024
4faf535
Rollup merge of #122244 - tvallotton:local_waker_leak_fix, r=Nilstrieb
matthiaskrgr Mar 10, 2024
8a9f3fd
Rollup merge of #122251 - jieyouxu:unused-lifetimes-dedup-test, r=Nad…
matthiaskrgr Mar 10, 2024
d2fbf0c
Rollup merge of #122264 - fee1-dead-contrib:add, r=fee1-dead
matthiaskrgr Mar 10, 2024
01ce236
Rollup merge of #122269 - heiher:fix-doc, r=workingjubilee
matthiaskrgr Mar 10, 2024
9d03046
Rollup merge of #122271 - pitaj:diag_items-legacy_numeric_constants, …
matthiaskrgr Mar 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add std::ffi::c_str modules
  • Loading branch information
clarfonthey committed Feb 22, 2024
commit 1ea6cd715e01f14395ee3f7d944ecc68adf0dde4
2 changes: 2 additions & 0 deletions library/alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! [`CString`] and its related types.

#[cfg(test)]
mod tests;

Expand Down
10 changes: 7 additions & 3 deletions library/alloc/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@

#![stable(feature = "alloc_ffi", since = "1.64.0")]

#[doc(no_inline)]
#[stable(feature = "alloc_c_string", since = "1.64.0")]
pub use self::c_str::FromVecWithNulError;
pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};

#[doc(inline)]
#[stable(feature = "alloc_c_string", since = "1.64.0")]
pub use self::c_str::{CString, IntoStringError, NulError};
pub use self::c_str::CString;

mod c_str;
#[unstable(feature = "c_str_module", issue = "112134")]
pub mod c_str;
17 changes: 12 additions & 5 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! [`CStr`] and its related types.

use crate::cmp::Ordering;
use crate::error::Error;
use crate::ffi::c_char;
Expand All @@ -8,15 +10,20 @@ use crate::slice;
use crate::slice::memchr;
use crate::str;

// FIXME: because this is doc(inline)d, we *have* to use intra-doc links because the actual link
// depends on where the item is being documented. however, since this is libcore, we can't
// actually reference libstd or liballoc in intra-doc links. so, the best we can do is remove the
// links to `CString` and `String` for now until a solution is developed

/// Representation of a borrowed C string.
///
/// This type represents a borrowed reference to a nul-terminated
/// array of bytes. It can be constructed safely from a <code>&[[u8]]</code>
/// slice, or unsafely from a raw `*const c_char`. It can then be
/// converted to a Rust <code>&[str]</code> by performing UTF-8 validation, or
/// into an owned [`CString`].
/// into an owned `CString`.
///
/// `&CStr` is to [`CString`] as <code>&[str]</code> is to [`String`]: the former
/// `&CStr` is to `CString` as <code>&[str]</code> is to `String`: the former
/// in each pair are borrowed references; the latter are owned
/// strings.
///
Expand All @@ -25,9 +32,6 @@ use crate::str;
/// Instead, safe wrappers of FFI functions may leverage the unsafe [`CStr::from_ptr`] constructor
/// to provide a safe interface to other consumers.
///
/// [`CString`]: ../../std/ffi/struct.CString.html
/// [`String`]: ../../std/string/struct.String.html
///
/// # Examples
///
/// Inspecting a foreign C string:
Expand Down Expand Up @@ -124,10 +128,13 @@ enum FromBytesWithNulErrorKind {
NotNulTerminated,
}

// FIXME: const stability attributes should not be required here, I think
impl FromBytesWithNulError {
#[rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0")]
const fn interior_nul(pos: usize) -> FromBytesWithNulError {
FromBytesWithNulError { kind: FromBytesWithNulErrorKind::InteriorNul(pos) }
}
#[rustc_const_stable(feature = "const_cstr_methods", since = "1.72.0")]
const fn not_nul_terminated() -> FromBytesWithNulError {
FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated }
}
Expand Down
14 changes: 12 additions & 2 deletions library/core/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ use crate::fmt;
use crate::marker::PhantomData;
use crate::ops::{Deref, DerefMut};

#[doc(no_inline)]
#[stable(feature = "core_c_str", since = "1.64.0")]
pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
pub use self::c_str::FromBytesWithNulError;

mod c_str;
#[doc(no_inline)]
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
pub use self::c_str::FromBytesUntilNulError;

#[doc(inline)]
#[stable(feature = "core_c_str", since = "1.64.0")]
pub use self::c_str::CStr;

#[unstable(feature = "c_str_module", issue = "112134")]
pub mod c_str;

macro_rules! type_alias {
{
Expand Down
19 changes: 19 additions & 0 deletions library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! [`CStr`], [`CString`], and related types.

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::ffi::c_str::CStr;

#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
pub use core::ffi::c_str::FromBytesWithNulError;

#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
pub use core::ffi::c_str::FromBytesUntilNulError;

#[stable(feature = "rust1", since = "1.0.0")]
pub use alloc::ffi::c_str::{CString, NulError};

#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
pub use alloc::ffi::c_str::FromVecWithNulError;

#[stable(feature = "cstring_into", since = "1.7.0")]
pub use alloc::ffi::c_str::IntoStringError;
32 changes: 26 additions & 6 deletions library/std/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,32 @@

#![stable(feature = "rust1", since = "1.0.0")]

#[stable(feature = "alloc_c_string", since = "1.64.0")]
pub use alloc::ffi::{CString, FromVecWithNulError, IntoStringError, NulError};
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.73.0")]
pub use core::ffi::FromBytesUntilNulError;
#[stable(feature = "core_c_str", since = "1.64.0")]
pub use core::ffi::{CStr, FromBytesWithNulError};
#[unstable(feature = "c_str_module", issue = "112134")]
pub mod c_str;

#[doc(inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::c_str::{CStr, CString};

#[doc(no_inline)]
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
pub use self::c_str::FromBytesWithNulError;

#[doc(no_inline)]
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
pub use self::c_str::FromBytesUntilNulError;

#[doc(no_inline)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::c_str::NulError;

#[doc(no_inline)]
#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
pub use self::c_str::FromVecWithNulError;

#[doc(no_inline)]
#[stable(feature = "cstring_into", since = "1.7.0")]
pub use self::c_str::IntoStringError;

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::os_str::{OsStr, OsString};
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
//
// Library features (core):
// tidy-alphabetical-start
#![feature(c_str_module)]
#![feature(char_internals)]
#![feature(core_intrinsics)]
#![feature(core_io_borrowed_buf)]
Expand Down
Loading