about summary refs log tree commit diff
path: root/compiler/rustc_hir
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-15 15:47:17 +0000
committerbors <bors@rust-lang.org>2022-04-15 15:47:17 +0000
commit1e6fe5855a115ef7f17f3e17205fab7340775701 (patch)
tree10d4001f37a7a8f4780f878f9d72f9e60fc9ad73 /compiler/rustc_hir
parent69a5ae35fe5bb507ca5987e12392dce5186480b9 (diff)
parentf62c84e6b9b9720c2a49279843029b1c50fec54e (diff)
downloadrust-1e6fe5855a115ef7f17f3e17205fab7340775701.tar.gz
rust-1e6fe5855a115ef7f17f3e17205fab7340775701.zip
Auto merge of #94079 - petrochenkov:cstr, r=joshtriplett
library: Move `CStr` to libcore, and `CString` to liballoc

Closes https://github.com/rust-lang/rust/issues/46736

Interesting points:
- Stability:
    - To make `CStr(ing)` from libcore/liballoc unusable without enabling features I had to make these structures unstable, and reexport them from libstd using stable type aliases instead of `pub use` reexports. (Because stability of `use` items is not checked.)
- Relying on target ABI in libcore is ok:
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1044263371
- `trait CStrExt` (UPDATE: used only in `cfg(bootstrap)` mode, otherwise lang items are used instead)
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450
- `strlen`
    - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450

Otherwise it's just a code move + some minor hackery usual for liballoc in `cfg(test)` mode.
Diffstat (limited to 'compiler/rustc_hir')
-rw-r--r--compiler/rustc_hir/src/lang_items.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs
index b8df1632144..9318ebb40b0 100644
--- a/compiler/rustc_hir/src/lang_items.rs
+++ b/compiler/rustc_hir/src/lang_items.rs
@@ -326,6 +326,8 @@ language_item_table! {
     Range,                   sym::Range,               range_struct,               Target::Struct,         GenericRequirement::None;
     RangeToInclusive,        sym::RangeToInclusive,    range_to_inclusive_struct,  Target::Struct,         GenericRequirement::None;
     RangeTo,                 sym::RangeTo,             range_to_struct,            Target::Struct,         GenericRequirement::None;
+
+    CStr,                    sym::CStr,                c_str,                      Target::Struct,         GenericRequirement::None;
 }
 
 pub enum GenericRequirement {