Skip to content

Commit 89c041d

Browse files
committed
---
yaml --- r: 64366 b: refs/heads/snap-stage3 c: 9db1903 h: refs/heads/master v: v3
1 parent 7f78b99 commit 89c041d

File tree

243 files changed

+954
-729
lines changed

Some content is hidden

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

243 files changed

+954
-729
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 712ac836c63c3ae98daf9fb98b7b96ed73347848
4+
refs/heads/snap-stage3: 9db190305f7562f15b5282fed508aef81cfc9689
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rust.md

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,14 +1417,83 @@ names are effectively reserved. Some significant attributes include:
14171417
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
14181418
* The `link` attribute, for describing linkage metadata for a crate.
14191419
* The `test` attribute, for marking functions as unit tests.
1420-
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported
1421-
by the compiler can be found via `rustc -W help`.
1420+
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
1421+
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
14221422
* The `deriving` attribute, for automatically generating
14231423
implementations of certain traits.
14241424
* The `static_assert` attribute, for asserting that a static bool is true at compiletime
14251425

14261426
Other attributes may be added or removed during development of the language.
14271427

1428+
### Lint check attributes
1429+
1430+
A lint check names a potentially undesirable coding pattern, such as
1431+
unreachable code or omitted documentation, for the static entity to
1432+
which the attribute applies.
1433+
1434+
For any lint check `C`:
1435+
1436+
* `warn(C)` warns about violations of `C` but continues compilation,
1437+
* `deny(C)` signals an error after encountering a violation of `C`,
1438+
* `allow(C)` overrides the check for `C` so that violations will go
1439+
unreported,
1440+
* `forbid(C)` is the same as `deny(C)`, but also forbids uses of
1441+
`allow(C)` within the entity.
1442+
1443+
The lint checks supported by the compiler can be found via `rustc -W help`,
1444+
along with their default settings.
1445+
1446+
~~~{.xfail-test}
1447+
mod m1 {
1448+
// Missing documentation is ignored here
1449+
#[allow(missing_doc)]
1450+
pub fn undocumented_one() -> int { 1 }
1451+
1452+
// Missing documentation signals a warning here
1453+
#[warn(missing_doc)]
1454+
pub fn undocumented_too() -> int { 2 }
1455+
1456+
// Missing documentation signals an error here
1457+
#[deny(missing_doc)]
1458+
pub fn undocumented_end() -> int { 3 }
1459+
}
1460+
~~~
1461+
1462+
This example shows how one can use `allow` and `warn` to toggle
1463+
a particular check on and off.
1464+
1465+
~~~
1466+
#[warn(missing_doc)]
1467+
mod m2{
1468+
#[allow(missing_doc)]
1469+
mod nested {
1470+
// Missing documentation is ignored here
1471+
pub fn undocumented_one() -> int { 1 }
1472+
1473+
// Missing documentation signals a warning here,
1474+
// despite the allow above.
1475+
#[warn(missing_doc)]
1476+
pub fn undocumented_two() -> int { 2 }
1477+
}
1478+
1479+
// Missing documentation signals a warning here
1480+
pub fn undocumented_too() -> int { 3 }
1481+
}
1482+
~~~
1483+
1484+
This example shows how one can use `forbid` to disallow uses
1485+
of `allow` for that lint check.
1486+
1487+
~~~{.xfail-test}
1488+
#[forbid(missing_doc)]
1489+
mod m3 {
1490+
// Attempting to toggle warning signals an error here
1491+
#[allow(missing_doc)]
1492+
/// Returns 2.
1493+
pub fn undocumented_too() -> int { 2 }
1494+
}
1495+
~~~
1496+
14281497
### Language items
14291498

14301499
Some primitive Rust operations are defined in Rust code,

branches/snap-stage3/src/libextra/dlist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ impl<T> Deque<T> for DList<T> {
173173
let tail_own = match tail.prev.resolve() {
174174
None => {
175175
self.list_tail = Rawlink::none();
176-
self.list_head.take_unwrap()
176+
self.list_head.swap_unwrap()
177177
},
178178
Some(tail_prev) => {
179179
self.list_tail = tail.prev;
180-
tail_prev.next.take_unwrap()
180+
tail_prev.next.swap_unwrap()
181181
}
182182
};
183183
Some(tail_own.value)
@@ -465,7 +465,7 @@ impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
465465
Some(prev) => prev,
466466
};
467467
let mut ins_node = ~Node{value: elt, next: None, prev: Rawlink::none()};
468-
let node_own = prev_node.next.take_unwrap();
468+
let node_own = prev_node.next.swap_unwrap();
469469
ins_node.next = link_with_prev(node_own, Rawlink::some(ins_node));
470470
prev_node.next = link_with_prev(ins_node, Rawlink::some(prev_node));
471471
self.list.length += 1;

branches/snap-stage3/src/libextra/net/ip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub fn get_addr(node: &str, iotask: &iotask)
116116
let (output_po, output_ch) = stream();
117117
let mut output_ch = Some(SharedChan::new(output_ch));
118118
do str::as_buf(node) |node_ptr, len| {
119-
let output_ch = output_ch.take_unwrap();
119+
let output_ch = output_ch.swap_unwrap();
120120
debug!("slice len %?", len);
121121
let handle = create_uv_getaddrinfo_t();
122122
let handle_ptr: *uv_getaddrinfo_t = &handle;

branches/snap-stage3/src/libextra/sync.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'self> Condvar<'self> {
260260
signal_waitqueue(&state.waiters);
261261
}
262262
// Enqueue ourself to be woken up by a signaller.
263-
let SignalEnd = SignalEnd.take_unwrap();
263+
let SignalEnd = SignalEnd.swap_unwrap();
264264
state.blocked[condvar_id].tail.send(SignalEnd);
265265
} else {
266266
out_of_bounds = Some(state.blocked.len());
@@ -281,7 +281,7 @@ impl<'self> Condvar<'self> {
281281
// Unconditionally "block". (Might not actually block if a
282282
// signaller already sent -- I mean 'unconditionally' in contrast
283283
// with acquire().)
284-
let _ = comm::recv_one(WaitEnd.take_unwrap());
284+
let _ = comm::recv_one(WaitEnd.swap_unwrap());
285285
}
286286

287287
// This is needed for a failing condition variable to reacquire the
@@ -353,7 +353,7 @@ impl<'self> Condvar<'self> {
353353
}
354354
}
355355
do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
356-
let queue = queue.take_unwrap();
356+
let queue = queue.swap_unwrap();
357357
broadcast_waitqueue(&queue)
358358
}
359359
}
@@ -1436,7 +1436,7 @@ mod tests {
14361436
do x.write_downgrade |xwrite| {
14371437
let mut xopt = Some(xwrite);
14381438
do y.write_downgrade |_ywrite| {
1439-
y.downgrade(xopt.take_unwrap());
1439+
y.downgrade(xopt.swap_unwrap());
14401440
error!("oops, y.downgrade(x) should have failed!");
14411441
}
14421442
}

branches/snap-stage3/src/libextra/treemap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
552552
// Remove left horizontal link by rotating right
553553
fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
554554
if node.left.map_default(false, |x| x.level == node.level) {
555-
let mut save = node.left.take_unwrap();
555+
let mut save = node.left.swap_unwrap();
556556
swap(&mut node.left, &mut save.right); // save.right now None
557557
swap(node, &mut save);
558558
node.right = Some(save);
@@ -564,7 +564,7 @@ fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
564564
fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
565565
if node.right.map_default(false,
566566
|x| x.right.map_default(false, |y| y.level == node.level)) {
567-
let mut save = node.right.take_unwrap();
567+
let mut save = node.right.swap_unwrap();
568568
swap(&mut node.right, &mut save.left); // save.left now None
569569
save.level += 1;
570570
swap(node, &mut save);
@@ -643,7 +643,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
643643
Equal => {
644644
if save.left.is_some() {
645645
if save.right.is_some() {
646-
let mut left = save.left.take_unwrap();
646+
let mut left = save.left.swap_unwrap();
647647
if left.right.is_some() {
648648
heir_swap(save, &mut left.right);
649649
} else {
@@ -653,13 +653,13 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
653653
save.left = Some(left);
654654
(remove(&mut save.left, key), true)
655655
} else {
656-
let new = save.left.take_unwrap();
656+
let new = save.left.swap_unwrap();
657657
let ~TreeNode{value, _} = replace(save, new);
658-
*save = save.left.take_unwrap();
658+
*save = save.left.swap_unwrap();
659659
(Some(value), true)
660660
}
661661
} else if save.right.is_some() {
662-
let new = save.right.take_unwrap();
662+
let new = save.right.swap_unwrap();
663663
let ~TreeNode{value, _} = replace(save, new);
664664
(Some(value), true)
665665
} else {

branches/snap-stage3/src/librustc/driver/driver.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ pub fn compile_rest(sess: Session,
194194
// mod bar { macro_rules! baz!(() => {{}}) }
195195
//
196196
// baz! should not use this definition unless foo is enabled.
197+
crate = time(time_passes, ~"std macros injection", ||
198+
syntax::ext::expand::inject_std_macros(sess.parse_sess, copy cfg,
199+
crate));
200+
197201
crate = time(time_passes, ~"configuration 1", ||
198202
front::config::strip_unconfigured_items(crate));
199203

@@ -214,7 +218,7 @@ pub fn compile_rest(sess: Session,
214218
assert!(phases.from != cu_no_trans);
215219

216220
let (llcx, llmod, link_meta) = {
217-
crate = time(time_passes, ~"extra injection", ||
221+
crate = time(time_passes, ~"std injection", ||
218222
front::std_inject::maybe_inject_libstd_ref(sess, crate));
219223

220224
let ast_map = time(time_passes, ~"ast indexing", ||

branches/snap-stage3/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ pub fn alloca_maybe_zeroed(cx: block, ty: Type, name: &str, zero: bool) -> Value
15301530
let _icx = push_ctxt("alloca");
15311531
if cx.unreachable {
15321532
unsafe {
1533-
return llvm::LLVMGetUndef(ty.to_ref());
1533+
return llvm::LLVMGetUndef(ty.ptr_to().to_ref());
15341534
}
15351535
}
15361536
let initcx = base::raw_block(cx.fcx, false, cx.fcx.get_llstaticallocas());

branches/snap-stage3/src/librustc/middle/trans/build.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,15 +569,17 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
569569
hi: c_ulonglong, signed: lib::llvm::Bool) -> ValueRef {
570570
let value = Load(cx, PointerVal);
571571

572-
unsafe {
573-
let t = llvm::LLVMGetElementType(llvm::LLVMTypeOf(PointerVal));
574-
let min = llvm::LLVMConstInt(t, lo, signed);
575-
let max = llvm::LLVMConstInt(t, hi, signed);
576-
577-
do [min, max].as_imm_buf |ptr, len| {
578-
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
579-
llvm::LLVMMDNodeInContext(cx.fcx.ccx.llcx,
580-
ptr, len as c_uint));
572+
if !cx.unreachable {
573+
unsafe {
574+
let t = llvm::LLVMGetElementType(llvm::LLVMTypeOf(PointerVal));
575+
let min = llvm::LLVMConstInt(t, lo, signed);
576+
let max = llvm::LLVMConstInt(t, hi, signed);
577+
578+
do [min, max].as_imm_buf |ptr, len| {
579+
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
580+
llvm::LLVMMDNodeInContext(cx.fcx.ccx.llcx,
581+
ptr, len as c_uint));
582+
}
581583
}
582584
}
583585

branches/snap-stage3/src/librustc/middle/trans/controlflow.rs

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,38 @@ pub fn trans_if(bcx: block,
6363
let _indenter = indenter();
6464

6565
let _icx = push_ctxt("trans_if");
66+
67+
match cond.node {
68+
// `if true` and `if false` can be trans'd more efficiently,
69+
// by dropping branches that are known to be impossible.
70+
ast::expr_lit(@ref l) => match l.node {
71+
ast::lit_bool(true) => {
72+
// if true { .. } [else { .. }]
73+
let then_bcx_in = scope_block(bcx, thn.info(), "if_true_then");
74+
let then_bcx_out = trans_block(then_bcx_in, thn, dest);
75+
let then_bcx_out = trans_block_cleanups(then_bcx_out,
76+
block_cleanups(then_bcx_in));
77+
Br(bcx, then_bcx_in.llbb);
78+
return then_bcx_out;
79+
}
80+
ast::lit_bool(false) => {
81+
match els {
82+
// if false { .. } else { .. }
83+
Some(elexpr) => {
84+
let (else_bcx_in, else_bcx_out) =
85+
trans_if_else(bcx, elexpr, dest, "if_false_else");
86+
Br(bcx, else_bcx_in.llbb);
87+
return else_bcx_out;
88+
}
89+
// if false { .. }
90+
None => return bcx,
91+
}
92+
}
93+
_ => {}
94+
},
95+
_ => {}
96+
}
97+
6698
let Result {bcx, val: cond_val} =
6799
expr::trans_to_datum(bcx, cond).to_result();
68100

@@ -80,22 +112,8 @@ pub fn trans_if(bcx: block,
80112
// 'else' context
81113
let (else_bcx_in, next_bcx) = match els {
82114
Some(elexpr) => {
83-
let else_bcx_in = scope_block(bcx, els.info(), "else");
84-
let else_bcx_out = match elexpr.node {
85-
ast::expr_if(_, _, _) => {
86-
let elseif_blk = ast_util::block_from_expr(elexpr);
87-
trans_block(else_bcx_in, &elseif_blk, dest)
88-
}
89-
ast::expr_block(ref blk) => {
90-
trans_block(else_bcx_in, blk, dest)
91-
}
92-
// would be nice to have a constraint on ifs
93-
_ => bcx.tcx().sess.bug("strange alternative in if")
94-
};
95-
let else_bcx_out = trans_block_cleanups(else_bcx_out,
96-
block_cleanups(else_bcx_in));
97-
98-
(else_bcx_in, join_blocks(bcx, [then_bcx_out, else_bcx_out]))
115+
let (else_bcx_in, else_bcx_out) = trans_if_else(bcx, elexpr, dest, "else");
116+
(else_bcx_in, join_blocks(bcx, [then_bcx_out, else_bcx_out]))
99117
}
100118
_ => {
101119
let next_bcx = sub_block(bcx, "next");
@@ -109,7 +127,27 @@ pub fn trans_if(bcx: block,
109127
then_bcx_in.to_str(), else_bcx_in.to_str());
110128

111129
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
112-
next_bcx
130+
return next_bcx;
131+
132+
// trans `else [ if { .. } ... | { .. } ]`
133+
fn trans_if_else(bcx: block, elexpr: @ast::expr,
134+
dest: expr::Dest, scope_name: &str) -> (block, block) {
135+
let else_bcx_in = scope_block(bcx, elexpr.info(), scope_name);
136+
let else_bcx_out = match elexpr.node {
137+
ast::expr_if(_, _, _) => {
138+
let elseif_blk = ast_util::block_from_expr(elexpr);
139+
trans_block(else_bcx_in, &elseif_blk, dest)
140+
}
141+
ast::expr_block(ref blk) => {
142+
trans_block(else_bcx_in, blk, dest)
143+
}
144+
// would be nice to have a constraint on ifs
145+
_ => bcx.tcx().sess.bug("strange alternative in if")
146+
};
147+
let else_bcx_out = trans_block_cleanups(else_bcx_out,
148+
block_cleanups(else_bcx_in));
149+
(else_bcx_in, else_bcx_out)
150+
}
113151
}
114152

115153
pub fn join_blocks(parent_bcx: block, in_cxs: &[block]) -> block {

branches/snap-stage3/src/librustc/middle/trans/datum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl Datum {
413413
pub fn to_value_datum(&self, bcx: block) -> Datum {
414414
/*!
415415
*
416-
* Yields a by-ref form of this datum. This may involve
416+
* Yields a by-value form of this datum. This may involve
417417
* creation of a temporary stack slot. The value returned by
418418
* this function is not separately rooted from this datum, so
419419
* it will not live longer than the current datum. */

branches/snap-stage3/src/librustdoc/astsrv.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ fn build_ctxt(sess: Session,
113113

114114
use rustc::front::config;
115115

116+
let ast = syntax::ext::expand::inject_std_macros(sess.parse_sess,
117+
copy sess.opts.cfg, ast);
116118
let ast = config::strip_unconfigured_items(ast);
117119
let ast = syntax::ext::expand::expand_crate(sess.parse_sess,
118120
copy sess.opts.cfg, ast);
@@ -138,7 +140,8 @@ fn should_prune_unconfigured_items() {
138140
let source = ~"#[cfg(shut_up_and_leave_me_alone)]fn a() { }";
139141
do from_str(source) |srv| {
140142
do exec(srv) |ctxt| {
141-
assert!(ctxt.ast.node.module.items.is_empty());
143+
// one item: the __std_macros secret module
144+
assert_eq!(ctxt.ast.node.module.items.len(), 1);
142145
}
143146
}
144147
}

branches/snap-stage3/src/librustdoc/attr_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ mod test {
255255
#[test]
256256
fn should_should_extract_mod_attributes() {
257257
let doc = mk_doc(~"#[doc = \"test\"] mod a { }");
258-
assert!(doc.cratemod().mods()[0].desc() == Some(~"test"));
258+
// hidden __std_macros module at the start.
259+
assert!(doc.cratemod().mods()[1].desc() == Some(~"test"));
259260
}
260261
261262
#[test]

0 commit comments

Comments
 (0)