mirror of https://github.com/rust-lang/rust.git
Remove unused code from remaining compiler crates
This commit is contained in:
parent
58b3923ad3
commit
215cd36e1c
|
@ -14,12 +14,6 @@ pub struct WorkQueue<T: Idx> {
|
|||
}
|
||||
|
||||
impl<T: Idx> WorkQueue<T> {
|
||||
/// Creates a new work queue with all the elements from (0..len).
|
||||
#[inline]
|
||||
pub fn with_all(len: usize) -> Self {
|
||||
WorkQueue { deque: (0..len).map(T::new).collect(), set: BitSet::new_filled(len) }
|
||||
}
|
||||
|
||||
/// Creates a new work queue that starts empty, where elements range from (0..len).
|
||||
#[inline]
|
||||
pub fn with_none(len: usize) -> Self {
|
||||
|
|
|
@ -121,11 +121,6 @@ impl Diagnostic {
|
|||
self.level == Level::Cancelled
|
||||
}
|
||||
|
||||
/// Set the sorting span.
|
||||
pub fn set_sort_span(&mut self, sp: Span) {
|
||||
self.sort_span = sp;
|
||||
}
|
||||
|
||||
/// Adds a span/label to be included in the resulting snippet.
|
||||
///
|
||||
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
|
||||
|
@ -535,14 +530,6 @@ impl Diagnostic {
|
|||
&self.message
|
||||
}
|
||||
|
||||
/// Used by a lint. Copies over all details *but* the "main
|
||||
/// message".
|
||||
pub fn copy_details_not_message(&mut self, from: &Diagnostic) {
|
||||
self.span = from.span.clone();
|
||||
self.code = from.code.clone();
|
||||
self.children.extend(from.children.iter().cloned())
|
||||
}
|
||||
|
||||
/// Convenience function for internal use, clients should use one of the
|
||||
/// public methods above.
|
||||
pub fn sub(
|
||||
|
|
|
@ -510,8 +510,6 @@ impl Emitter for SilentEmitter {
|
|||
fn emit_diagnostic(&mut self, _: &Diagnostic) {}
|
||||
}
|
||||
|
||||
/// Maximum number of lines we will print for each error; arbitrary.
|
||||
pub const MAX_HIGHLIGHT_LINES: usize = 6;
|
||||
/// Maximum number of lines we will print for a multiline suggestion; arbitrary.
|
||||
///
|
||||
/// This should be replaced with a more involved mechanism to output multiline suggestions that
|
||||
|
|
|
@ -148,17 +148,6 @@ impl Annotatable {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn map_item_or<F, G>(self, mut f: F, mut or: G) -> Annotatable
|
||||
where
|
||||
F: FnMut(P<ast::Item>) -> P<ast::Item>,
|
||||
G: FnMut(Annotatable) -> Annotatable,
|
||||
{
|
||||
match self {
|
||||
Annotatable::Item(i) => Annotatable::Item(f(i)),
|
||||
_ => or(self),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_trait_item(self) -> P<ast::AssocItem> {
|
||||
match self {
|
||||
Annotatable::TraitItem(i) => i,
|
||||
|
@ -1052,9 +1041,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
.chain(components.iter().map(|&s| Ident::with_dummy_span(s)))
|
||||
.collect()
|
||||
}
|
||||
pub fn name_of(&self, st: &str) -> Symbol {
|
||||
Symbol::intern(st)
|
||||
}
|
||||
|
||||
pub fn check_unused_macros(&mut self) {
|
||||
self.resolver.check_unused_macros();
|
||||
|
|
|
@ -139,24 +139,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
ast::Lifetime { id: ast::DUMMY_NODE_ID, ident: ident.with_span_pos(span) }
|
||||
}
|
||||
|
||||
pub fn lifetime_def(
|
||||
&self,
|
||||
span: Span,
|
||||
ident: Ident,
|
||||
attrs: Vec<ast::Attribute>,
|
||||
bounds: ast::GenericBounds,
|
||||
) -> ast::GenericParam {
|
||||
let lifetime = self.lifetime(span, ident);
|
||||
ast::GenericParam {
|
||||
ident: lifetime.ident,
|
||||
id: lifetime.id,
|
||||
attrs: attrs.into(),
|
||||
bounds,
|
||||
kind: ast::GenericParamKind::Lifetime,
|
||||
is_placeholder: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stmt_expr(&self, expr: P<ast::Expr>) -> ast::Stmt {
|
||||
ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
|
@ -465,24 +447,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
self.pat_tuple_struct(span, path, vec![pat])
|
||||
}
|
||||
|
||||
pub fn pat_none(&self, span: Span) -> P<ast::Pat> {
|
||||
let some = self.std_path(&[sym::option, sym::Option, sym::None]);
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_path(span, path)
|
||||
}
|
||||
|
||||
pub fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
||||
let some = self.std_path(&[sym::result, sym::Result, sym::Ok]);
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_tuple_struct(span, path, vec![pat])
|
||||
}
|
||||
|
||||
pub fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
||||
let some = self.std_path(&[sym::result, sym::Result, sym::Err]);
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_tuple_struct(span, path, vec![pat])
|
||||
}
|
||||
|
||||
pub fn arm(&self, span: Span, pat: P<ast::Pat>, expr: P<ast::Expr>) -> ast::Arm {
|
||||
ast::Arm {
|
||||
attrs: vec![],
|
||||
|
@ -514,26 +478,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
self.expr(span, ast::ExprKind::If(cond, self.block_expr(then), els))
|
||||
}
|
||||
|
||||
pub fn lambda_fn_decl(
|
||||
&self,
|
||||
span: Span,
|
||||
fn_decl: P<ast::FnDecl>,
|
||||
body: P<ast::Expr>,
|
||||
fn_decl_span: Span,
|
||||
) -> P<ast::Expr> {
|
||||
self.expr(
|
||||
span,
|
||||
ast::ExprKind::Closure(
|
||||
ast::CaptureBy::Ref,
|
||||
ast::Async::No,
|
||||
ast::Movability::Movable,
|
||||
fn_decl,
|
||||
body,
|
||||
fn_decl_span,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn lambda(&self, span: Span, ids: Vec<Ident>, body: P<ast::Expr>) -> P<ast::Expr> {
|
||||
let fn_decl = self.fn_decl(
|
||||
ids.iter().map(|id| self.param(span, *id, self.ty(span, ast::TyKind::Infer))).collect(),
|
||||
|
@ -610,47 +554,6 @@ impl<'a> ExtCtxt<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn variant(&self, span: Span, ident: Ident, tys: Vec<P<ast::Ty>>) -> ast::Variant {
|
||||
let vis_span = span.shrink_to_lo();
|
||||
let fields: Vec<_> = tys
|
||||
.into_iter()
|
||||
.map(|ty| ast::StructField {
|
||||
span: ty.span,
|
||||
ty,
|
||||
ident: None,
|
||||
vis: ast::Visibility {
|
||||
span: vis_span,
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
attrs: Vec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
is_placeholder: false,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let vdata = if fields.is_empty() {
|
||||
ast::VariantData::Unit(ast::DUMMY_NODE_ID)
|
||||
} else {
|
||||
ast::VariantData::Tuple(fields, ast::DUMMY_NODE_ID)
|
||||
};
|
||||
|
||||
ast::Variant {
|
||||
attrs: Vec::new(),
|
||||
data: vdata,
|
||||
disr_expr: None,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
ident,
|
||||
vis: ast::Visibility {
|
||||
span: vis_span,
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
span,
|
||||
is_placeholder: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn item_static(
|
||||
&self,
|
||||
span: Span,
|
||||
|
|
|
@ -75,33 +75,6 @@ pub fn link_or_copy<P: AsRef<Path>, Q: AsRef<Path>>(p: P, q: Q) -> io::Result<Li
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum RenameOrCopyRemove {
|
||||
Rename,
|
||||
CopyRemove,
|
||||
}
|
||||
|
||||
/// Rename `p` into `q`, preferring to use `rename` if possible.
|
||||
/// If `rename` fails (rename may fail for reasons such as crossing
|
||||
/// filesystem), fallback to copy & remove
|
||||
pub fn rename_or_copy_remove<P: AsRef<Path>, Q: AsRef<Path>>(
|
||||
p: P,
|
||||
q: Q,
|
||||
) -> io::Result<RenameOrCopyRemove> {
|
||||
let p = p.as_ref();
|
||||
let q = q.as_ref();
|
||||
match fs::rename(p, q) {
|
||||
Ok(()) => Ok(RenameOrCopyRemove::Rename),
|
||||
Err(_) => match fs::copy(p, q) {
|
||||
Ok(_) => {
|
||||
fs::remove_file(p)?;
|
||||
Ok(RenameOrCopyRemove::CopyRemove)
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn path_to_c_string(p: &Path) -> CString {
|
||||
use std::ffi::OsStr;
|
||||
|
|
|
@ -44,9 +44,6 @@ pub trait PpAnn {
|
|||
fn nested(&self, _state: &mut State<'_>, _nested: Nested) {}
|
||||
fn pre(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
|
||||
fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) {}
|
||||
fn try_fetch_item(&self, _: hir::HirId) -> Option<&hir::Item<'_>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NoAnn;
|
||||
|
@ -54,9 +51,6 @@ impl PpAnn for NoAnn {}
|
|||
pub const NO_ANN: &dyn PpAnn = &NoAnn;
|
||||
|
||||
impl PpAnn for hir::Crate<'_> {
|
||||
fn try_fetch_item(&self, item: hir::HirId) -> Option<&hir::Item<'_>> {
|
||||
Some(self.item(item))
|
||||
}
|
||||
fn nested(&self, state: &mut State<'_>, nested: Nested) {
|
||||
match nested {
|
||||
Nested::Item(id) => state.print_item(self.item(id.id)),
|
||||
|
|
|
@ -711,10 +711,6 @@ impl<'tcx> LateContext<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn current_lint_root(&self) -> hir::HirId {
|
||||
self.last_node_with_lint_attrs
|
||||
}
|
||||
|
||||
/// Check if a `DefId`'s path matches the given absolute type path usage.
|
||||
///
|
||||
/// Anonymous scopes such as `extern` imports are matched with `kw::Invalid`;
|
||||
|
|
|
@ -313,27 +313,6 @@ impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> {
|
|||
Ok(ty)
|
||||
}
|
||||
|
||||
fn cached_predicate_for_shorthand<F>(
|
||||
&mut self,
|
||||
shorthand: usize,
|
||||
or_insert_with: F,
|
||||
) -> Result<ty::Predicate<'tcx>, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<ty::Predicate<'tcx>, Self::Error>,
|
||||
{
|
||||
let tcx = self.tcx();
|
||||
|
||||
let key = ty::CReaderCacheKey { cnum: self.cdata().cnum, pos: shorthand };
|
||||
|
||||
if let Some(&pred) = tcx.pred_rcache.borrow().get(&key) {
|
||||
return Ok(pred);
|
||||
}
|
||||
|
||||
let pred = or_insert_with(self)?;
|
||||
tcx.pred_rcache.borrow_mut().insert(key, pred);
|
||||
Ok(pred)
|
||||
}
|
||||
|
||||
fn with_position<F, R>(&mut self, pos: usize, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut Self) -> R,
|
||||
|
|
|
@ -62,15 +62,6 @@ where
|
|||
let blocks = mir::traversal::reachable(body);
|
||||
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
|
||||
}
|
||||
|
||||
pub fn visit_in_rpo_with(
|
||||
&self,
|
||||
body: &'mir mir::Body<'tcx>,
|
||||
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
|
||||
) {
|
||||
let blocks = mir::traversal::reverse_postorder(body);
|
||||
visit_results(body, blocks.map(|(bb, _)| bb), self, vis)
|
||||
}
|
||||
}
|
||||
|
||||
/// A solver for dataflow problems.
|
||||
|
|
|
@ -114,16 +114,6 @@ pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Spa
|
|||
source_file_to_parser(sess, file_to_source_file(sess, path, sp))
|
||||
}
|
||||
|
||||
/// Creates a new parser, returning buffered diagnostics if the file doesn't exist,
|
||||
/// or from lexing the initial token stream.
|
||||
pub fn maybe_new_parser_from_file<'a>(
|
||||
sess: &'a ParseSess,
|
||||
path: &Path,
|
||||
) -> Result<Parser<'a>, Vec<Diagnostic>> {
|
||||
let file = try_file_to_source_file(sess, path, None).map_err(|db| vec![db])?;
|
||||
maybe_source_file_to_parser(sess, file)
|
||||
}
|
||||
|
||||
/// Given a `source_file` and config, returns a parser.
|
||||
fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Parser<'_> {
|
||||
panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file))
|
||||
|
@ -146,12 +136,6 @@ fn maybe_source_file_to_parser(
|
|||
Ok(parser)
|
||||
}
|
||||
|
||||
// Must preserve old name for now, because `quote!` from the *existing*
|
||||
// compiler expands into it.
|
||||
pub fn new_parser_from_tts(sess: &ParseSess, tts: Vec<TokenTree>) -> Parser<'_> {
|
||||
stream_to_parser(sess, tts.into_iter().collect(), crate::MACRO_ARGUMENTS)
|
||||
}
|
||||
|
||||
// Base abstractions
|
||||
|
||||
/// Given a session and a path and an optional span (for error reporting),
|
||||
|
|
|
@ -1586,5 +1586,3 @@ pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
|
|||
let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
|
||||
handler.struct_warn(msg).emit();
|
||||
}
|
||||
|
||||
pub type CompileResult = Result<(), ErrorReported>;
|
||||
|
|
|
@ -290,10 +290,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
pub fn closure_typer(&self) -> &'cx InferCtxt<'cx, 'tcx> {
|
||||
self.infcx
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Selection
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue