/// `declare_lint!()` invocations to follow the convention of upper-case
/// statics without repeating the name.
///
- /// The name is written with underscores, e.g. "unused_imports".
+ /// The name is written with underscores, e.g., "unused_imports".
/// On the command line, underscores become dashes.
pub name: &'static str,
/// Description of the lint or the issue it detects.
///
- /// e.g. "imports that are never used"
+ /// e.g., "imports that are never used"
pub desc: &'static str,
/// Starting at the given edition, default to the given lint level. If this is `None`, then use
pub trait LintPass {
/// Get descriptions of the lints this `LintPass` object can emit.
///
- /// NB: there is no enforcement that the object only emits lints it registered.
+ /// N.B., there is no enforcement that the object only emits lints it registered.
/// And some `rustc` internal `LintPass`es register lints to be emitted by other
/// parts of the compiler. If you want enforced access restrictions for your
/// `Lint`, make it a private `static` item in its own module.
fn check_block_post(&mut self, _: &EarlyContext<'_>, _: &ast::Block) { }
fn check_stmt(&mut self, _: &EarlyContext<'_>, _: &ast::Stmt) { }
fn check_arm(&mut self, _: &EarlyContext<'_>, _: &ast::Arm) { }
- fn check_pat(&mut self, _: &EarlyContext<'_>, _: &ast::Pat) { }
+ fn check_pat(&mut self, _: &EarlyContext<'_>, _: &ast::Pat, _: &mut bool) { }
fn check_expr(&mut self, _: &EarlyContext<'_>, _: &ast::Expr) { }
fn check_expr_post(&mut self, _: &EarlyContext<'_>, _: &ast::Expr) { }
fn check_ty(&mut self, _: &EarlyContext<'_>, _: &ast::Ty) { }
pub use self::levels::{LintLevelSets, LintLevelMap};
+#[derive(Default)]
pub struct LintBuffer {
map: NodeMap<Vec<BufferedEarlyLint>>,
}
impl LintBuffer {
- pub fn new() -> LintBuffer {
- LintBuffer { map: NodeMap() }
- }
-
pub fn add_lint(&mut self,
lint: &'static Lint,
id: ast::NodeId,
levels: LintLevelSets::builder(tcx.sess),
tcx: tcx,
};
- let krate = tcx.hir.krate();
+ let krate = tcx.hir().krate();
builder.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |builder| {
intravisit::walk_crate(builder, krate);
where F: FnOnce(&mut Self)
{
let push = self.levels.push(attrs);
- self.levels.register_id(self.tcx.hir.definitions().node_to_hir_id(id));
+ self.levels.register_id(self.tcx.hir().definitions().node_to_hir_id(id));
f(self);
self.levels.pop(push);
}
impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
- intravisit::NestedVisitorMap::All(&self.tcx.hir)
+ intravisit::NestedVisitorMap::All(&self.tcx.hir())
}
fn visit_item(&mut self, it: &'tcx hir::Item) {