-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Change clippy's symbol interning strategy to be reentrant #60907
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
Changes from all commits
a1fcc76
cd48f0d
e3fe4cf
f62c5cc
4f3be11
2b01df7
e9722da
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ __pycache__/ | |
.project | ||
.settings/ | ||
.valgrindrc | ||
.vscode/ | ||
.vscode | ||
.favorites.json | ||
/*-*-*-*/ | ||
/*-*-*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,21 +82,23 @@ pub struct Globals { | |
} | ||
|
||
impl Globals { | ||
fn new() -> Globals { | ||
/// See documentation on `syntax_pos::Globals` for information on the slice. | ||
/// It is solely forwareded to `syntax_pos::Globals::new` | ||
fn new(driver_symbols: &[&str]) -> Globals { | ||
Globals { | ||
// We have no idea how many attributes their will be, so just | ||
// initiate the vectors with 0 bits. We'll grow them as necessary. | ||
used_attrs: Lock::new(GrowableBitSet::new_empty()), | ||
known_attrs: Lock::new(GrowableBitSet::new_empty()), | ||
syntax_pos_globals: syntax_pos::Globals::new(), | ||
syntax_pos_globals: syntax_pos::Globals::new(driver_symbols), | ||
} | ||
} | ||
} | ||
|
||
pub fn with_globals<F, R>(f: F) -> R | ||
pub fn with_globals<F, R>(driver_symbols: &[&str], f: F) -> R | ||
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.
Too bad Rust still doesn't have default fn parameters to write 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. I was considering that, but it seemed too error prone (since it's too easy to forget to do somewhere). |
||
where F: FnOnce() -> R | ||
{ | ||
let globals = Globals::new(); | ||
let globals = Globals::new(driver_symbols); | ||
GLOBALS.set(&globals, || { | ||
syntax_pos::GLOBALS.set(&globals.syntax_pos_globals, f) | ||
}) | ||
|
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.
I'm not sure this one needs the extra symbols.
It's a "leaf" function that shouldn't delegate to any tool-specific functionality.
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.
It should not need any symbols at all I believe. Would you mind if I did that change in a separate PR?
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.
It needs symbols because it parses paths and therefore needs to use at least
self
/super
/etc.I guess it's ok to leave this as is because I'm not entirely sure that parsing cannot be intercepted by a tool now or in the future.