dylint_linting
This crate provides the following macros to help in creating Dylint libraries:
dylint_library!
declare_late_lint!
,declare_early_lint!
,declare_pre_expansion_lint!
impl_late_lint!
,impl_early_lint!
,impl_pre_expansion_lint!
dylint_library!
The dylint_library!
macro expands to the following:
extern crate rustc_driver;
pub extern "C"
If your library uses the dylint_library!
macro and the dylint-link
tool, then all you should have to do is implement the register_lints
function. See the examples in this repository.
declare_late_lint!
, etc.
If your library contains just one lint, using declare_late_lint!
, etc. can make your code more concise. Each of these macros requires the same arguments as declare_lint!
, and wraps the following:
- a call to
dylint_library!
- an implementation of the
register_lints
function - a call to
declare_lint!
- a call to
declare_lint_pass!
For example, declare_late_lint!(vis NAME, Level, "description")
expands to the following:
!;
extern crate rustc_lint;
extern crate rustc_session;
declare_lint!;
declare_lint_pass!;
dylint_library
declare_early_lint!
and declare_pre_expansion_lint!
are defined similarly.
impl_late_lint!
, etc.
impl_late_lint!
, etc. are like declare_late_lint!
, etc. except:
- each calls
impl_lint_pass!
instead ofdeclare_lint_pass!
; - each requires an additional argument to specify the default value of the lint's
LintPass
structure.
That is, impl_late_lint!
's additional argument is what goes here:
lint_store.register_late_pass;
^^^
An example use of impl_pre_expansion_lint!
can be found in env_cargo_path in this repository.