Skip to content

Commit 67fe9ef

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 121423 b: refs/heads/snap-stage3 c: 609552e h: refs/heads/master i: 121421: 34891ae 121419: 18ec80c 121415: e65513f 121407: b488d6f v: v3
1 parent cc8da6f commit 67fe9ef

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 7a93beef7f692b34168ad69633f56483d38ad8fc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c1898b9acb324990367bb6672145c30b51e0399f
4+
refs/heads/snap-stage3: 609552e19516299b061687d52094d0b755b213d3
55
refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)