Skip to content

Commit

Permalink
Suffix "str" and "str_alloc" lang items with "_impl".
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 7, 2020
1 parent 39b6253 commit 3eb1d9d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ impl ToOwned for str {
}

/// Methods for string slices.
#[lang = "str_alloc"]
#[cfg_attr(bootstrap, lang = "str_alloc")]
#[cfg_attr(not(bootstrap), lang = "str_alloc_impl")]
#[cfg(not(test))]
impl str {
/// Converts a `Box<str>` into a `Box<[u8]>` without copying or allocating.
Expand Down
3 changes: 2 additions & 1 deletion src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,8 @@ fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
);
}

#[lang = "str"]
#[cfg_attr(bootstrap, lang = "str")]
#[cfg_attr(not(bootstrap), lang = "str_impl")]
#[cfg(not(test))]
impl str {
/// Returns the length of `self`.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_hir/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ language_item_table! {
// Variant name, Name, Method name, Target;
BoolImplItem, "bool", bool_impl, Target::Impl;
CharImplItem, "char", char_impl, Target::Impl;
StrImplItem, "str", str_impl, Target::Impl;
StrImplItem, "str_impl", str_impl, Target::Impl;
SliceImplItem, "slice", slice_impl, Target::Impl;
SliceU8ImplItem, "slice_u8", slice_u8_impl, Target::Impl;
StrAllocImplItem, "str_alloc", str_alloc_impl, Target::Impl;
StrAllocImplItem, "str_alloc_impl", str_alloc_impl, Target::Impl;
SliceAllocImplItem, "slice_alloc", slice_alloc_impl, Target::Impl;
SliceU8AllocImplItem, "slice_u8_alloc", slice_u8_alloc_impl, Target::Impl;
ConstPtrImplItem, "const_ptr", const_ptr_impl, Target::Impl;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
def_id,
lang_items.str_impl(),
lang_items.str_alloc_impl(),
"str",
"str_impl",
"str",
item.span,
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/issue-23511.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pub mod str {
#![doc(primitive = "str")]

#[lang = "str_alloc"]
#[lang = "str_alloc_impl"]
impl str {
// @has search-index.js foo
pub fn foo(&self) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/single-primitive-inherent-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#![no_std]

// OK
#[lang = "str_alloc"]
#[lang = "str_alloc_impl"]
impl str {}

impl str {
//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive
//~^ error: only a single inherent implementation marked with `#[lang = "str_impl"]` is allowed for the `str` primitive
}
2 changes: 1 addition & 1 deletion src/test/ui/single-primitive-inherent-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0390]: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive
error[E0390]: only a single inherent implementation marked with `#[lang = "str_impl"]` is allowed for the `str` primitive
--> $DIR/single-primitive-inherent-impl.rs:11:1
|
LL | / impl str {
Expand Down

0 comments on commit 3eb1d9d

Please sign in to comment.