Skip to content

Commit e09449d

Browse files
committed
---
yaml --- r: 159102 b: refs/heads/snap-stage3 c: 8771394 h: refs/heads/master v: v3
1 parent adde5c9 commit e09449d

File tree

6 files changed

+24
-35
lines changed

6 files changed

+24
-35
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: 40fb87d40f681f5356af42175fc7b85da387f037
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 15ba87f0314fda5e81603f37ae5f40e2022bcfc1
4+
refs/heads/snap-stage3: 877139495d4c572493f2440cff038283a3ba4e5e
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/middle/stability.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ 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, StructField, TypeTraitItem};
20+
use syntax::ast::{TypeMethod, Method, Generics, StructDef, StructField};
21+
use syntax::ast::{Ident, TypeTraitItem};
2122
use syntax::ast_util::is_local;
2223
use syntax::attr::Stability;
2324
use syntax::visit::{FnKind, FkMethod, Visitor};
@@ -47,15 +48,9 @@ impl Annotator {
4748
match attr::find_stability(attrs.as_slice()) {
4849
Some(stab) => {
4950
self.index.local.insert(id, stab.clone());
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-
}
51+
let parent = replace(&mut self.parent, Some(stab));
52+
f(self);
53+
self.parent = parent;
5954
}
6055
None => {
6156
self.parent.clone().map(|stab| self.index.local.insert(id, stab));
@@ -68,15 +63,6 @@ impl Annotator {
6863
impl<'v> Visitor<'v> for Annotator {
6964
fn visit_item(&mut self, i: &Item) {
7065
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-
}
8066
}
8167

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

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+
112105
fn visit_struct_field(&mut self, s: &StructField) {
113106
self.annotate(s.node.id, &s.node.attrs, |v| visit::walk_struct_field(v, s));
114107
}

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

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

branches/snap-stage3/src/test/auxiliary/inherited_stability.rs

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

1919
#[stable]
2020
pub mod stable_mod {
21-
pub fn experimental() {}
22-
23-
#[stable]
24-
pub fn stable() {}
25-
}
26-
27-
#[unstable]
28-
pub mod unstable_mod {
2921
#[experimental]
3022
pub fn experimental() {}
3123

32-
pub fn unstable() {}
24+
pub fn stable() {}
3325
}
3426

3527
pub mod experimental_mod {
@@ -41,9 +33,9 @@ pub mod experimental_mod {
4133

4234
#[stable]
4335
pub trait Stable {
36+
#[experimental]
4437
fn experimental(&self);
4538

46-
#[stable]
4739
fn stable(&self);
4840
}
4941

branches/snap-stage3/src/test/compile-fail/lint-stability.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ 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-
171168
experimental_mod::experimental(); //~ ERROR use of experimental item
172169
experimental_mod::stable();
173170

0 commit comments

Comments
 (0)