Skip to content

Commit 3eb1d9d

Browse files
committed
Suffix "str" and "str_alloc" lang items with "_impl".
1 parent 39b6253 commit 3eb1d9d

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

src/liballoc/str.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ impl ToOwned for str {
213213
}
214214

215215
/// Methods for string slices.
216-
#[lang = "str_alloc"]
216+
#[cfg_attr(bootstrap, lang = "str_alloc")]
217+
#[cfg_attr(not(bootstrap), lang = "str_alloc_impl")]
217218
#[cfg(not(test))]
218219
impl str {
219220
/// Converts a `Box<str>` into a `Box<[u8]>` without copying or allocating.

src/libcore/str/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,8 @@ fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
22242224
);
22252225
}
22262226

2227-
#[lang = "str"]
2227+
#[cfg_attr(bootstrap, lang = "str")]
2228+
#[cfg_attr(not(bootstrap), lang = "str_impl")]
22282229
#[cfg(not(test))]
22292230
impl str {
22302231
/// Returns the length of `self`.

src/librustc_hir/lang_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ language_item_table! {
127127
// Variant name, Name, Method name, Target;
128128
BoolImplItem, "bool", bool_impl, Target::Impl;
129129
CharImplItem, "char", char_impl, Target::Impl;
130-
StrImplItem, "str", str_impl, Target::Impl;
130+
StrImplItem, "str_impl", str_impl, Target::Impl;
131131
SliceImplItem, "slice", slice_impl, Target::Impl;
132132
SliceU8ImplItem, "slice_u8", slice_u8_impl, Target::Impl;
133-
StrAllocImplItem, "str_alloc", str_alloc_impl, Target::Impl;
133+
StrAllocImplItem, "str_alloc_impl", str_alloc_impl, Target::Impl;
134134
SliceAllocImplItem, "slice_alloc", slice_alloc_impl, Target::Impl;
135135
SliceU8AllocImplItem, "slice_u8_alloc", slice_u8_alloc_impl, Target::Impl;
136136
ConstPtrImplItem, "const_ptr", const_ptr_impl, Target::Impl;

src/librustc_typeck/coherence/inherent_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
8787
def_id,
8888
lang_items.str_impl(),
8989
lang_items.str_alloc_impl(),
90-
"str",
90+
"str_impl",
9191
"str",
9292
item.span,
9393
);

src/test/rustdoc/issue-23511.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pub mod str {
55
#![doc(primitive = "str")]
66

7-
#[lang = "str_alloc"]
7+
#[lang = "str_alloc_impl"]
88
impl str {
99
// @has search-index.js foo
1010
pub fn foo(&self) {}

src/test/ui/single-primitive-inherent-impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#![no_std]
66

77
// OK
8-
#[lang = "str_alloc"]
8+
#[lang = "str_alloc_impl"]
99
impl str {}
1010

1111
impl str {
12-
//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive
12+
//~^ error: only a single inherent implementation marked with `#[lang = "str_impl"]` is allowed for the `str` primitive
1313
}

src/test/ui/single-primitive-inherent-impl.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0390]: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive
1+
error[E0390]: only a single inherent implementation marked with `#[lang = "str_impl"]` is allowed for the `str` primitive
22
--> $DIR/single-primitive-inherent-impl.rs:11:1
33
|
44
LL | / impl str {

0 commit comments

Comments
 (0)