Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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`.

0 commit comments

Comments
 (0)