rust-clippy/tests/ui-internal/invalid_msrv_attr_impl.fixed
flip1995 bca4ee7971
Implement internal lint for MSRV lints
This internal lint checks if the `extract_msrv_attrs!` macro is used if
a lint has a MSRV. If not, it suggests to add this attribute to the lint
pass implementation.
2022-03-01 09:40:07 +00:00

40 lines
871 B
Rust

// run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]
extern crate rustc_ast;
extern crate rustc_hir;
extern crate rustc_lint;
extern crate rustc_middle;
#[macro_use]
extern crate rustc_session;
use clippy_utils::extract_msrv_attr;
use rustc_hir::Expr;
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
use rustc_semver::RustcVersion;
declare_lint! {
pub TEST_LINT,
Warn,
""
}
struct Pass {
msrv: Option<RustcVersion>,
}
impl_lint_pass!(Pass => [TEST_LINT]);
impl LateLintPass<'_> for Pass {
extract_msrv_attr!(LateContext);
fn check_expr(&mut self, _: &LateContext<'_>, _: &Expr<'_>) {}
}
impl EarlyLintPass for Pass {
extract_msrv_attr!(EarlyContext);
fn check_expr(&mut self, _: &EarlyContext<'_>, _: &rustc_ast::Expr) {}
}
fn main() {}