Skip to content

Commit ff0978b

Browse files
committed
---
yaml --- r: 159319 b: refs/heads/master c: a58fc68 h: refs/heads/master i: 159317: dd869b8 159315: 36692f0 159311: 8ab6d14 v: v3
1 parent 7cd9a20 commit ff0978b

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b73bc79d12c592bcbf80f7d9cb4cfc30ca20f6bd
2+
refs/heads/master: a58fc68223f177b6790a6b4027bb6761031e9fa8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9c96a79a74f10bed18b031ce0ac4126c56d6cfb3
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2

trunk/src/librustc/middle/stability.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ use syntax::{attr, visit};
1717
use syntax::ast;
1818
use syntax::ast::{Attribute, Block, Crate, DefId, FnDecl, NodeId, Variant};
1919
use syntax::ast::{Item, RequiredMethod, ProvidedMethod, TraitItem};
20-
use syntax::ast::{TypeMethod, Method, Generics, StructDef, StructField};
21-
use syntax::ast::{Ident, TypeTraitItem};
20+
use syntax::ast::{TypeMethod, Method, Generics, StructField, TypeTraitItem};
2221
use syntax::ast_util::is_local;
2322
use syntax::attr::Stability;
2423
use syntax::visit::{FnKind, FkMethod, Visitor};
@@ -48,9 +47,15 @@ impl Annotator {
4847
match attr::find_stability(attrs.as_slice()) {
4948
Some(stab) => {
5049
self.index.local.insert(id, stab.clone());
51-
let parent = replace(&mut self.parent, Some(stab));
52-
f(self);
53-
self.parent = parent;
50+
51+
// Don't inherit #[stable]
52+
if stab.level != attr::Stable {
53+
let parent = replace(&mut self.parent, Some(stab));
54+
f(self);
55+
self.parent = parent;
56+
} else {
57+
f(self);
58+
}
5459
}
5560
None => {
5661
self.parent.clone().map(|stab| self.index.local.insert(id, stab));
@@ -63,6 +68,15 @@ impl Annotator {
6368
impl<'v> Visitor<'v> for Annotator {
6469
fn visit_item(&mut self, i: &Item) {
6570
self.annotate(i.id, &i.attrs, |v| visit::walk_item(v, i));
71+
72+
match i.node {
73+
ast::ItemStruct(ref sd, _) => {
74+
sd.ctor_id.map(|id| {
75+
self.annotate(id, &i.attrs, |_| {})
76+
});
77+
}
78+
_ => {}
79+
}
6680
}
6781

6882
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
@@ -95,13 +109,6 @@ impl<'v> Visitor<'v> for Annotator {
95109
self.annotate(var.node.id, &var.node.attrs, |v| visit::walk_variant(v, var, g))
96110
}
97111

98-
fn visit_struct_def(&mut self, s: &StructDef, _: Ident, _: &Generics, _: NodeId) {
99-
match s.ctor_id {
100-
Some(id) => self.annotate(id, &vec![], |v| visit::walk_struct_def(v, s)),
101-
None => visit::walk_struct_def(self, s)
102-
}
103-
}
104-
105112
fn visit_struct_field(&mut self, s: &StructField) {
106113
self.annotate(s.node.id, &s.node.attrs, |v| visit::walk_struct_field(v, s));
107114
}

trunk/src/librustc/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T {
3535
let rv = rv.unwrap();
3636

3737
println!("{}time: {}.{:03} \t{}", " ".repeat(old),
38-
dur.num_seconds(), dur.num_milliseconds(), what);
38+
dur.num_seconds(), dur.num_milliseconds() % 1000, what);
3939
depth.replace(Some(old));
4040

4141
rv

trunk/src/libstd/time/duration.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Duration {
140140
pub fn span(f: ||) -> Duration {
141141
let before = super::precise_time_ns();
142142
f();
143-
Duration::nanoseconds((before - super::precise_time_ns()) as i64)
143+
Duration::nanoseconds((super::precise_time_ns() - before) as i64)
144144
}
145145

146146
/// Returns the total number of whole weeks in the duration.
@@ -565,4 +565,11 @@ mod tests {
565565
assert_eq!(format!("{:30}", Duration::days(1) + Duration::milliseconds(2345)),
566566
"P1DT2.345S".to_string());
567567
}
568+
569+
#[test]
570+
fn span() {
571+
use io::timer::sleep;
572+
let dur = Duration::span(|| sleep(Duration::milliseconds(5)));
573+
assert!(dur > Duration::milliseconds(1));
574+
}
568575
}

trunk/src/test/auxiliary/inherited_stability.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,20 @@ pub fn stable() {}
1818

1919
#[stable]
2020
pub mod stable_mod {
21-
#[experimental]
2221
pub fn experimental() {}
2322

23+
#[stable]
2424
pub fn stable() {}
2525
}
2626

27+
#[unstable]
28+
pub mod unstable_mod {
29+
#[experimental]
30+
pub fn experimental() {}
31+
32+
pub fn unstable() {}
33+
}
34+
2735
pub mod experimental_mod {
2836
pub fn experimental() {}
2937

@@ -33,9 +41,9 @@ pub mod experimental_mod {
3341

3442
#[stable]
3543
pub trait Stable {
36-
#[experimental]
3744
fn experimental(&self);
3845

46+
#[stable]
3947
fn stable(&self);
4048
}
4149

trunk/src/test/compile-fail/lint-stability.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ mod inheritance {
165165
stable_mod::experimental(); //~ ERROR use of experimental item
166166
stable_mod::stable();
167167

168+
unstable_mod::experimental(); //~ ERROR use of experimental item
169+
unstable_mod::unstable(); //~ ERROR use of unstable item
170+
168171
experimental_mod::experimental(); //~ ERROR use of experimental item
169172
experimental_mod::stable();
170173

0 commit comments

Comments
 (0)