Skip to content

Commit e86affb

Browse files
committed
---
yaml --- r: 187855 b: refs/heads/tmp c: 487ee79 h: refs/heads/master i: 187853: be4404a 187851: 23cad78 187847: f1a5be1 187839: 23f333a v: v3
1 parent 773e074 commit e86affb

File tree

46 files changed

+834
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+834
-100
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 804c071d8b9cfe4d40df9565558db8a9d87d7775
37+
refs/heads/tmp: 487ee79e3fb391fc97ea8c9c618eb7780a5dee2d
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/src/etc/htmldocck.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
highlights for example. If you want to simply check the presence of
9797
given node or attribute, use an empty string (`""`) as a `PATTERN`.
9898
99+
* `@count PATH XPATH COUNT' checks for the occurrence of given XPath
100+
in the given file. The number of occurrences must match the given count.
101+
99102
All conditions can be negated with `!`. `@!has foo/type.NoSuch.html`
100103
checks if the given file does not exist, for example.
101104
@@ -333,6 +336,11 @@ def check_tree_text(tree, path, pat, regexp):
333336
return ret
334337

335338

339+
def check_tree_count(tree, path, count):
340+
path = normalize_xpath(path)
341+
return len(tree.findall(path)) == count
342+
343+
336344
def check(target, commands):
337345
cache = CachedFiles(target)
338346
for c in commands:
@@ -360,6 +368,13 @@ def check(target, commands):
360368
raise RuntimeError('Invalid number of @{} arguments \
361369
at line {}'.format(c.cmd, c.lineno))
362370

371+
elif c.cmd == 'count': # count test
372+
if len(c.args) == 3: # @count <path> <pat> <count> = count test
373+
ret = check_tree_count(cache.get_tree(c.args[0]), c.args[1], int(c.args[2]))
374+
else:
375+
raise RuntimeError('Invalid number of @{} arguments \
376+
at line {}'.format(c.cmd, c.lineno))
377+
363378
elif c.cmd == 'valid-html':
364379
raise RuntimeError('Unimplemented @valid-html at line {}'.format(c.lineno))
365380

branches/tmp/src/liballoc/arc.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ pub struct Weak<T> {
139139
unsafe impl<T: Sync + Send> Send for Weak<T> { }
140140
unsafe impl<T: Sync + Send> Sync for Weak<T> { }
141141

142+
#[stable(feature = "rust1", since = "1.0.0")]
143+
impl<T: fmt::Debug> fmt::Debug for Weak<T> {
144+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
145+
write!(f, "(Weak)")
146+
}
147+
}
148+
142149
struct ArcInner<T> {
143150
strong: atomic::AtomicUsize,
144151
weak: atomic::AtomicUsize,

branches/tmp/src/liballoc/heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ mod imp {
300300
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
301301
} else {
302302
let new_ptr = allocate(size, align);
303-
ptr::copy_memory(new_ptr, ptr, cmp::min(size, old_size));
303+
ptr::copy(new_ptr, ptr, cmp::min(size, old_size));
304304
deallocate(ptr, old_size, align);
305305
new_ptr
306306
}

branches/tmp/src/libcore/fmt/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ pub trait Write {
110110
/// traits.
111111
#[stable(feature = "rust1", since = "1.0.0")]
112112
pub struct Formatter<'a> {
113-
#[cfg(not(stage0))]
114113
flags: u32,
115-
#[cfg(stage0)]
116-
flags: usize,
117114
fill: char,
118115
align: rt::v1::Alignment,
119116
width: Option<usize>,
@@ -159,13 +156,6 @@ impl<'a> ArgumentV1<'a> {
159156
}
160157
}
161158

162-
#[cfg(stage0)]
163-
#[doc(hidden)]
164-
#[stable(feature = "rust1", since = "1.0.0")]
165-
pub fn from_uint(x: &uint) -> ArgumentV1 {
166-
ArgumentV1::new(x, ArgumentV1::show_usize)
167-
}
168-
#[cfg(not(stage0))]
169159
#[doc(hidden)]
170160
#[stable(feature = "rust1", since = "1.0.0")]
171161
pub fn from_usize(x: &usize) -> ArgumentV1 {
@@ -605,14 +595,9 @@ impl<'a> Formatter<'a> {
605595
write(self.buf, fmt)
606596
}
607597

608-
#[cfg(not(stage0))]
609598
/// Flags for formatting (packed version of rt::Flag)
610599
#[stable(feature = "rust1", since = "1.0.0")]
611600
pub fn flags(&self) -> u32 { self.flags }
612-
#[cfg(stage0)]
613-
/// Flags for formatting (packed version of rt::Flag)
614-
#[stable(feature = "rust1", since = "1.0.0")]
615-
pub fn flags(&self) -> usize { self.flags }
616601

617602
/// Character used as 'fill' whenever there is alignment
618603
#[unstable(feature = "core", reason = "method was just created")]

branches/tmp/src/libcore/fmt/rt/v1.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ pub struct FormatSpec {
3232
pub fill: char,
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
pub align: Alignment,
35-
#[cfg(stage0)]
36-
#[stable(feature = "rust1", since = "1.0.0")]
37-
pub flags: usize,
38-
#[cfg(not(stage0))]
3935
#[stable(feature = "rust1", since = "1.0.0")]
4036
pub flags: u32,
4137
#[stable(feature = "rust1", since = "1.0.0")]

branches/tmp/src/libcore/intrinsics.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ extern "rust-intrinsic" {
241241
/// will trigger a compiler error.
242242
pub fn return_address() -> *const u8;
243243

244-
/// Returns `true` if a type requires drop glue.
244+
/// Returns `true` if the actual type given as `T` requires drop
245+
/// glue; returns `false` if the actual type provided for `T`
246+
/// implements `Copy`.
247+
///
248+
/// If the actual type neither requires drop glue nor implements
249+
/// `Copy`, then may return `true` or `false`.
245250
pub fn needs_drop<T>() -> bool;
246251

247252
/// Returns `true` if a type is managed (will be allocated on the local heap)

branches/tmp/src/libcore/macros.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ macro_rules! panic {
1515
panic!("explicit panic")
1616
);
1717
($msg:expr) => ({
18-
#[cfg(stage0)]
19-
static _MSG_FILE_LINE: (&'static str, &'static str, usize) = ($msg, file!(), line!());
20-
#[cfg(not(stage0))]
2118
static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!());
2219
::core::panicking::panic(&_MSG_FILE_LINE)
2320
});
@@ -26,9 +23,6 @@ macro_rules! panic {
2623
// used inside a dead function. Just `#[allow(dead_code)]` is
2724
// insufficient, since the user may have
2825
// `#[forbid(dead_code)]` and which cannot be overridden.
29-
#[cfg(stage0)]
30-
static _FILE_LINE: (&'static str, usize) = (file!(), line!());
31-
#[cfg(not(stage0))]
3226
static _FILE_LINE: (&'static str, u32) = (file!(), line!());
3327
::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
3428
});

branches/tmp/src/libcore/panicking.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,20 @@ use fmt;
3434

3535
#[cold] #[inline(never)] // this is the slow path, always
3636
#[lang="panic"]
37-
#[cfg(stage0)]
38-
pub fn panic(expr_file_line: &(&'static str, &'static str, usize)) -> ! {
39-
let (expr, file, line) = *expr_file_line;
40-
panic_fmt(format_args!("{}", expr), &(file, line))
41-
}
42-
#[cold] #[inline(never)] // this is the slow path, always
43-
#[lang="panic"]
44-
#[cfg(not(stage0))]
4537
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! {
4638
let (expr, file, line) = *expr_file_line;
4739
panic_fmt(format_args!("{}", expr), &(file, line))
4840
}
4941

5042
#[cold] #[inline(never)]
5143
#[lang="panic_bounds_check"]
52-
#[cfg(stage0)]
53-
fn panic_bounds_check(file_line: &(&'static str, usize),
54-
index: usize, len: usize) -> ! {
55-
panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
56-
len, index), file_line)
57-
}
58-
#[cold] #[inline(never)]
59-
#[lang="panic_bounds_check"]
60-
#[cfg(not(stage0))]
6144
fn panic_bounds_check(file_line: &(&'static str, u32),
6245
index: usize, len: usize) -> ! {
6346
panic_fmt(format_args!("index out of bounds: the len is {} but the index is {}",
6447
len, index), file_line)
6548
}
6649

6750
#[cold] #[inline(never)]
68-
#[cfg(stage0)]
69-
pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, usize)) -> ! {
70-
#[allow(improper_ctypes)]
71-
extern {
72-
#[lang = "panic_fmt"]
73-
fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: uint) -> !;
74-
}
75-
let (file, line) = *file_line;
76-
unsafe { panic_impl(fmt, file, line as uint) }
77-
}
78-
#[cold] #[inline(never)]
79-
#[cfg(not(stage0))]
8051
pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! {
8152
#[allow(improper_ctypes)]
8253
extern {

branches/tmp/src/libcore/str/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
939939
type Item = &'a str;
940940

941941
#[inline]
942+
#[allow(deprecated)]
942943
fn next(&mut self) -> Option<&'a str> {
943944
Iterator::next(&mut self.0)
944945
}

branches/tmp/src/liblog/macros.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@
5050
#[macro_export]
5151
macro_rules! log {
5252
($lvl:expr, $($arg:tt)+) => ({
53-
#[cfg(stage0)]
54-
static LOC: ::log::LogLocation = ::log::LogLocation {
55-
line: line!() as u32,
56-
file: file!(),
57-
module_path: module_path!(),
58-
};
59-
#[cfg(not(stage0))]
6053
static LOC: ::log::LogLocation = ::log::LogLocation {
6154
line: line!(),
6255
file: file!(),

branches/tmp/src/librustc/lint/builtin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,11 @@ impl LintPass for Stability {
17711771
stability::check_path(cx.tcx, path, id,
17721772
&mut |id, sp, stab| self.lint(cx, id, sp, stab));
17731773
}
1774+
1775+
fn check_pat(&mut self, cx: &Context, pat: &ast::Pat) {
1776+
stability::check_pat(cx.tcx, pat,
1777+
&mut |id, sp, stab| self.lint(cx, id, sp, stab))
1778+
}
17741779
}
17751780

17761781
declare_lint! {

branches/tmp/src/librustc/middle/stability.rs

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ impl<'a> Annotator<'a> {
5858
attrs: &Vec<Attribute>, item_sp: Span, f: F, required: bool) where
5959
F: FnOnce(&mut Annotator),
6060
{
61+
debug!("annotate(id = {:?}, attrs = {:?})", id, attrs);
6162
match attr::find_stability(self.sess.diagnostic(), attrs, item_sp) {
6263
Some(stab) => {
64+
debug!("annotate: found {:?}", stab);
6365
self.index.local.insert(id, stab.clone());
6466

6567
// Don't inherit #[stable(feature = "rust1", since = "1.0.0")]
@@ -72,6 +74,8 @@ impl<'a> Annotator<'a> {
7274
}
7375
}
7476
None => {
77+
debug!("annotate: not found, use_parent = {:?}, parent = {:?}",
78+
use_parent, self.parent);
7579
if use_parent {
7680
if let Some(stab) = self.parent.clone() {
7781
self.index.local.insert(id, stab);
@@ -299,6 +303,12 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Checker<'a, 'tcx> {
299303
&mut |id, sp, stab| self.check(id, sp, stab));
300304
visit::walk_path(self, path)
301305
}
306+
307+
fn visit_pat(&mut self, pat: &ast::Pat) {
308+
check_pat(self.tcx, pat,
309+
&mut |id, sp, stab| self.check(id, sp, stab));
310+
visit::walk_pat(self, pat)
311+
}
302312
}
303313

304314
/// Helper for discovering nodes to check for stability
@@ -385,6 +395,76 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr,
385395
None => return
386396
}
387397
}
398+
ast::ExprField(ref base_e, ref field) => {
399+
span = field.span;
400+
match ty::expr_ty_adjusted(tcx, base_e).sty {
401+
ty::ty_struct(did, _) => {
402+
ty::lookup_struct_fields(tcx, did)
403+
.iter()
404+
.find(|f| f.name == field.node.name)
405+
.unwrap_or_else(|| {
406+
tcx.sess.span_bug(field.span,
407+
"stability::check_expr: unknown named field access")
408+
})
409+
.id
410+
}
411+
_ => tcx.sess.span_bug(e.span,
412+
"stability::check_expr: named field access on non-struct")
413+
}
414+
}
415+
ast::ExprTupField(ref base_e, ref field) => {
416+
span = field.span;
417+
match ty::expr_ty_adjusted(tcx, base_e).sty {
418+
ty::ty_struct(did, _) => {
419+
ty::lookup_struct_fields(tcx, did)
420+
.get(field.node)
421+
.unwrap_or_else(|| {
422+
tcx.sess.span_bug(field.span,
423+
"stability::check_expr: unknown unnamed field access")
424+
})
425+
.id
426+
}
427+
ty::ty_tup(..) => return,
428+
_ => tcx.sess.span_bug(e.span,
429+
"stability::check_expr: unnamed field access on \
430+
something other than a tuple or struct")
431+
}
432+
}
433+
ast::ExprStruct(_, ref expr_fields, _) => {
434+
let type_ = ty::expr_ty(tcx, e);
435+
match type_.sty {
436+
ty::ty_struct(did, _) => {
437+
let struct_fields = ty::lookup_struct_fields(tcx, did);
438+
// check the stability of each field that appears
439+
// in the construction expression.
440+
for field in expr_fields {
441+
let did = struct_fields
442+
.iter()
443+
.find(|f| f.name == field.ident.node.name)
444+
.unwrap_or_else(|| {
445+
tcx.sess.span_bug(field.span,
446+
"stability::check_expr: unknown named \
447+
field access")
448+
})
449+
.id;
450+
maybe_do_stability_check(tcx, did, field.span, cb);
451+
}
452+
453+
// we're done.
454+
return
455+
}
456+
// we don't look at stability attributes on
457+
// struct-like enums (yet...), but it's definitely not
458+
// a bug to have construct one.
459+
ty::ty_enum(..) => return,
460+
_ => {
461+
tcx.sess.span_bug(e.span,
462+
&format!("stability::check_expr: struct construction \
463+
of non-struct, type {:?}",
464+
type_.repr(tcx)));
465+
}
466+
}
467+
}
388468
_ => return
389469
};
390470

@@ -403,6 +483,47 @@ pub fn check_path(tcx: &ty::ctxt, path: &ast::Path, id: ast::NodeId,
403483

404484
}
405485

486+
pub fn check_pat(tcx: &ty::ctxt, pat: &ast::Pat,
487+
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
488+
debug!("check_pat(pat = {:?})", pat);
489+
if is_internal(tcx, pat.span) { return; }
490+
491+
let did = match ty::pat_ty_opt(tcx, pat) {
492+
Some(&ty::TyS { sty: ty::ty_struct(did, _), .. }) => did,
493+
Some(_) | None => return,
494+
};
495+
let struct_fields = ty::lookup_struct_fields(tcx, did);
496+
match pat.node {
497+
// Foo(a, b, c)
498+
ast::PatEnum(_, Some(ref pat_fields)) => {
499+
for (field, struct_field) in pat_fields.iter().zip(struct_fields.iter()) {
500+
// a .. pattern is fine, but anything positional is
501+
// not.
502+
if let ast::PatWild(ast::PatWildMulti) = field.node {
503+
continue
504+
}
505+
maybe_do_stability_check(tcx, struct_field.id, field.span, cb)
506+
}
507+
}
508+
// Foo { a, b, c }
509+
ast::PatStruct(_, ref pat_fields, _) => {
510+
for field in pat_fields {
511+
let did = struct_fields
512+
.iter()
513+
.find(|f| f.name == field.node.ident.name)
514+
.unwrap_or_else(|| {
515+
tcx.sess.span_bug(field.span,
516+
"stability::check_pat: unknown named field access")
517+
})
518+
.id;
519+
maybe_do_stability_check(tcx, did, field.span, cb);
520+
}
521+
}
522+
// everything else is fine.
523+
_ => {}
524+
}
525+
}
526+
406527
fn maybe_do_stability_check(tcx: &ty::ctxt, id: ast::DefId, span: Span,
407528
cb: &mut FnMut(ast::DefId, Span, &Option<Stability>)) {
408529
if !is_staged_api(tcx, id) { return }

0 commit comments

Comments
 (0)