Skip to content

Commit dc6b8ed

Browse files
committed
Remove dead code
Revert some `pub(crate)`s to `pub`s to make sure Miri and Clippy work Revert some `pub(crate)`s to `pub`s to address Michael Woerister's comments
1 parent 532bb60 commit dc6b8ed

File tree

76 files changed

+158
-1406
lines changed

Some content is hidden

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

76 files changed

+158
-1406
lines changed

src/librustc_allocator/lib.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(warnings)]
11+
#![deny(warnings)]
1212

1313
#![feature(rustc_private)]
1414

@@ -24,69 +24,58 @@ pub static ALLOCATOR_METHODS: &[AllocatorMethod] = &[
2424
name: "alloc",
2525
inputs: &[AllocatorTy::Layout],
2626
output: AllocatorTy::ResultPtr,
27-
is_unsafe: true,
2827
},
2928
AllocatorMethod {
3029
name: "oom",
3130
inputs: &[AllocatorTy::AllocErr],
3231
output: AllocatorTy::Bang,
33-
is_unsafe: false,
3432
},
3533
AllocatorMethod {
3634
name: "dealloc",
3735
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout],
3836
output: AllocatorTy::Unit,
39-
is_unsafe: true,
4037
},
4138
AllocatorMethod {
4239
name: "usable_size",
4340
inputs: &[AllocatorTy::LayoutRef],
4441
output: AllocatorTy::UsizePair,
45-
is_unsafe: false,
4642
},
4743
AllocatorMethod {
4844
name: "realloc",
4945
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
5046
output: AllocatorTy::ResultPtr,
51-
is_unsafe: true,
5247
},
5348
AllocatorMethod {
5449
name: "alloc_zeroed",
5550
inputs: &[AllocatorTy::Layout],
5651
output: AllocatorTy::ResultPtr,
57-
is_unsafe: true,
5852
},
5953
AllocatorMethod {
6054
name: "alloc_excess",
6155
inputs: &[AllocatorTy::Layout],
6256
output: AllocatorTy::ResultExcess,
63-
is_unsafe: true,
6457
},
6558
AllocatorMethod {
6659
name: "realloc_excess",
6760
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
6861
output: AllocatorTy::ResultExcess,
69-
is_unsafe: true,
7062
},
7163
AllocatorMethod {
7264
name: "grow_in_place",
7365
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
7466
output: AllocatorTy::ResultUnit,
75-
is_unsafe: true,
7667
},
7768
AllocatorMethod {
7869
name: "shrink_in_place",
7970
inputs: &[AllocatorTy::Ptr, AllocatorTy::Layout, AllocatorTy::Layout],
8071
output: AllocatorTy::ResultUnit,
81-
is_unsafe: true,
8272
},
8373
];
8474

8575
pub struct AllocatorMethod {
8676
pub name: &'static str,
8777
pub inputs: &'static [AllocatorTy],
8878
pub output: AllocatorTy,
89-
pub(crate) is_unsafe: bool,
9079
}
9180

9281
pub enum AllocatorTy {

src/librustc_back/dynamic_lib.rs

Lines changed: 2 additions & 34 deletions
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(crate) 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(crate) 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(crate) 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/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2828
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2929
html_root_url = "https://doc.rust-lang.org/nightly/")]
30-
#![allow(warnings)]
30+
#![deny(warnings)]
3131

3232
#![feature(box_syntax)]
3333
#![feature(const_fn)]

src/librustc_back/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ pub fn ref_slice<T>(ptr: &T) -> &[T; 1] {
1414
unsafe { mem::transmute(ptr) }
1515
}
1616

17-
pub(crate) fn mut_ref_slice<T>(ptr: &mut T) -> &mut [T; 1] {
17+
pub fn mut_ref_slice<T>(ptr: &mut T) -> &mut [T; 1] {
1818
unsafe { mem::transmute(ptr) }
1919
}

src/librustc_back/tempdir.rs

Lines changed: 0 additions & 9 deletions
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(crate) 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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,6 @@ pub(crate) 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(crate) 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(crate) 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

Lines changed: 0 additions & 6 deletions
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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
672672
err.emit();
673673
}
674674

675-
pub(crate) fn span_err(&self, s: Span, m: &str) {
676-
self.tcx.sess.span_err(s, m);
677-
}
678-
679-
pub(crate) fn struct_span_err<S: Into<MultiSpan>>(&self, s: S, m: &str)
680-
-> DiagnosticBuilder<'a> {
681-
self.tcx.sess.struct_span_err(s, m)
682-
}
683-
684675
pub(crate) fn struct_span_err_with_code<S: Into<MultiSpan>>(&self,
685676
s: S,
686677
msg: &str,
@@ -689,10 +680,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
689680
self.tcx.sess.struct_span_err_with_code(s, msg, code)
690681
}
691682

692-
pub(crate) fn span_err_with_code<S: Into<MultiSpan>>(&self, s: S, msg: &str, code: &str) {
693-
self.tcx.sess.span_err_with_code(s, msg, code);
694-
}
695-
696683
fn bckerr_to_diag(&self, err: &BckError<'tcx>) -> DiagnosticBuilder<'a> {
697684
let span = err.span.clone();
698685

src/librustc_borrowck/borrowck/move_data.rs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ pub(crate) struct MoveData<'tcx> {
5353
/// kill move bits.
5454
pub(crate) 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(crate) variant_matches: RefCell<Vec<VariantMatch>>,
59-
6056
/// Assignments to a variable or path, like `x = foo`, but not `x += foo`.
6157
pub(crate) assignee_ids: RefCell<NodeSet>,
6258
}
@@ -156,25 +152,10 @@ pub(crate) struct Assignment {
156152

157153
/// span of node where assignment occurs
158154
pub(crate) span: Span,
159-
160-
/// id for l-value expression on lhs of assignment
161-
pub(crate) assignee_id: ast::NodeId,
162155
}
163156

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

179160
#[derive(Clone, Copy)]
180161
pub(crate) struct MoveDataFlowOperator;
@@ -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
}
@@ -460,7 +440,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
460440
path: path_index,
461441
id: assign_id,
462442
span: span,
463-
assignee_id: assignee_id,
464443
};
465444

466445
if self.is_var_path(path_index) {
@@ -476,31 +455,6 @@ impl<'a, 'tcx> MoveData<'tcx> {
476455
}
477456
}
478457

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

src/librustc_borrowck/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1515
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1616
html_root_url = "https://doc.rust-lang.org/nightly/")]
17-
#![allow(warnings)]
17+
#![deny(warnings)]
1818

1919
#![allow(non_camel_case_types)]
2020

@@ -39,7 +39,6 @@ extern crate core; // for NonZero
3939

4040
pub use borrowck::check_crate;
4141
pub use borrowck::build_borrowck_dataflow_data_for_fn;
42-
pub(crate) use borrowck::{AnalysisData, BorrowckCtxt};
4342

4443
// NB: This module needs to be declared first so diagnostics are
4544
// registered before they are used.

src/librustc_const_eval/eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ macro_rules! math {
5454
///
5555
/// `substs` is optional and is used for associated constants.
5656
/// This generally happens in late/trans const evaluation.
57-
pub(crate) fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
57+
pub fn lookup_const_by_id<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
5858
def_id: DefId,
5959
substs: &'tcx Substs<'tcx>)
6060
-> Option<(DefId, &'tcx Substs<'tcx>)> {

src/librustc_const_eval/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2121
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2222
html_root_url = "https://doc.rust-lang.org/nightly/")]
23-
#![allow(warnings)]
23+
#![deny(warnings)]
2424

2525
#![feature(rustc_diagnostic_macros)]
2626
#![feature(slice_patterns)]

src/librustc_const_math/float.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ impl ConstFloat {
3030
}
3131
}
3232

33-
pub(crate) fn is_nan(&self) -> bool {
34-
match *self {
35-
F32(f) => f.is_nan(),
36-
F64(f) => f.is_nan(),
37-
}
38-
}
39-
4033
/// Compares the values if they are of the same type
4134
pub fn try_cmp(self, rhs: Self) -> Result<Ordering, ConstMathErr> {
4235
match (self, rhs) {

src/librustc_const_math/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl ConstInt {
315315
}
316316
}
317317

318-
pub(crate) fn int_type(self) -> IntType {
318+
pub fn int_type(self) -> IntType {
319319
match self {
320320
ConstInt::I8(_) => IntType::SignedInt(IntTy::I8),
321321
ConstInt::I16(_) => IntType::SignedInt(IntTy::I16),

src/librustc_const_math/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2121
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2222
html_root_url = "https://doc.rust-lang.org/nightly/")]
23-
#![allow(warnings)]
23+
#![deny(warnings)]
2424

2525
#![feature(const_fn)]
2626
#![feature(i128)]

0 commit comments

Comments
 (0)