Skip to content

Commit 215cd36

Browse files
committed
Remove unused code from remaining compiler crates
1 parent 58b3923 commit 215cd36

File tree

13 files changed

+0
-221
lines changed

13 files changed

+0
-221
lines changed

compiler/rustc_data_structures/src/work_queue.rs

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ pub struct WorkQueue<T: Idx> {
1414
}
1515

1616
impl<T: Idx> WorkQueue<T> {
17-
/// Creates a new work queue with all the elements from (0..len).
18-
#[inline]
19-
pub fn with_all(len: usize) -> Self {
20-
WorkQueue { deque: (0..len).map(T::new).collect(), set: BitSet::new_filled(len) }
21-
}
22-
2317
/// Creates a new work queue that starts empty, where elements range from (0..len).
2418
#[inline]
2519
pub fn with_none(len: usize) -> Self {

compiler/rustc_errors/src/diagnostic.rs

-13
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ impl Diagnostic {
121121
self.level == Level::Cancelled
122122
}
123123

124-
/// Set the sorting span.
125-
pub fn set_sort_span(&mut self, sp: Span) {
126-
self.sort_span = sp;
127-
}
128-
129124
/// Adds a span/label to be included in the resulting snippet.
130125
///
131126
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
@@ -535,14 +530,6 @@ impl Diagnostic {
535530
&self.message
536531
}
537532

538-
/// Used by a lint. Copies over all details *but* the "main
539-
/// message".
540-
pub fn copy_details_not_message(&mut self, from: &Diagnostic) {
541-
self.span = from.span.clone();
542-
self.code = from.code.clone();
543-
self.children.extend(from.children.iter().cloned())
544-
}
545-
546533
/// Convenience function for internal use, clients should use one of the
547534
/// public methods above.
548535
pub fn sub(

compiler/rustc_errors/src/emitter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,6 @@ impl Emitter for SilentEmitter {
510510
fn emit_diagnostic(&mut self, _: &Diagnostic) {}
511511
}
512512

513-
/// Maximum number of lines we will print for each error; arbitrary.
514-
pub const MAX_HIGHLIGHT_LINES: usize = 6;
515513
/// Maximum number of lines we will print for a multiline suggestion; arbitrary.
516514
///
517515
/// This should be replaced with a more involved mechanism to output multiline suggestions that

compiler/rustc_expand/src/base.rs

-14
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,6 @@ impl Annotatable {
148148
}
149149
}
150150

151-
pub fn map_item_or<F, G>(self, mut f: F, mut or: G) -> Annotatable
152-
where
153-
F: FnMut(P<ast::Item>) -> P<ast::Item>,
154-
G: FnMut(Annotatable) -> Annotatable,
155-
{
156-
match self {
157-
Annotatable::Item(i) => Annotatable::Item(f(i)),
158-
_ => or(self),
159-
}
160-
}
161-
162151
pub fn expect_trait_item(self) -> P<ast::AssocItem> {
163152
match self {
164153
Annotatable::TraitItem(i) => i,
@@ -1052,9 +1041,6 @@ impl<'a> ExtCtxt<'a> {
10521041
.chain(components.iter().map(|&s| Ident::with_dummy_span(s)))
10531042
.collect()
10541043
}
1055-
pub fn name_of(&self, st: &str) -> Symbol {
1056-
Symbol::intern(st)
1057-
}
10581044

10591045
pub fn check_unused_macros(&mut self) {
10601046
self.resolver.check_unused_macros();

compiler/rustc_expand/src/build.rs

-97
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,6 @@ impl<'a> ExtCtxt<'a> {
139139
ast::Lifetime { id: ast::DUMMY_NODE_ID, ident: ident.with_span_pos(span) }
140140
}
141141

142-
pub fn lifetime_def(
143-
&self,
144-
span: Span,
145-
ident: Ident,
146-
attrs: Vec<ast::Attribute>,
147-
bounds: ast::GenericBounds,
148-
) -> ast::GenericParam {
149-
let lifetime = self.lifetime(span, ident);
150-
ast::GenericParam {
151-
ident: lifetime.ident,
152-
id: lifetime.id,
153-
attrs: attrs.into(),
154-
bounds,
155-
kind: ast::GenericParamKind::Lifetime,
156-
is_placeholder: false,
157-
}
158-
}
159-
160142
pub fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt {
161143
ast::Stmt {
162144
id: ast::DUMMY_NODE_ID,
@@ -465,24 +447,6 @@ impl<'a> ExtCtxt<'a> {
465447
self.pat_tuple_struct(span, path, vec![pat])
466448
}
467449

468-
pub fn pat_none(&self, span: Span) -> P<ast::Pat> {
469-
let some = self.std_path(&[sym::option, sym::Option, sym::None]);
470-
let path = self.path_global(span, some);
471-
self.pat_path(span, path)
472-
}
473-
474-
pub fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
475-
let some = self.std_path(&[sym::result, sym::Result, sym::Ok]);
476-
let path = self.path_global(span, some);
477-
self.pat_tuple_struct(span, path, vec![pat])
478-
}
479-
480-
pub fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
481-
let some = self.std_path(&[sym::result, sym::Result, sym::Err]);
482-
let path = self.path_global(span, some);
483-
self.pat_tuple_struct(span, path, vec![pat])
484-
}
485-
486450
pub fn arm(&self, span: Span, pat: P<ast::Pat>, expr: P<ast::Expr>) -> ast::Arm {
487451
ast::Arm {
488452
attrs: vec![],
@@ -514,26 +478,6 @@ impl<'a> ExtCtxt<'a> {
514478
self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els))
515479
}
516480

517-
pub fn lambda_fn_decl(
518-
&self,
519-
span: Span,
520-
fn_decl: P<ast::FnDecl>,
521-
body: P<ast::Expr>,
522-
fn_decl_span: Span,
523-
) -> P<ast::Expr> {
524-
self.expr(
525-
span,
526-
ast::ExprKind::Closure(
527-
ast::CaptureBy::Ref,
528-
ast::Async::No,
529-
ast::Movability::Movable,
530-
fn_decl,
531-
body,
532-
fn_decl_span,
533-
),
534-
)
535-
}
536-
537481
pub fn lambda(&self, span: Span, ids: Vec<Ident>, body: P<ast::Expr>) -> P<ast::Expr> {
538482
let fn_decl = self.fn_decl(
539483
ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(),
@@ -610,47 +554,6 @@ impl<'a> ExtCtxt<'a> {
610554
})
611555
}
612556

613-
pub fn variant(&self, span: Span, ident: Ident, tys: Vec<P<ast::Ty>>) -> ast::Variant {
614-
let vis_span = span.shrink_to_lo();
615-
let fields: Vec<_> = tys
616-
.into_iter()
617-
.map(|ty| ast::StructField {
618-
span: ty.span,
619-
ty,
620-
ident: None,
621-
vis: ast::Visibility {
622-
span: vis_span,
623-
kind: ast::VisibilityKind::Inherited,
624-
tokens: None,
625-
},
626-
attrs: Vec::new(),
627-
id: ast::DUMMY_NODE_ID,
628-
is_placeholder: false,
629-
})
630-
.collect();
631-
632-
let vdata = if fields.is_empty() {
633-
ast::VariantData::Unit(ast::DUMMY_NODE_ID)
634-
} else {
635-
ast::VariantData::Tuple(fields, ast::DUMMY_NODE_ID)
636-
};
637-
638-
ast::Variant {
639-
attrs: Vec::new(),
640-
data: vdata,
641-
disr_expr: None,
642-
id: ast::DUMMY_NODE_ID,
643-
ident,
644-
vis: ast::Visibility {
645-
span: vis_span,
646-
kind: ast::VisibilityKind::Inherited,
647-
tokens: None,
648-
},
649-
span,
650-
is_placeholder: false,
651-
}
652-
}
653-
654557
pub fn item_static(
655558
&self,
656559
span: Span,

compiler/rustc_fs_util/src/lib.rs

-27
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,6 @@ pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<Li
7575
}
7676
}
7777

78-
#[derive(Debug)]
79-
pub enum RenameOrCopyRemove {
80-
Rename,
81-
CopyRemove,
82-
}
83-
84-
/// Rename `p` into `q`, preferring to use `rename` if possible.
85-
/// If `rename` fails (rename may fail for reasons such as crossing
86-
/// filesystem), fallback to copy & remove
87-
pub fn rename_or_copy_remove<P: AsRef<Path>, Q: AsRef<Path>>(
88-
p: P,
89-
q: Q,
90-
) -> io::Result<RenameOrCopyRemove> {
91-
let p = p.as_ref();
92-
let q = q.as_ref();
93-
match fs::rename(p, q) {
94-
Ok(()) => Ok(RenameOrCopyRemove::Rename),
95-
Err(_) => match fs::copy(p, q) {
96-
Ok(_) => {
97-
fs::remove_file(p)?;
98-
Ok(RenameOrCopyRemove::CopyRemove)
99-
}
100-
Err(e) => Err(e),
101-
},
102-
}
103-
}
104-
10578
#[cfg(unix)]
10679
pub fn path_to_c_string(p: &Path) -> CString {
10780
use std::ffi::OsStr;

compiler/rustc_hir_pretty/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,13 @@ pub trait PpAnn {
4444
fn nested(&self, _state: &mut State<'_>, _nested: Nested) {}
4545
fn pre(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
4646
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
47-
fn try_fetch_item(&self, _: hir::HirId) -> Option<&hir::Item<'_>> {
48-
None
49-
}
5047
}
5148

5249
pub struct NoAnn;
5350
impl PpAnn for NoAnn {}
5451
pub const NO_ANN: &dyn PpAnn = &NoAnn;
5552

5653
impl PpAnn for hir::Crate<'_> {
57-
fn try_fetch_item(&self, item: hir::HirId) -> Option<&hir::Item<'_>> {
58-
Some(self.item(item))
59-
}
6054
fn nested(&self, state: &mut State<'_>, nested: Nested) {
6155
match nested {
6256
Nested::Item(id) => state.print_item(self.item(id.id)),

compiler/rustc_lint/src/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,6 @@ impl<'tcx> LateContext<'tcx> {
711711
}
712712
}
713713

714-
pub fn current_lint_root(&self) -> hir::HirId {
715-
self.last_node_with_lint_attrs
716-
}
717-
718714
/// Check if a `DefId`'s path matches the given absolute type path usage.
719715
///
720716
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;

compiler/rustc_metadata/src/rmeta/decoder.rs

-21
Original file line numberDiff line numberDiff line change
@@ -313,27 +313,6 @@ impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
313313
Ok(ty)
314314
}
315315

316-
fn cached_predicate_for_shorthand<F>(
317-
&mut self,
318-
shorthand: usize,
319-
or_insert_with: F,
320-
) -> Result<ty::Predicate<'tcx>, Self::Error>
321-
where
322-
F: FnOnce(&mut Self) -> Result<ty::Predicate<'tcx>, Self::Error>,
323-
{
324-
let tcx = self.tcx();
325-
326-
let key = ty::CReaderCacheKey { cnum: self.cdata().cnum, pos: shorthand };
327-
328-
if let Some(&pred) = tcx.pred_rcache.borrow().get(&key) {
329-
return Ok(pred);
330-
}
331-
332-
let pred = or_insert_with(self)?;
333-
tcx.pred_rcache.borrow_mut().insert(key, pred);
334-
Ok(pred)
335-
}
336-
337316
fn with_position<F, R>(&mut self, pos: usize, f: F) -> R
338317
where
339318
F: FnOnce(&mut Self) -> R,

compiler/rustc_mir/src/dataflow/framework/engine.rs

-9
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,6 @@ where
6262
let blocks = mir::traversal::reachable(body);
6363
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
6464
}
65-
66-
pub fn visit_in_rpo_with(
67-
&self,
68-
body: &'mir mir::Body<'tcx>,
69-
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
70-
) {
71-
let blocks = mir::traversal::reverse_postorder(body);
72-
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
73-
}
7465
}
7566

7667
/// A solver for dataflow problems.

compiler/rustc_parse/src/lib.rs

-16
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,6 @@ pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Spa
114114
source_file_to_parser(sess, file_to_source_file(sess, path, sp))
115115
}
116116

117-
/// Creates a new parser, returning buffered diagnostics if the file doesn't exist,
118-
/// or from lexing the initial token stream.
119-
pub fn maybe_new_parser_from_file<'a>(
120-
sess: &'a ParseSess,
121-
path: &Path,
122-
) -> Result<Parser<'a>, Vec<Diagnostic>> {
123-
let file = try_file_to_source_file(sess, path, None).map_err(|db| vec![db])?;
124-
maybe_source_file_to_parser(sess, file)
125-
}
126-
127117
/// Given a `source_file` and config, returns a parser.
128118
fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Parser<'_> {
129119
panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file))
@@ -146,12 +136,6 @@ fn maybe_source_file_to_parser(
146136
Ok(parser)
147137
}
148138

149-
// Must preserve old name for now, because `quote!` from the *existing*
150-
// compiler expands into it.
151-
pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser<'_> {
152-
stream_to_parser(sess, tts.into_iter().collect(), crate::MACRO_ARGUMENTS)
153-
}
154-
155139
// Base abstractions
156140

157141
/// Given a session and a path and an optional span (for error reporting),

compiler/rustc_session/src/session.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1586,5 +1586,3 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
15861586
let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
15871587
handler.struct_warn(msg).emit();
15881588
}
1589-
1590-
pub type CompileResult = Result<(), ErrorReported>;

compiler/rustc_trait_selection/src/traits/select/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
290290
self.infcx.tcx
291291
}
292292

293-
pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx> {
294-
self.infcx
295-
}
296-
297293
///////////////////////////////////////////////////////////////////////////
298294
// Selection
299295
//

0 commit comments

Comments
 (0)