Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
47a443c
Duplicate lint specifications are always bug!
Mark-Simulacrum Sep 24, 2019
577d442
De-propagate optional session from lint registration
Mark-Simulacrum Sep 24, 2019
2121b04
Handle lints, not passes in push_lints
Mark-Simulacrum Sep 24, 2019
748eccd
Lints being from a plugin is dependent on the lint, not the registration
Mark-Simulacrum Oct 7, 2019
b060f3b
Split module and crate late pass registration
Mark-Simulacrum Oct 7, 2019
e1079c8
Split out just registration to separate function
Mark-Simulacrum Oct 7, 2019
68c07db
No longer implicitly register lints when registering passes
Mark-Simulacrum Oct 7, 2019
7fef397
Make get_lints be a static function
Mark-Simulacrum Oct 7, 2019
2454512
Take lint passes as constructor functions
Mark-Simulacrum Oct 7, 2019
aa4ee2c
Move to storing constructor functions inside LintStore
Mark-Simulacrum Oct 7, 2019
c1abc30
Make declare_lint take any amount of boolean fields
Mark-Simulacrum Oct 8, 2019
7abb1fa
Remove side table of future incompatibility info
Mark-Simulacrum Oct 9, 2019
c4475c7
Access future incompatibility information directly
Mark-Simulacrum Oct 9, 2019
da56d1d
Remove all borrows of lint store from Session from librustc
Mark-Simulacrum Oct 9, 2019
dab3bd6
Create lint store during plugin registration
Mark-Simulacrum Oct 9, 2019
b761367
Fix test fallout
Mark-Simulacrum Oct 9, 2019
6be0a70
Update API to be more compatible with plugin needs
Mark-Simulacrum Oct 10, 2019
4e8d1b2
Add some documentation
Mark-Simulacrum Oct 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add some documentation
  • Loading branch information
Mark-Simulacrum committed Oct 22, 2019
commit 4e8d1b229217c7c83ce96b44410ccae9470db973
24 changes: 16 additions & 8 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,31 @@ impl LintStore {
.collect()
}

pub fn register_early_pass(&mut self,
pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync) {
pub fn register_early_pass(
&mut self,
pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync
) {
self.early_passes.push(Box::new(pass));
}

pub fn register_pre_expansion_pass(&mut self,
pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync) {
pub fn register_pre_expansion_pass(
&mut self,
pass: impl Fn() -> EarlyLintPassObject + 'static + sync::Send + sync::Sync,
) {
self.pre_expansion_passes.push(Box::new(pass));
}

pub fn register_late_pass(&mut self,
pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync) {
pub fn register_late_pass(
&mut self,
pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync,
) {
self.late_passes.push(Box::new(pass));
}

pub fn register_late_mod_pass(&mut self,
pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync) {
pub fn register_late_mod_pass(
&mut self,
pass: impl Fn() -> LateLintPassObject + 'static + sync::Send + sync::Sync,
) {
self.late_module_passes.push(Box::new(pass));
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T {
pub trait Callbacks {
/// Called before creating the compiler instance
fn config(&mut self, _config: &mut interface::Config) {}
/// Called early during compilation to allow other drivers to easily register lints.
fn extra_lints(&mut self, _ls: &mut lint::LintStore) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: doc-comment

/// Called after parsing. Return value instructs the compiler whether to
/// continue the compilation afterwards (defaults to `Compilation::Continue`)
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_interface/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ pub struct Config {
pub crate_name: Option<String>,
pub lint_caps: FxHashMap<lint::LintId, lint::Level>,

/// This is a callback from the driver that is called when we're registering lints;
/// it is called during plugin registration when we have the LintStore in a non-shared state.
///
/// Note that if you find a Some here you probably want to call that function in the new
/// function being registered.
pub register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have a comment here. Something like:


Callback that is invoked during lint registration. Use the &mut LintStore value to register new lints with the compiler as needed.

}

Expand Down
1 change: 1 addition & 0 deletions src/librustc_plugin/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Registry<'a> {
/// from the plugin registrar.
pub sess: &'a Session,

/// The `LintStore` allows plugins to register new lints.
pub lint_store: &'a mut LintStore,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: doc-comment, I think something simple like this would suffice


The LintStore permits plugins to register new lints.


#[doc(hidden)]
Expand Down