//! `LintPass` (also, note that such lints will need to be defined in
//! `rustc::lint::builtin`, not here).
//!
-//! If you define a new `LintPass`, you will also need to add it to the
-//! `add_builtin!` or `add_builtin_with_new!` invocation in `lib.rs`.
-//! Use the former for unit-like structs and the latter for structs with
-//! a `pub fn new()`.
+//! If you define a new `EarlyLintPass`, you will also need to add it to the
+//! `add_early_builtin!` or `add_early_builtin_with_new!` invocation in
+//! `lib.rs`. Use the former for unit-like structs and the latter for structs
+//! with a `pub fn new()`.
+//!
+//! If you define a new `LateLintPass`, you will also need to add it to the
+//! `late_lint_methods!` invocation in `lib.rs`.
use rustc::hir::def::Def;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
}
fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
- let ty = cx.tables.node_id_to_type(e.hir_id);
+ let ty = cx.tables.node_type(e.hir_id);
self.check_heap_type(cx, e.span, ty);
}
}
}
pub struct MissingDoc {
- /// Stack of whether #[doc(hidden)] is set
- /// at each level which has lint attributes.
+ /// Stack of whether `#[doc(hidden)]` is set at each level which has lint attributes.
doc_hidden_stack: Vec<bool>,
/// Private traits or trait items that leaked through. Don't check their methods.
"detects anonymous parameters"
}
-/// Checks for use of anonymous parameters (RFC 1685)
-#[derive(Clone)]
+/// Checks for use of anonymous parameters (RFC 1685).
+#[derive(Copy, Clone)]
pub struct AnonymousParameters;
impl LintPass for AnonymousParameters {
}
}
-/// Checks for use of attributes which have been deprecated.
+/// Check for use of attributes which have been deprecated.
#[derive(Clone)]
pub struct DeprecatedAttr {
// This is not free to compute, so we want to keep it around, rather than
for param in &generics.params {
match param.kind {
GenericParamKind::Lifetime { .. } => {}
- GenericParamKind::Type { .. } => {
- let mut err = cx.struct_span_lint(NO_MANGLE_GENERIC_ITEMS,
- it.span,
- "functions generic over \
- types must be mangled");
+ GenericParamKind::Type { .. } |
+ GenericParamKind::Const { .. } => {
+ let mut err = cx.struct_span_lint(
+ NO_MANGLE_GENERIC_ITEMS,
+ it.span,
+ "functions generic over types or consts must be mangled",
+ );
err.span_suggestion_short(
no_mangle_attr.span,
"remove this attribute",
if !def_id_is_transmute(cx, did) {
return None;
}
- let sig = cx.tables.node_id_to_type(expr.hir_id).fn_sig(cx.tcx);
+ let sig = cx.tables.node_type(expr.hir_id).fn_sig(cx.tcx);
let from = sig.inputs().skip_binder()[0];
let to = *sig.output().skip_binder();
return Some((&from.sty, &to.sty));
}
}
-/// Lint for items marked `pub` that aren't reachable from other crates
+/// Lint for items marked `pub` that aren't reachable from other crates.
+#[derive(Copy, Clone)]
pub struct UnreachablePub;
declare_lint! {
}
}
-/// Lint for trait and lifetime bounds in type aliases being mostly ignored:
+/// Lint for trait and lifetime bounds in type aliases being mostly ignored.
/// They are relevant when using associated types, but otherwise neither checked
/// at definition site nor enforced at use site.
"detects edition keywords being used as an identifier"
}
-/// Checks for uses of edition keywords used as an identifier
-#[derive(Clone)]
+/// Check for uses of edition keywords used as an identifier.
+#[derive(Copy, Clone)]
pub struct KeywordIdents;
impl LintPass for KeywordIdents {
for param in &generics.params {
let param_name = match param.kind {
- hir::GenericParamKind::Lifetime { .. } => { continue; },
+ hir::GenericParamKind::Lifetime { .. } => continue,
hir::GenericParamKind::Type { .. } => {
match param.name {
- hir::ParamName::Fresh(_) => { continue; },
- hir::ParamName::Error => { continue; },
- hir::ParamName::Plain(name) => name.to_string()
+ hir::ParamName::Fresh(_) => continue,
+ hir::ParamName::Error => continue,
+ hir::ParamName::Plain(name) => name.to_string(),
}
}
+ hir::GenericParamKind::Const { .. } => continue,
};
let bound_spans = self.collect_outlives_bound_spans(
cx, def_id, ¶m_name, ¶m.bounds, infer_static