Skip to content

Commit

Permalink
Remove dead code for encoding/decoding lint IDs
Browse files Browse the repository at this point in the history
This helps decouple the lint system from needing the implicit TLS TyCtxt
as well.
  • Loading branch information
Mark-Simulacrum committed Nov 12, 2019
1 parent 5dda3ee commit 8c29b74
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use crate::util::common::time;
use errors::DiagnosticBuilder;
use std::slice;
use rustc_data_structures::sync::{self, ParallelIterator, join, par_iter};
use rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
use syntax::ast;
use syntax::util::lev_distance::find_best_match_for_name;
use syntax::visit as ast_visit;
Expand Down Expand Up @@ -71,7 +70,7 @@ pub struct LintStore {

/// Lints that are buffered up early on in the `Session` before the
/// `LintLevels` is calculated
#[derive(PartialEq, RustcEncodable, RustcDecodable, Debug)]
#[derive(PartialEq, Debug)]
pub struct BufferedEarlyLint {
pub lint_id: LintId,
pub ast_id: ast::NodeId,
Expand Down Expand Up @@ -1574,27 +1573,3 @@ pub fn check_ast_crate<T: EarlyLintPass>(
}
}
}

impl Encodable for LintId {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
s.emit_str(&self.lint.name.to_lowercase())
}
}

impl Decodable for LintId {
#[inline]
fn decode<D: Decoder>(d: &mut D) -> Result<LintId, D::Error> {
let s = d.read_str()?;
ty::tls::with(|tcx| {
match tcx.lint_store.find_lints(&s) {
Ok(ids) => {
if ids.len() != 0 {
panic!("invalid lint-id `{}`", s);
}
Ok(ids[0])
}
Err(_) => panic!("invalid lint-id `{}`", s),
}
})
}
}

0 comments on commit 8c29b74

Please sign in to comment.