Skip to content

Commit

Permalink
Add newtype of [u8] as "str" lang item.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 7, 2020
1 parent 3eb1d9d commit a35355c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ pub mod pattern;
#[allow(missing_docs)]
pub mod lossy;

// HACK(eddyb) private and not named `str` to avoid changing name resolution.
#[cfg(not(bootstrap))]
#[lang = "str"]
struct Str([u8]);

/// Parse a value from a string
///
/// `FromStr`'s [`from_str`] method is often used implicitly, through
Expand Down
1 change: 1 addition & 0 deletions src/librustc_hir/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ language_item_table! {
// Variant name, Name, Method name, Target;
BoolImplItem, "bool", bool_impl, Target::Impl;
CharImplItem, "char", char_impl, Target::Impl;
StrItem, "str", str_type, Target::Struct;
StrImplItem, "str_impl", str_impl, Target::Impl;
SliceImplItem, "slice", slice_impl, Target::Impl;
SliceU8ImplItem, "slice_u8", slice_u8_impl, Target::Impl;
Expand Down

0 comments on commit a35355c

Please sign in to comment.