Skip to content

Commit 757b7ac

Browse files
committed
Auto merge of #43986 - petrochenkov:pubcrate3, r=pnkfelix
rustc: Remove some dead code Extracted from #43192 r? @eddyb
2 parents 06bf94a + de4dbe5 commit 757b7ac

File tree

59 files changed

+64
-1309
lines changed

Some content is hidden

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

59 files changed

+64
-1309
lines changed

src/librustc_allocator/lib.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![deny(warnings)]
12+
1113
#![feature(rustc_private)]
1214

1315
extern crate rustc;
@@ -22,69 +24,58 @@ pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
2224
name: "alloc",
2325
inputs: &[AllocatorTy::Layout],
2426
output: AllocatorTy::ResultPtr,
25-
is_unsafe: true,
2627
},
2728
AllocatorMethod {
2829
name: "oom",
2930
inputs: &[AllocatorTy::AllocErr],
3031
output: AllocatorTy::Bang,
31-
is_unsafe: false,
3232
},
3333
AllocatorMethod {
3434
name: "dealloc",
3535
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
3636
output: AllocatorTy::Unit,
37-
is_unsafe: true,
3837
},
3938
AllocatorMethod {
4039
name: "usable_size",
4140
inputs: &[AllocatorTy::LayoutRef],
4241
output: AllocatorTy::UsizePair,
43-
is_unsafe: false,
4442
},
4543
AllocatorMethod {
4644
name: "realloc",
4745
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
4846
output: AllocatorTy::ResultPtr,
49-
is_unsafe: true,
5047
},
5148
AllocatorMethod {
5249
name: "alloc_zeroed",
5350
inputs: &[AllocatorTy::Layout],
5451
output: AllocatorTy::ResultPtr,
55-
is_unsafe: true,
5652
},
5753
AllocatorMethod {
5854
name: "alloc_excess",
5955
inputs: &[AllocatorTy::Layout],
6056
output: AllocatorTy::ResultExcess,
61-
is_unsafe: true,
6257
},
6358
AllocatorMethod {
6459
name: "realloc_excess",
6560
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
6661
output: AllocatorTy::ResultExcess,
67-
is_unsafe: true,
6862
},
6963
AllocatorMethod {
7064
name: "grow_in_place",
7165
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
7266
output: AllocatorTy::ResultUnit,
73-
is_unsafe: true,
7467
},
7568
AllocatorMethod {
7669
name: "shrink_in_place",
7770
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
7871
output: AllocatorTy::ResultUnit,
79-
is_unsafe: true,
8072
},
8173
];
8274

8375
pub struct AllocatorMethod {
8476
pub name: &'static str,
8577
pub inputs: &'static [AllocatorTy],
8678
pub output: AllocatorTy,
87-
pub is_unsafe: bool,
8879
}
8980

9081
pub enum AllocatorTy {

src/librustc_back/dynamic_lib.rs

+2-34
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
//!
1313
//! A simple wrapper over the platform's dynamic library facilities
1414
15-
use std::env;
16-
use std::ffi::{CString, OsString};
17-
use std::path::{Path, PathBuf};
15+
use std::ffi::CString;
16+
use std::path::Path;
1817

1918
pub struct DynamicLibrary {
2019
handle: *mut u8
@@ -43,24 +42,6 @@ impl DynamicLibrary {
4342
}
4443
}
4544

46-
/// Prepends a path to this process's search path for dynamic libraries
47-
pub fn prepend_search_path(path: &Path) {
48-
let mut search_path = DynamicLibrary::search_path();
49-
search_path.insert(0, path.to_path_buf());
50-
env::set_var(DynamicLibrary::envvar(), &DynamicLibrary::create_path(&search_path));
51-
}
52-
53-
/// From a slice of paths, create a new vector which is suitable to be an
54-
/// environment variable for this platforms dylib search path.
55-
pub fn create_path(path: &[PathBuf]) -> OsString {
56-
let mut newvar = OsString::new();
57-
for (i, path) in path.iter().enumerate() {
58-
if i > 0 { newvar.push(DynamicLibrary::separator()); }
59-
newvar.push(path);
60-
}
61-
return newvar;
62-
}
63-
6445
/// Returns the environment variable for this process's dynamic library
6546
/// search path
6647
pub fn envvar() -> &'static str {
@@ -75,19 +56,6 @@ impl DynamicLibrary {
7556
}
7657
}
7758

78-
fn separator() -> &'static str {
79-
if cfg!(windows) { ";" } else { ":" }
80-
}
81-
82-
/// Returns the current search path for dynamic libraries being used by this
83-
/// process
84-
pub fn search_path() -> Vec<PathBuf> {
85-
match env::var_os(DynamicLibrary::envvar()) {
86-
Some(var) => env::split_paths(&var).collect(),
87-
None => Vec::new(),
88-
}
89-
}
90-
9159
/// Accesses the value at the symbol of the dynamic library.
9260
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
9361
// This function should have a lifetime constraint of 'a on

src/librustc_back/tempdir.rs

-9
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,6 @@ impl TempDir {
9595
self.path.as_ref().unwrap()
9696
}
9797

98-
/// Close and remove the temporary directory
99-
///
100-
/// Although `TempDir` removes the directory on drop, in the destructor
101-
/// any errors are ignored. To detect errors cleaning up the temporary
102-
/// directory, call `close` instead.
103-
pub fn close(mut self) -> io::Result<()> {
104-
self.cleanup_dir()
105-
}
106-
10798
fn cleanup_dir(&mut self) -> io::Result<()> {
10899
match self.path {
109100
Some(ref p) => fs::remove_dir_all(p),

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

-31
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,6 @@ pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
113113
gather_move(bccx, move_data, move_error_collector, move_info);
114114
}
115115

116-
pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
117-
move_data: &MoveData<'tcx>,
118-
_move_error_collector: &mut MoveErrorCollector<'tcx>,
119-
move_pat: &hir::Pat,
120-
cmt: mc::cmt<'tcx>,
121-
mode: euv::MatchMode) {
122-
let tcx = bccx.tcx;
123-
debug!("gather_match_variant(move_pat={}, cmt={:?}, mode={:?})",
124-
move_pat.id, cmt, mode);
125-
126-
let opt_lp = opt_loan_path(&cmt);
127-
match opt_lp {
128-
Some(lp) => {
129-
match lp.kind {
130-
LpDowncast(ref base_lp, _) =>
131-
move_data.add_variant_match(
132-
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
133-
_ => bug!("should only call gather_match_variant \
134-
for cat_downcast cmt"),
135-
}
136-
}
137-
None => {
138-
// We get None when input to match is non-path (e.g.
139-
// temporary result like a function call). Since no
140-
// loan-path is being matched, no need to record a
141-
// downcast.
142-
return;
143-
}
144-
}
145-
}
146-
147116
pub fn gather_move_from_pat<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
148117
move_data: &MoveData<'tcx>,
149118
move_error_collector: &mut MoveErrorCollector<'tcx>,

src/librustc_borrowck/borrowck/gather_loans/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
9494
matched_pat,
9595
cmt,
9696
mode);
97-
98-
if let Categorization::Downcast(..) = cmt.cat {
99-
gather_moves::gather_match_variant(
100-
self.bccx, &self.move_data, &mut self.move_error_collector,
101-
matched_pat, cmt, mode);
102-
}
10397
}
10498

10599
fn consume_pat(&mut self,

src/librustc_borrowck/borrowck/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
714714
err.emit();
715715
}
716716

717-
pub fn span_err(&self, s: Span, m: &str) {
718-
self.tcx.sess.span_err(s, m);
719-
}
720-
721-
pub fn struct_span_err<S: Into<MultiSpan>>(&self, s: S, m: &str)
722-
-> DiagnosticBuilder<'a> {
723-
self.tcx.sess.struct_span_err(s, m)
724-
}
725-
726717
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(&self,
727718
s: S,
728719
msg: &str,
@@ -731,10 +722,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
731722
self.tcx.sess.struct_span_err_with_code(s, msg, code)
732723
}
733724

734-
pub fn span_err_with_code<S: Into<MultiSpan>>(&self, s: S, msg: &str, code: &str) {
735-
self.tcx.sess.span_err_with_code(s, msg, code);
736-
}
737-
738725
fn bckerr_to_diag(&self, err: &BckError<'tcx>) -> DiagnosticBuilder<'a> {
739726
let span = err.span.clone();
740727

src/librustc_borrowck/borrowck/move_data.rs

-45
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ pub struct MoveData<'tcx> {
5353
/// kill move bits.
5454
pub path_assignments: RefCell<Vec<Assignment>>,
5555

56-
/// Enum variant matched within a pattern on some match arm, like
57-
/// `SomeStruct{ f: Variant1(x, y) } => ...`
58-
pub variant_matches: RefCell<Vec<VariantMatch>>,
59-
6056
/// Assignments to a variable or path, like `x = foo`, but not `x += foo`.
6157
pub assignee_ids: RefCell<NodeSet>,
6258
}
@@ -161,21 +157,6 @@ pub struct Assignment {
161157
pub assignee_id: ast::NodeId,
162158
}
163159

164-
#[derive(Copy, Clone)]
165-
pub struct VariantMatch {
166-
/// downcast to the variant.
167-
pub path: MovePathIndex,
168-
169-
/// path being downcast to the variant.
170-
pub base_path: MovePathIndex,
171-
172-
/// id where variant's pattern occurs
173-
pub id: ast::NodeId,
174-
175-
/// says if variant established by move (and why), by copy, or by borrow.
176-
pub mode: euv::MatchMode
177-
}
178-
179160
#[derive(Clone, Copy)]
180161
pub struct MoveDataFlowOperator;
181162

@@ -215,7 +196,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
215196
moves: RefCell::new(Vec::new()),
216197
path_assignments: RefCell::new(Vec::new()),
217198
var_assignments: RefCell::new(Vec::new()),
218-
variant_matches: RefCell::new(Vec::new()),
219199
assignee_ids: RefCell::new(NodeSet()),
220200
}
221201
}
@@ -485,31 +465,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
485465
}
486466
}
487467

488-
/// Adds a new record for a match of `base_lp`, downcast to
489-
/// variant `lp`, that occurs at location `pattern_id`. (One
490-
/// should be able to recover the span info from the
491-
/// `pattern_id` and the hir_map, I think.)
492-
pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
493-
lp: Rc<LoanPath<'tcx>>,
494-
pattern_id: ast::NodeId,
495-
base_lp: Rc<LoanPath<'tcx>>,
496-
mode: euv::MatchMode) {
497-
debug!("add_variant_match(lp={:?}, pattern_id={})",
498-
lp, pattern_id);
499-
500-
let path_index = self.move_path(tcx, lp.clone());
501-
let base_path_index = self.move_path(tcx, base_lp.clone());
502-
503-
let variant_match = VariantMatch {
504-
path: path_index,
505-
base_path: base_path_index,
506-
id: pattern_id,
507-
mode,
508-
};
509-
510-
self.variant_matches.borrow_mut().push(variant_match);
511-
}
512-
513468
/// Adds the gen/kills for the various moves and
514469
/// assignments into the provided data flow contexts.
515470
/// Moves are generated by moves and killed by assignments and

src/librustc_borrowck/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ extern crate core; // for NonZero
3737

3838
pub use borrowck::check_crate;
3939
pub use borrowck::build_borrowck_dataflow_data_for_fn;
40-
pub use borrowck::{AnalysisData, BorrowckCtxt};
4140

4241
// NB: This module needs to be declared first so diagnostics are
4342
// registered before they are used.
44-
pub mod diagnostics;
43+
mod diagnostics;
4544

4645
mod borrowck;
4746

src/librustc_const_eval/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern crate syntax_pos;
4141

4242
// NB: This module needs to be declared first so diagnostics are
4343
// registered before they are used.
44-
pub mod diagnostics;
44+
mod diagnostics;
4545

4646
mod eval;
4747
mod _match;

src/librustc_const_math/float.rs

-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ impl ConstFloat {
3737
self.ty.ty_to_string()
3838
}
3939

40-
pub fn is_nan(&self) -> bool {
41-
match self.ty {
42-
ast::FloatTy::F32 => Single::from_bits(self.bits).is_nan(),
43-
ast::FloatTy::F64 => Double::from_bits(self.bits).is_nan(),
44-
}
45-
}
46-
4740
/// Compares the values if they are of the same type
4841
pub fn try_cmp(self, rhs: Self) -> Result<Ordering, ConstMathErr> {
4942
match (self.ty, rhs.ty) {

src/librustc_data_structures/blake2b.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::mem;
2424
use std::slice;
2525

2626
#[repr(C)]
27-
pub struct Blake2bCtx {
27+
struct Blake2bCtx {
2828
b: [u8; 128],
2929
h: [u64; 8],
3030
t: [u64; 2],

0 commit comments

Comments
 (0)