dylint_linting

This crate provides the following macros to help in creating [Dylint] libraries:

dylint_library!

The dylint_library! macro expands to the following:

```rust

[allow(unusedexterncrates)]

extern crate rustc_driver;

[no_mangle]

pub extern "C" fn dylintversion() -> *mut std::os::raw::cchar { std::ffi::CString::new($crate::DYLINTVERSION) .unwrap() .intoraw() } ```

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:

For example, declare_late_lint!(vis NAME, Level, "description") expands to the following:

```rust dylintlinting::dylintlibrary!();

extern crate rustclint; extern crate rustcsession;

[no_mangle]

pub fn registerlints(sess: &rustcsession::Session, lintstore: &mut rustclint::LintStore) { lintstore.registerlints(&[NAME]); lintstore.registerlatepass(|| Box::new(Name)); }

rustcsession::declarelint!(vis NAME, Level, "description");

rustcsession::declarelint_pass!(Name => [NAME]); ```

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:

That is, impl_late_lint!'s additional argument is what goes here:

rust lint_store.register_late_pass(|| Box::new(...)); ^^^

An example use of impl_pre_expansion_lint! can be found in [envcargopath] in this repository.