Skip to content

Commit

Permalink
Auto merge of #43986 - petrochenkov:pubcrate3, r=pnkfelix
Browse files Browse the repository at this point in the history
rustc: Remove some dead code

Extracted from #43192

r? @eddyb
  • Loading branch information
bors committed Aug 21, 2017
2 parents 06bf94a + de4dbe5 commit 757b7ac
Show file tree
Hide file tree
Showing 59 changed files with 64 additions and 1,309 deletions.
13 changes: 2 additions & 11 deletions src/librustc_allocator/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(rustc_private)]

extern crate rustc;
Expand All @@ -22,69 +24,58 @@ pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
name: "alloc",
inputs: &[AllocatorTy::Layout],
output: AllocatorTy::ResultPtr,
is_unsafe: true,
},
AllocatorMethod {
name: "oom",
inputs: &[AllocatorTy::AllocErr],
output: AllocatorTy::Bang,
is_unsafe: false,
},
AllocatorMethod {
name: "dealloc",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
output: AllocatorTy::Unit,
is_unsafe: true,
},
AllocatorMethod {
name: "usable_size",
inputs: &[AllocatorTy::LayoutRef],
output: AllocatorTy::UsizePair,
is_unsafe: false,
},
AllocatorMethod {
name: "realloc",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
output: AllocatorTy::ResultPtr,
is_unsafe: true,
},
AllocatorMethod {
name: "alloc_zeroed",
inputs: &[AllocatorTy::Layout],
output: AllocatorTy::ResultPtr,
is_unsafe: true,
},
AllocatorMethod {
name: "alloc_excess",
inputs: &[AllocatorTy::Layout],
output: AllocatorTy::ResultExcess,
is_unsafe: true,
},
AllocatorMethod {
name: "realloc_excess",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
output: AllocatorTy::ResultExcess,
is_unsafe: true,
},
AllocatorMethod {
name: "grow_in_place",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
output: AllocatorTy::ResultUnit,
is_unsafe: true,
},
AllocatorMethod {
name: "shrink_in_place",
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
output: AllocatorTy::ResultUnit,
is_unsafe: true,
},
];

pub struct AllocatorMethod {
pub name: &'static str,
pub inputs: &'static [AllocatorTy],
pub output: AllocatorTy,
pub is_unsafe: bool,
}

pub enum AllocatorTy {
Expand Down
36 changes: 2 additions & 34 deletions src/librustc_back/dynamic_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
//!
//! A simple wrapper over the platform's dynamic library facilities

use std::env;
use std::ffi::{CString, OsString};
use std::path::{Path, PathBuf};
use std::ffi::CString;
use std::path::Path;

pub struct DynamicLibrary {
handle: *mut u8
Expand Down Expand Up @@ -43,24 +42,6 @@ impl DynamicLibrary {
}
}

/// Prepends a path to this process's search path for dynamic libraries
pub fn prepend_search_path(path: &Path) {
let mut search_path = DynamicLibrary::search_path();
search_path.insert(0, path.to_path_buf());
env::set_var(DynamicLibrary::envvar(), &DynamicLibrary::create_path(&search_path));
}

/// From a slice of paths, create a new vector which is suitable to be an
/// environment variable for this platforms dylib search path.
pub fn create_path(path: &[PathBuf]) -> OsString {
let mut newvar = OsString::new();
for (i, path) in path.iter().enumerate() {
if i > 0 { newvar.push(DynamicLibrary::separator()); }
newvar.push(path);
}
return newvar;
}

/// Returns the environment variable for this process's dynamic library
/// search path
pub fn envvar() -> &'static str {
Expand All @@ -75,19 +56,6 @@ impl DynamicLibrary {
}
}

fn separator() -> &'static str {
if cfg!(windows) { ";" } else { ":" }
}

/// Returns the current search path for dynamic libraries being used by this
/// process
pub fn search_path() -> Vec<PathBuf> {
match env::var_os(DynamicLibrary::envvar()) {
Some(var) => env::split_paths(&var).collect(),
None => Vec::new(),
}
}

/// Accesses the value at the symbol of the dynamic library.
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
// This function should have a lifetime constraint of 'a on
Expand Down
9 changes: 0 additions & 9 deletions src/librustc_back/tempdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ impl TempDir {
self.path.as_ref().unwrap()
}

/// Close and remove the temporary directory
///
/// Although `TempDir` removes the directory on drop, in the destructor
/// any errors are ignored. To detect errors cleaning up the temporary
/// directory, call `close` instead.
pub fn close(mut self) -> io::Result<()> {
self.cleanup_dir()
}

fn cleanup_dir(&mut self) -> io::Result<()> {
match self.path {
Some(ref p) => fs::remove_dir_all(p),
Expand Down
31 changes: 0 additions & 31 deletions src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,37 +113,6 @@ pub fn gather_move_from_expr<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
gather_move(bccx, move_data, move_error_collector, move_info);
}

pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
_move_error_collector: &mut MoveErrorCollector<'tcx>,
move_pat: &hir::Pat,
cmt: mc::cmt<'tcx>,
mode: euv::MatchMode) {
let tcx = bccx.tcx;
debug!("gather_match_variant(move_pat={}, cmt={:?}, mode={:?})",
move_pat.id, cmt, mode);

let opt_lp = opt_loan_path(&cmt);
match opt_lp {
Some(lp) => {
match lp.kind {
LpDowncast(ref base_lp, _) =>
move_data.add_variant_match(
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
_ => bug!("should only call gather_match_variant \
for cat_downcast cmt"),
}
}
None => {
// We get None when input to match is non-path (e.g.
// temporary result like a function call). Since no
// loan-path is being matched, no need to record a
// downcast.
return;
}
}
}

pub fn gather_move_from_pat<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
move_data: &MoveData<'tcx>,
move_error_collector: &mut MoveErrorCollector<'tcx>,
Expand Down
6 changes: 0 additions & 6 deletions src/librustc_borrowck/borrowck/gather_loans/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
matched_pat,
cmt,
mode);

if let Categorization::Downcast(..) = cmt.cat {
gather_moves::gather_match_variant(
self.bccx, &self.move_data, &mut self.move_error_collector,
matched_pat, cmt, mode);
}
}

fn consume_pat(&mut self,
Expand Down
13 changes: 0 additions & 13 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,15 +714,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
err.emit();
}

pub fn span_err(&self, s: Span, m: &str) {
self.tcx.sess.span_err(s, m);
}

pub fn struct_span_err<S: Into<MultiSpan>>(&self, s: S, m: &str)
-> DiagnosticBuilder<'a> {
self.tcx.sess.struct_span_err(s, m)
}

pub fn struct_span_err_with_code<S: Into<MultiSpan>>(&self,
s: S,
msg: &str,
Expand All @@ -731,10 +722,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.tcx.sess.struct_span_err_with_code(s, msg, code)
}

pub fn span_err_with_code<S: Into<MultiSpan>>(&self, s: S, msg: &str, code: &str) {
self.tcx.sess.span_err_with_code(s, msg, code);
}

fn bckerr_to_diag(&self, err: &BckError<'tcx>) -> DiagnosticBuilder<'a> {
let span = err.span.clone();

Expand Down
45 changes: 0 additions & 45 deletions src/librustc_borrowck/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ pub struct MoveData<'tcx> {
/// kill move bits.
pub path_assignments: RefCell<Vec<Assignment>>,

/// Enum variant matched within a pattern on some match arm, like
/// `SomeStruct{ f: Variant1(x, y) } => ...`
pub variant_matches: RefCell<Vec<VariantMatch>>,

/// Assignments to a variable or path, like `x = foo`, but not `x += foo`.
pub assignee_ids: RefCell<NodeSet>,
}
Expand Down Expand Up @@ -161,21 +157,6 @@ pub struct Assignment {
pub assignee_id: ast::NodeId,
}

#[derive(Copy, Clone)]
pub struct VariantMatch {
/// downcast to the variant.
pub path: MovePathIndex,

/// path being downcast to the variant.
pub base_path: MovePathIndex,

/// id where variant's pattern occurs
pub id: ast::NodeId,

/// says if variant established by move (and why), by copy, or by borrow.
pub mode: euv::MatchMode
}

#[derive(Clone, Copy)]
pub struct MoveDataFlowOperator;

Expand Down Expand Up @@ -215,7 +196,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
moves: RefCell::new(Vec::new()),
path_assignments: RefCell::new(Vec::new()),
var_assignments: RefCell::new(Vec::new()),
variant_matches: RefCell::new(Vec::new()),
assignee_ids: RefCell::new(NodeSet()),
}
}
Expand Down Expand Up @@ -485,31 +465,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
}
}

/// Adds a new record for a match of `base_lp`, downcast to
/// variant `lp`, that occurs at location `pattern_id`. (One
/// should be able to recover the span info from the
/// `pattern_id` and the hir_map, I think.)
pub fn add_variant_match(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
lp: Rc<LoanPath<'tcx>>,
pattern_id: ast::NodeId,
base_lp: Rc<LoanPath<'tcx>>,
mode: euv::MatchMode) {
debug!("add_variant_match(lp={:?}, pattern_id={})",
lp, pattern_id);

let path_index = self.move_path(tcx, lp.clone());
let base_path_index = self.move_path(tcx, base_lp.clone());

let variant_match = VariantMatch {
path: path_index,
base_path: base_path_index,
id: pattern_id,
mode,
};

self.variant_matches.borrow_mut().push(variant_match);
}

/// Adds the gen/kills for the various moves and
/// assignments into the provided data flow contexts.
/// Moves are generated by moves and killed by assignments and
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_borrowck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ extern crate core; // for NonZero

pub use borrowck::check_crate;
pub use borrowck::build_borrowck_dataflow_data_for_fn;
pub use borrowck::{AnalysisData, BorrowckCtxt};

// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
pub mod diagnostics;
mod diagnostics;

mod borrowck;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_const_eval/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern crate syntax_pos;

// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
pub mod diagnostics;
mod diagnostics;

mod eval;
mod _match;
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_const_math/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ impl ConstFloat {
self.ty.ty_to_string()
}

pub fn is_nan(&self) -> bool {
match self.ty {
ast::FloatTy::F32 => Single::from_bits(self.bits).is_nan(),
ast::FloatTy::F64 => Double::from_bits(self.bits).is_nan(),
}
}

/// Compares the values if they are of the same type
pub fn try_cmp(self, rhs: Self) -> Result<Ordering, ConstMathErr> {
match (self.ty, rhs.ty) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/blake2b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::mem;
use std::slice;

#[repr(C)]
pub struct Blake2bCtx {
struct Blake2bCtx {
b: [u8; 128],
h: [u64; 8],
t: [u64; 2],
Expand Down
Loading

0 comments on commit 757b7ac

Please sign in to comment.