Skip to content

Commit afbecc0

Browse files
committed
remove now unnecessary lang items
1 parent 983c12f commit afbecc0

File tree

18 files changed

+51
-90
lines changed

18 files changed

+51
-90
lines changed

compiler/rustc_hir/src/lang_items.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -166,36 +166,6 @@ pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
166166

167167
language_item_table! {
168168
// Variant name, Name, Method name, Target Generic requirements;
169-
Bool, sym::bool, bool_impl, Target::Impl, GenericRequirement::None;
170-
Char, sym::char, char_impl, Target::Impl, GenericRequirement::None;
171-
Str, sym::str, str_impl, Target::Impl, GenericRequirement::None;
172-
Array, sym::array, array_impl, Target::Impl, GenericRequirement::None;
173-
Slice, sym::slice, slice_impl, Target::Impl, GenericRequirement::None;
174-
SliceU8, sym::slice_u8, slice_u8_impl, Target::Impl, GenericRequirement::None;
175-
StrAlloc, sym::str_alloc, str_alloc_impl, Target::Impl, GenericRequirement::None;
176-
SliceAlloc, sym::slice_alloc, slice_alloc_impl, Target::Impl, GenericRequirement::None;
177-
SliceU8Alloc, sym::slice_u8_alloc, slice_u8_alloc_impl, Target::Impl, GenericRequirement::None;
178-
ConstPtr, sym::const_ptr, const_ptr_impl, Target::Impl, GenericRequirement::None;
179-
MutPtr, sym::mut_ptr, mut_ptr_impl, Target::Impl, GenericRequirement::None;
180-
ConstSlicePtr, sym::const_slice_ptr, const_slice_ptr_impl, Target::Impl, GenericRequirement::None;
181-
MutSlicePtr, sym::mut_slice_ptr, mut_slice_ptr_impl, Target::Impl, GenericRequirement::None;
182-
I8, sym::i8, i8_impl, Target::Impl, GenericRequirement::None;
183-
I16, sym::i16, i16_impl, Target::Impl, GenericRequirement::None;
184-
I32, sym::i32, i32_impl, Target::Impl, GenericRequirement::None;
185-
I64, sym::i64, i64_impl, Target::Impl, GenericRequirement::None;
186-
I128, sym::i128, i128_impl, Target::Impl, GenericRequirement::None;
187-
Isize, sym::isize, isize_impl, Target::Impl, GenericRequirement::None;
188-
U8, sym::u8, u8_impl, Target::Impl, GenericRequirement::None;
189-
U16, sym::u16, u16_impl, Target::Impl, GenericRequirement::None;
190-
U32, sym::u32, u32_impl, Target::Impl, GenericRequirement::None;
191-
U64, sym::u64, u64_impl, Target::Impl, GenericRequirement::None;
192-
U128, sym::u128, u128_impl, Target::Impl, GenericRequirement::None;
193-
Usize, sym::usize, usize_impl, Target::Impl, GenericRequirement::None;
194-
F32, sym::f32, f32_impl, Target::Impl, GenericRequirement::None;
195-
F64, sym::f64, f64_impl, Target::Impl, GenericRequirement::None;
196-
F32Runtime, sym::f32_runtime, f32_runtime_impl, Target::Impl, GenericRequirement::None;
197-
F64Runtime, sym::f64_runtime, f64_runtime_impl, Target::Impl, GenericRequirement::None;
198-
199169
Sized, sym::sized, sized_trait, Target::Trait, GenericRequirement::Exact(0);
200170
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
201171
/// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,9 @@ symbols! {
494494
const_panic,
495495
const_panic_fmt,
496496
const_precise_live_drops,
497-
const_ptr,
498497
const_raw_ptr_deref,
499498
const_raw_ptr_to_usize_cast,
500499
const_refs_to_cell,
501-
const_slice_ptr,
502500
const_trait_bound_opt_out,
503501
const_trait_impl,
504502
const_transmute,
@@ -655,9 +653,7 @@ symbols! {
655653
f,
656654
f16c_target_feature,
657655
f32,
658-
f32_runtime,
659656
f64,
660-
f64_runtime,
661657
fabsf32,
662658
fabsf64,
663659
fadd_fast,
@@ -913,8 +909,6 @@ symbols! {
913909
mul_with_overflow,
914910
must_not_suspend,
915911
must_use,
916-
mut_ptr,
917-
mut_slice_ptr,
918912
naked,
919913
naked_functions,
920914
name,
@@ -1314,11 +1308,8 @@ symbols! {
13141308
sized,
13151309
skip,
13161310
slice,
1317-
slice_alloc,
13181311
slice_len_fn,
13191312
slice_patterns,
1320-
slice_u8,
1321-
slice_u8_alloc,
13221313
slicing_syntax,
13231314
soft,
13241315
specialization,
@@ -1348,7 +1339,6 @@ symbols! {
13481339
stop_after_dataflow,
13491340
store,
13501341
str,
1351-
str_alloc,
13521342
str_split_whitespace,
13531343
str_trim,
13541344
str_trim_end,

compiler/rustc_typeck/src/check/method/suggest.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
281281
// There are methods that are defined on the primitive types and won't be
282282
// found when exploring `all_traits`, but we also need them to be acurate on
283283
// our suggestions (#47759).
284-
let fund_assoc = |opt_def_id: Option<DefId>| {
285-
opt_def_id.and_then(|id| self.associated_value(id, item_name)).is_some()
284+
let found_assoc = |ty: Ty<'tcx>| {
285+
simplify_type(tcx, ty, TreatParams::AsPlaceholders).and_then(|simp| {
286+
tcx.incoherent_impls(simp)
287+
.iter()
288+
.find_map(|&id| self.associated_value(id, item_name))
289+
}).is_some()
286290
};
287-
let lang_items = tcx.lang_items();
288291
let found_candidate = candidates.next().is_some()
289-
|| fund_assoc(lang_items.i8_impl())
290-
|| fund_assoc(lang_items.i16_impl())
291-
|| fund_assoc(lang_items.i32_impl())
292-
|| fund_assoc(lang_items.i64_impl())
293-
|| fund_assoc(lang_items.i128_impl())
294-
|| fund_assoc(lang_items.u8_impl())
295-
|| fund_assoc(lang_items.u16_impl())
296-
|| fund_assoc(lang_items.u32_impl())
297-
|| fund_assoc(lang_items.u64_impl())
298-
|| fund_assoc(lang_items.u128_impl())
299-
|| fund_assoc(lang_items.f32_impl())
300-
|| fund_assoc(lang_items.f32_runtime_impl())
301-
|| fund_assoc(lang_items.f64_impl())
302-
|| fund_assoc(lang_items.f64_runtime_impl());
292+
|| found_assoc(tcx.types.i8)
293+
|| found_assoc(tcx.types.i16)
294+
|| found_assoc(tcx.types.i32)
295+
|| found_assoc(tcx.types.i64)
296+
|| found_assoc(tcx.types.i128)
297+
|| found_assoc(tcx.types.u8)
298+
|| found_assoc(tcx.types.u16)
299+
|| found_assoc(tcx.types.u32)
300+
|| found_assoc(tcx.types.u64)
301+
|| found_assoc(tcx.types.u128)
302+
|| found_assoc(tcx.types.f32)
303+
|| found_assoc(tcx.types.f32);
303304
if let (true, false, SelfSource::MethodCall(expr), true) = (
304305
actual.is_numeric(),
305306
actual.has_concrete_skeleton(),

library/alloc/src/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ mod hack {
237237
}
238238
}
239239

240-
#[lang = "slice_alloc"]
240+
#[cfg_attr(bootstrap, lang = "slice_alloc")]
241241
#[cfg(not(test))]
242242
impl<T> [T] {
243243
/// Sorts the slice.
@@ -667,7 +667,7 @@ impl<T> [T] {
667667
}
668668
}
669669

670-
#[lang = "slice_u8_alloc"]
670+
#[cfg_attr(bootstrap, lang = "slice_u8_alloc")]
671671
#[cfg(not(test))]
672672
impl [u8] {
673673
/// Returns a vector containing a copy of this slice where each byte

library/alloc/src/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl ToOwned for str {
235235
}
236236

237237
/// Methods for string slices.
238-
#[lang = "str_alloc"]
238+
#[cfg_attr(bootstrap, lang = "str_alloc")]
239239
#[cfg(not(test))]
240240
impl str {
241241
/// Converts a `Box<str>` into a `Box<[u8]>` without copying or allocating.

library/core/src/array/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ macro_rules! array_impl_default {
395395

396396
array_impl_default! {32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}
397397

398-
#[lang = "array"]
398+
#[cfg_attr(bootstrap, lang = "array")]
399399
impl<T, const N: usize> [T; N] {
400400
/// Returns an array of the same size as `self`, with function `f` applied to each element
401401
/// in order.

library/core/src/bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::marker::Destruct;
44

5-
#[lang = "bool"]
5+
#[cfg_attr(bootstrap, lang = "bool")]
66
impl bool {
77
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
88
/// or `None` otherwise.

library/core/src/char/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::unicode::{self, conversions};
77

88
use super::*;
99

10-
#[lang = "char"]
10+
#[cfg_attr(bootstrap, lang = "char")]
1111
impl char {
1212
/// The highest valid code point a `char` can have, `'\u{10FFFF}'`.
1313
///

library/core/src/num/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub mod consts {
370370
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
371371
}
372372

373-
#[lang = "f32"]
373+
#[cfg_attr(bootstrap, lang = "f32")]
374374
#[cfg(not(test))]
375375
impl f32 {
376376
/// The radix or base of the internal representation of `f32`.

library/core/src/num/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub mod consts {
370370
pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;
371371
}
372372

373-
#[lang = "f64"]
373+
#[cfg_attr(bootstrap, lang = "f64")]
374374
#[cfg(not(test))]
375375
impl f64 {
376376
/// The radix or base of the internal representation of `f64`.

library/core/src/num/mod.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -193,34 +193,34 @@ macro_rules! widening_impl {
193193
};
194194
}
195195

196-
#[lang = "i8"]
196+
#[cfg_attr(bootstrap, lang = "i8")]
197197
impl i8 {
198198
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
199199
"[0x12]", "[0x12]", "", "" }
200200
}
201201

202-
#[lang = "i16"]
202+
#[cfg_attr(bootstrap, lang = "i16")]
203203
impl i16 {
204204
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
205205
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
206206
}
207207

208-
#[lang = "i32"]
208+
#[cfg_attr(bootstrap, lang = "i32")]
209209
impl i32 {
210210
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
211211
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
212212
"[0x12, 0x34, 0x56, 0x78]", "", "" }
213213
}
214214

215-
#[lang = "i64"]
215+
#[cfg_attr(bootstrap, lang = "i64")]
216216
impl i64 {
217217
int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12,
218218
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
219219
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
220220
"[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]", "", "" }
221221
}
222222

223-
#[lang = "i128"]
223+
#[cfg_attr(bootstrap, lang = "i128")]
224224
impl i128 {
225225
int_impl! { i128, i128, u128, 128, 127, -170141183460469231731687303715884105728,
226226
170141183460469231731687303715884105727, 16,
@@ -233,15 +233,15 @@ impl i128 {
233233
}
234234

235235
#[cfg(target_pointer_width = "16")]
236-
#[lang = "isize"]
236+
#[cfg_attr(bootstrap, lang = "isize")]
237237
impl isize {
238238
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
239239
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
240240
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
241241
}
242242

243243
#[cfg(target_pointer_width = "32")]
244-
#[lang = "isize"]
244+
#[cfg_attr(bootstrap, lang = "isize")]
245245
impl isize {
246246
int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
247247
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
@@ -250,7 +250,7 @@ impl isize {
250250
}
251251

252252
#[cfg(target_pointer_width = "64")]
253-
#[lang = "isize"]
253+
#[cfg_attr(bootstrap, lang = "isize")]
254254
impl isize {
255255
int_impl! { isize, i64, usize, 64, 63, -9223372036854775808, 9223372036854775807,
256256
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
@@ -262,7 +262,7 @@ impl isize {
262262
/// If 6th bit set ascii is upper case.
263263
const ASCII_CASE_MASK: u8 = 0b0010_0000;
264264

265-
#[lang = "u8"]
265+
#[cfg_attr(bootstrap, lang = "u8")]
266266
impl u8 {
267267
uint_impl! { u8, u8, i8, NonZeroU8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
268268
"[0x12]", "", "" }
@@ -816,7 +816,7 @@ impl u8 {
816816
}
817817
}
818818

819-
#[lang = "u16"]
819+
#[cfg_attr(bootstrap, lang = "u16")]
820820
impl u16 {
821821
uint_impl! { u16, u16, i16, NonZeroU16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
822822
"[0x34, 0x12]", "[0x12, 0x34]", "", "" }
@@ -848,14 +848,14 @@ impl u16 {
848848
}
849849
}
850850

851-
#[lang = "u32"]
851+
#[cfg_attr(bootstrap, lang = "u32")]
852852
impl u32 {
853853
uint_impl! { u32, u32, i32, NonZeroU32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
854854
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
855855
widening_impl! { u32, u64, 32, unsigned }
856856
}
857857

858-
#[lang = "u64"]
858+
#[cfg_attr(bootstrap, lang = "u64")]
859859
impl u64 {
860860
uint_impl! { u64, u64, i64, NonZeroU64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
861861
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
@@ -865,7 +865,7 @@ impl u64 {
865865
widening_impl! { u64, u128, 64, unsigned }
866866
}
867867

868-
#[lang = "u128"]
868+
#[cfg_attr(bootstrap, lang = "u128")]
869869
impl u128 {
870870
uint_impl! { u128, u128, i128, NonZeroU128, 128, 340282366920938463463374607431768211455, 16,
871871
"0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012",
@@ -878,15 +878,15 @@ impl u128 {
878878
}
879879

880880
#[cfg(target_pointer_width = "16")]
881-
#[lang = "usize"]
881+
#[cfg_attr(bootstrap, lang = "usize")]
882882
impl usize {
883883
uint_impl! { usize, u16, isize, NonZeroUsize, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
884884
"[0x34, 0x12]", "[0x12, 0x34]",
885885
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
886886
widening_impl! { usize, u32, 16, unsigned }
887887
}
888888
#[cfg(target_pointer_width = "32")]
889-
#[lang = "usize"]
889+
#[cfg_attr(bootstrap, lang = "usize")]
890890
impl usize {
891891
uint_impl! { usize, u32, isize, NonZeroUsize, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
892892
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]",
@@ -895,7 +895,7 @@ impl usize {
895895
}
896896

897897
#[cfg(target_pointer_width = "64")]
898-
#[lang = "usize"]
898+
#[cfg_attr(bootstrap, lang = "usize")]
899899
impl usize {
900900
uint_impl! { usize, u64, isize, NonZeroUsize, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
901901
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",

library/core/src/ptr/const_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::intrinsics;
44
use crate::mem;
55
use crate::slice::{self, SliceIndex};
66

7-
#[lang = "const_ptr"]
7+
#[cfg_attr(bootstrap, lang = "const_ptr")]
88
impl<T: ?Sized> *const T {
99
/// Returns `true` if the pointer is null.
1010
///
@@ -969,7 +969,7 @@ impl<T: ?Sized> *const T {
969969
}
970970
}
971971

972-
#[lang = "const_slice_ptr"]
972+
#[cfg_attr(bootstrap, lang = "const_slice_ptr")]
973973
impl<T> *const [T] {
974974
/// Returns the length of a raw slice.
975975
///

library/core/src/ptr/mut_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::cmp::Ordering::{self, Equal, Greater, Less};
33
use crate::intrinsics;
44
use crate::slice::{self, SliceIndex};
55

6-
#[lang = "mut_ptr"]
6+
#[cfg_attr(bootstrap, lang = "mut_ptr")]
77
impl<T: ?Sized> *mut T {
88
/// Returns `true` if the pointer is null.
99
///
@@ -1240,7 +1240,7 @@ impl<T: ?Sized> *mut T {
12401240
}
12411241
}
12421242

1243-
#[lang = "mut_slice_ptr"]
1243+
#[cfg_attr(bootstrap, lang = "mut_slice_ptr")]
12441244
impl<T> *mut [T] {
12451245
/// Returns the length of a raw slice.
12461246
///

library/core/src/slice/ascii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::iter;
66
use crate::mem;
77
use crate::ops;
88

9-
#[lang = "slice_u8"]
9+
#[cfg_attr(bootstrap, lang = "slice_u8")]
1010
#[cfg(not(test))]
1111
impl [u8] {
1212
/// Checks if all bytes in this slice are within the ASCII range.

library/core/src/slice/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ enum Direction {
109109
Back,
110110
}
111111

112-
#[lang = "slice"]
112+
#[cfg_attr(bootstrap, lang = "slice")]
113113
#[cfg(not(test))]
114114
impl<T> [T] {
115115
/// Returns the number of elements in the slice.

0 commit comments

Comments
 (0)