Skip to content

Commit 48691ea

Browse files
committed
Auto merge of #83185 - jyn514:remove-dead-code, r=oli-obk
Remove (lots of) dead code Builds on - [ ] #83161 - [x] #83230 - [x] #83197. Found with https://github.com/est31/warnalyzer. See #77739 for a similar change in the past. Dubious changes: - Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future? TODO: - [ ] check if any of the comments on the deleted code should be kept. - [x] update the compiler documentation; right now it fails to build - [x] finish moving `cfg(test)` changes into #83197 cc `@est31`
2 parents 2917eda + 526bb10 commit 48691ea

File tree

74 files changed

+81
-995
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+81
-995
lines changed

compiler/rustc_arena/src/lib.rs

-20
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,6 @@ impl<T> TypedArena<T> {
236236
start_ptr
237237
}
238238

239-
/// Allocates a slice of objects that are copied into the `TypedArena`, returning a mutable
240-
/// reference to it. Will panic if passed a zero-sized types.
241-
///
242-
/// Panics:
243-
///
244-
/// - Zero-sized types
245-
/// - Zero-length slices
246-
#[inline]
247-
pub fn alloc_slice(&self, slice: &[T]) -> &mut [T]
248-
where
249-
T: Copy,
250-
{
251-
unsafe {
252-
let len = slice.len();
253-
let start_ptr = self.alloc_raw_slice(len);
254-
slice.as_ptr().copy_to_nonoverlapping(start_ptr, len);
255-
slice::from_raw_parts_mut(start_ptr, len)
256-
}
257-
}
258-
259239
#[inline]
260240
pub fn alloc_from_iter<I: IntoIterator<Item = T>>(&self, iter: I) -> &mut [T] {
261241
assert!(mem::size_of::<T>() != 0);

compiler/rustc_ast/src/ast.rs

-64
Original file line numberDiff line numberDiff line change
@@ -762,14 +762,6 @@ pub enum Mutability {
762762
}
763763

764764
impl Mutability {
765-
/// Returns `MutMutable` only if both `self` and `other` are mutable.
766-
pub fn and(self, other: Self) -> Self {
767-
match self {
768-
Mutability::Mut => other,
769-
Mutability::Not => Mutability::Not,
770-
}
771-
}
772-
773765
pub fn invert(self) -> Self {
774766
match self {
775767
Mutability::Mut => Mutability::Not,
@@ -1722,13 +1714,6 @@ impl FloatTy {
17221714
FloatTy::F64 => sym::f64,
17231715
}
17241716
}
1725-
1726-
pub fn bit_width(self) -> u64 {
1727-
match self {
1728-
FloatTy::F32 => 32,
1729-
FloatTy::F64 => 64,
1730-
}
1731-
}
17321717
}
17331718

17341719
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
@@ -1764,29 +1749,6 @@ impl IntTy {
17641749
IntTy::I128 => sym::i128,
17651750
}
17661751
}
1767-
1768-
pub fn bit_width(&self) -> Option<u64> {
1769-
Some(match *self {
1770-
IntTy::Isize => return None,
1771-
IntTy::I8 => 8,
1772-
IntTy::I16 => 16,
1773-
IntTy::I32 => 32,
1774-
IntTy::I64 => 64,
1775-
IntTy::I128 => 128,
1776-
})
1777-
}
1778-
1779-
pub fn normalize(&self, target_width: u32) -> Self {
1780-
match self {
1781-
IntTy::Isize => match target_width {
1782-
16 => IntTy::I16,
1783-
32 => IntTy::I32,
1784-
64 => IntTy::I64,
1785-
_ => unreachable!(),
1786-
},
1787-
_ => *self,
1788-
}
1789-
}
17901752
}
17911753

17921754
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Debug)]
@@ -1822,29 +1784,6 @@ impl UintTy {
18221784
UintTy::U128 => sym::u128,
18231785
}
18241786
}
1825-
1826-
pub fn bit_width(&self) -> Option<u64> {
1827-
Some(match *self {
1828-
UintTy::Usize => return None,
1829-
UintTy::U8 => 8,
1830-
UintTy::U16 => 16,
1831-
UintTy::U32 => 32,
1832-
UintTy::U64 => 64,
1833-
UintTy::U128 => 128,
1834-
})
1835-
}
1836-
1837-
pub fn normalize(&self, target_width: u32) -> Self {
1838-
match self {
1839-
UintTy::Usize => match target_width {
1840-
16 => UintTy::U16,
1841-
32 => UintTy::U32,
1842-
64 => UintTy::U64,
1843-
_ => unreachable!(),
1844-
},
1845-
_ => *self,
1846-
}
1847-
}
18481787
}
18491788

18501789
/// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or
@@ -2215,9 +2154,6 @@ pub struct FnDecl {
22152154
}
22162155

22172156
impl FnDecl {
2218-
pub fn get_self(&self) -> Option<ExplicitSelf> {
2219-
self.inputs.get(0).and_then(Param::to_self)
2220-
}
22212157
pub fn has_self(&self) -> bool {
22222158
self.inputs.get(0).map_or(false, Param::is_self)
22232159
}

compiler/rustc_ast/src/attr/mod.rs

+1-39
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,7 @@ impl NestedMetaItem {
100100
self.meta_item().map_or(false, |meta_item| meta_item.is_word())
101101
}
102102

103-
/// Returns `true` if `self` is a `MetaItem` and the meta item is a `ValueString`.
104-
pub fn is_value_str(&self) -> bool {
105-
self.value_str().is_some()
106-
}
107-
108-
/// Returns `true` if `self` is a `MetaItem` and the meta item is a list.
109-
pub fn is_meta_item_list(&self) -> bool {
110-
self.meta_item_list().is_some()
111-
}
112-
103+
/// See [`MetaItem::name_value_literal_span`].
113104
pub fn name_value_literal_span(&self) -> Option<Span> {
114105
self.meta_item()?.name_value_literal_span()
115106
}
@@ -165,31 +156,6 @@ impl Attribute {
165156
false
166157
}
167158
}
168-
169-
pub fn is_meta_item_list(&self) -> bool {
170-
self.meta_item_list().is_some()
171-
}
172-
173-
/// Indicates if the attribute is a `ValueString`.
174-
pub fn is_value_str(&self) -> bool {
175-
self.value_str().is_some()
176-
}
177-
178-
/// This is used in case you want the value span instead of the whole attribute. Example:
179-
///
180-
/// ```text
181-
/// #[doc(alias = "foo")]
182-
/// ```
183-
///
184-
/// In here, it'll return a span for `"foo"`.
185-
pub fn name_value_literal_span(&self) -> Option<Span> {
186-
match self.kind {
187-
AttrKind::Normal(ref item, _) => {
188-
item.meta(self.span).and_then(|meta| meta.name_value_literal_span())
189-
}
190-
AttrKind::DocComment(..) => None,
191-
}
192-
}
193159
}
194160

195161
impl MetaItem {
@@ -236,10 +202,6 @@ impl MetaItem {
236202
self.path == name
237203
}
238204

239-
pub fn is_value_str(&self) -> bool {
240-
self.value_str().is_some()
241-
}
242-
243205
/// This is used in case you want the value span instead of the whole attribute. Example:
244206
///
245207
/// ```text

compiler/rustc_ast/src/tokenstream.rs

-20
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ impl TokenTree {
8989
}
9090
}
9191

92-
pub fn joint(self) -> TokenStream {
93-
TokenStream::new(vec![(self, Spacing::Joint)])
94-
}
95-
9692
pub fn token(kind: TokenKind, span: Span) -> TokenTree {
9793
TokenTree::Token(Token::new(kind, span))
9894
}
@@ -278,14 +274,6 @@ impl TokenStream {
278274
self.0.len()
279275
}
280276

281-
pub fn span(&self) -> Option<Span> {
282-
match &**self.0 {
283-
[] => None,
284-
[(tt, _)] => Some(tt.span()),
285-
[(tt_start, _), .., (tt_end, _)] => Some(tt_start.span().to(tt_end.span())),
286-
}
287-
}
288-
289277
pub fn from_streams(mut streams: SmallVec<[TokenStream; 2]>) -> TokenStream {
290278
match streams.len() {
291279
0 => TokenStream::default(),
@@ -325,10 +313,6 @@ impl TokenStream {
325313
}
326314
}
327315

328-
pub fn trees_ref(&self) -> CursorRef<'_> {
329-
CursorRef::new(self)
330-
}
331-
332316
pub fn trees(&self) -> Cursor {
333317
self.clone().into_trees()
334318
}
@@ -427,10 +411,6 @@ pub struct CursorRef<'t> {
427411
}
428412

429413
impl<'t> CursorRef<'t> {
430-
fn new(stream: &TokenStream) -> CursorRef<'_> {
431-
CursorRef { stream, index: 0 }
432-
}
433-
434414
fn next_with_spacing(&mut self) -> Option<&'t TreeAndSpacing> {
435415
self.stream.0.get(self.index).map(|tree| {
436416
self.index += 1;

compiler/rustc_ast_pretty/src/pprust/mod.rs

-24
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ pub fn token_to_string(token: &Token) -> String {
2222
State::new().token_to_string(token)
2323
}
2424

25-
pub fn token_to_string_ext(token: &Token, convert_dollar_crate: bool) -> String {
26-
State::new().token_to_string_ext(token, convert_dollar_crate)
27-
}
28-
2925
pub fn ty_to_string(ty: &ast::Ty) -> String {
3026
State::new().ty_to_string(ty)
3127
}
@@ -50,18 +46,10 @@ pub fn tts_to_string(tokens: &TokenStream) -> String {
5046
State::new().tts_to_string(tokens)
5147
}
5248

53-
pub fn stmt_to_string(stmt: &ast::Stmt) -> String {
54-
State::new().stmt_to_string(stmt)
55-
}
56-
5749
pub fn item_to_string(i: &ast::Item) -> String {
5850
State::new().item_to_string(i)
5951
}
6052

61-
pub fn generic_params_to_string(generic_params: &[ast::GenericParam]) -> String {
62-
State::new().generic_params_to_string(generic_params)
63-
}
64-
6553
pub fn path_to_string(p: &ast::Path) -> String {
6654
State::new().path_to_string(p)
6755
}
@@ -74,26 +62,14 @@ pub fn vis_to_string(v: &ast::Visibility) -> String {
7462
State::new().vis_to_string(v)
7563
}
7664

77-
pub fn block_to_string(blk: &ast::Block) -> String {
78-
State::new().block_to_string(blk)
79-
}
80-
8165
pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
8266
State::new().meta_list_item_to_string(li)
8367
}
8468

85-
pub fn attr_item_to_string(ai: &ast::AttrItem) -> String {
86-
State::new().attr_item_to_string(ai)
87-
}
88-
8969
pub fn attribute_to_string(attr: &ast::Attribute) -> String {
9070
State::new().attribute_to_string(attr)
9171
}
9272

93-
pub fn param_to_string(arg: &ast::Param) -> String {
94-
State::new().param_to_string(arg)
95-
}
96-
9773
pub fn to_string(f: impl FnOnce(&mut State<'_>)) -> String {
9874
State::new().to_string(f)
9975
}

compiler/rustc_ast_pretty/src/pprust/state.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2292,10 +2292,6 @@ impl<'a> State<'a> {
22922292
}
22932293
}
22942294

2295-
pub fn print_usize(&mut self, i: usize) {
2296-
self.s.word(i.to_string())
2297-
}
2298-
22992295
crate fn print_name(&mut self, name: Symbol) {
23002296
self.s.word(name.to_string());
23012297
self.ann.post(self, AnnNode::Name(&name))

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+13-31
Original file line numberDiff line numberDiff line change
@@ -190,33 +190,6 @@ pub enum RealPredicate {
190190
RealPredicateTrue = 15,
191191
}
192192

193-
impl RealPredicate {
194-
pub fn from_generic(realpred: rustc_codegen_ssa::common::RealPredicate) -> Self {
195-
match realpred {
196-
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
197-
RealPredicate::RealPredicateFalse
198-
}
199-
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
200-
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
201-
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
202-
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
203-
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
204-
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
205-
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
206-
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
207-
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
208-
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
209-
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
210-
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
211-
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
212-
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
213-
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
214-
RealPredicate::RealPredicateTrue
215-
}
216-
}
217-
}
218-
}
219-
220193
/// LLVMTypeKind
221194
#[derive(Copy, Clone, PartialEq, Debug)]
222195
#[repr(C)]
@@ -711,7 +684,7 @@ pub mod coverageinfo {
711684
}
712685

713686
impl CounterMappingRegion {
714-
pub fn code_region(
687+
crate fn code_region(
715688
counter: coverage_map::Counter,
716689
file_id: u32,
717690
start_line: u32,
@@ -731,7 +704,10 @@ pub mod coverageinfo {
731704
}
732705
}
733706

734-
pub fn expansion_region(
707+
// This function might be used in the future; the LLVM API is still evolving, as is coverage
708+
// support.
709+
#[allow(dead_code)]
710+
crate fn expansion_region(
735711
file_id: u32,
736712
expanded_file_id: u32,
737713
start_line: u32,
@@ -751,7 +727,10 @@ pub mod coverageinfo {
751727
}
752728
}
753729

754-
pub fn skipped_region(
730+
// This function might be used in the future; the LLVM API is still evolving, as is coverage
731+
// support.
732+
#[allow(dead_code)]
733+
crate fn skipped_region(
755734
file_id: u32,
756735
start_line: u32,
757736
start_col: u32,
@@ -770,7 +749,10 @@ pub mod coverageinfo {
770749
}
771750
}
772751

773-
pub fn gap_region(
752+
// This function might be used in the future; the LLVM API is still evolving, as is coverage
753+
// support.
754+
#[allow(dead_code)]
755+
crate fn gap_region(
774756
counter: coverage_map::Counter,
775757
file_id: u32,
776758
start_line: u32,

0 commit comments

Comments
 (0)