-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Lockless LintStore #65193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lockless LintStore #65193
Changes from 1 commit
47a443c
577d442
2121b04
748eccd
b060f3b
e1079c8
68c07db
7fef397
2454512
aa4ee2c
c1abc30
7abb1fa
c4475c7
da56d1d
dab3bd6
b761367
6be0a70
4e8d1b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) {} | ||
| fn extra_lints(&mut self, _ls: &mut lint::LintStore) {} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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`) | ||
| fn after_parsing(&mut self, _compiler: &interface::Compiler) -> Compilation { | ||
|
|
@@ -182,6 +183,7 @@ pub fn run_compiler( | |
| stderr: None, | ||
| crate_name: None, | ||
| lint_caps: Default::default(), | ||
| register_lints: None, | ||
| }; | ||
| callbacks.config(&mut config); | ||
| config | ||
|
|
@@ -259,6 +261,7 @@ pub fn run_compiler( | |
| stderr: None, | ||
| crate_name: None, | ||
| lint_caps: Default::default(), | ||
| register_lints: None, | ||
| }; | ||
|
|
||
| callbacks.config(&mut config); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ pub struct Compiler { | |
| pub(crate) queries: Queries, | ||
| pub(crate) cstore: Lrc<CStore>, | ||
| pub(crate) crate_name: Option<String>, | ||
| pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>, | ||
| } | ||
|
|
||
| impl Compiler { | ||
|
|
@@ -80,6 +81,8 @@ pub struct Config { | |
|
|
||
| pub crate_name: Option<String>, | ||
| pub lint_caps: FxHashMap<lint::LintId, lint::Level>, | ||
|
|
||
| pub register_lints: Option<Box<dyn Fn(&Session, &mut lint::LintStore) + Send + Sync>>, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
|
|
||
| pub fn run_compiler_in_existing_thread_pool<F, R>(config: Config, f: F) -> R | ||
|
|
@@ -108,6 +111,7 @@ where | |
| output_file: config.output_file, | ||
| queries: Default::default(), | ||
| crate_name: config.crate_name, | ||
| register_lints: config.register_lints, | ||
| }; | ||
|
|
||
| let _sess_abort_error = OnDrop(|| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: put
&mut selfon next line, to align with rustfmt? (Similarly, the) {on the next line)