Skip to content

Commit c4dc74d

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 152788 b: refs/heads/try2 c: 609552e h: refs/heads/master v: v3
1 parent 88df3b7 commit c4dc74d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c1898b9acb324990367bb6672145c30b51e0399f
8+
refs/heads/try2: 609552e19516299b061687d52094d0b755b213d3
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/lint/context.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ pub struct LintStore {
5656
lints: Vec<(&'static Lint, bool)>,
5757

5858
/// Trait objects for each lint pass.
59-
passes: Vec<RefCell<LintPassObject>>,
59+
/// This is only `None` while iterating over the objects. See the definition
60+
/// of run_lints.
61+
passes: Option<Vec<LintPassObject>>,
6062

6163
/// Lints indexed by name.
6264
by_name: HashMap<&'static str, LintId>,
@@ -84,7 +86,7 @@ impl LintStore {
8486
pub fn new() -> LintStore {
8587
LintStore {
8688
lints: vec!(),
87-
passes: vec!(),
89+
passes: Some(vec!()),
8890
by_name: HashMap::new(),
8991
levels: HashMap::new(),
9092
}
@@ -117,7 +119,7 @@ impl LintStore {
117119
self.levels.insert(id, (lint.default_level, Default));
118120
}
119121
}
120-
self.passes.push(RefCell::new(pass));
122+
self.passes.get_mut_ref().push(pass);
121123
}
122124

123125
pub fn register_builtin(&mut self, sess: Option<&Session>) {
@@ -181,11 +183,15 @@ pub struct Context<'a> {
181183
}
182184

183185
/// Convenience macro for calling a `LintPass` method on every pass in the context.
184-
macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => (
185-
for obj in $cx.lints.passes.iter() {
186-
obj.borrow_mut().$f($cx, $($args),*);
187-
}
188-
))
186+
macro_rules! run_lints ( ($cx:expr, $f:ident, $($args:expr),*) => ({
187+
// Move the vector of passes out of `$cx` so that we can
188+
// iterate over it mutably while passing `$cx` to the methods.
189+
let mut passes = $cx.lints.passes.take_unwrap();
190+
for obj in passes.mut_iter() {
191+
obj.$f($cx, $($args),*);
192+
}
193+
$cx.lints.passes = Some(passes);
194+
}))
189195

190196
/// Emit a lint as a warning or an error (or not at all)
191197
/// according to `level`.

0 commit comments

Comments
 (0)