Skip to content

Commit 03d4eba

Browse files
committed
---
yaml --- r: 142901 b: refs/heads/try2 c: 8a1002f h: refs/heads/master i: 142899: 80b4427 v: v3
1 parent ee4f279 commit 03d4eba

File tree

236 files changed

+1317
-744
lines changed

Some content is hidden

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

236 files changed

+1317
-744
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 877bba91d54457c104ff0bf67fd46a499a451cf6
8+
refs/heads/try2: 8a1002fbd93989bbf5c8989ed8002827920b375b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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/try2/src/libextra/semver.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ impl cmp::Ord for Version {
113113
(0, _) => false,
114114
(_, 0) => true,
115115
(_, _) => self.pre < other.pre
116-
})) ||
117-
118-
(self.major == other.major &&
119-
self.minor == other.minor &&
120-
self.patch == other.patch &&
121-
self.pre == other.pre &&
122-
self.build < other.build)
116+
}))
123117
}
124118

125119
#[inline]
@@ -324,6 +318,8 @@ fn test_parse() {
324318
fn test_eq() {
325319
assert_eq!(parse("1.2.3"), parse("1.2.3"));
326320
assert_eq!(parse("1.2.3-alpha1"), parse("1.2.3-alpha1"));
321+
assert_eq!(parse("1.2.3+build.42"), parse("1.2.3+build.42"));
322+
assert_eq!(parse("1.2.3-alpha1+42"), parse("1.2.3-alpha1+42"));
327323
}
328324
329325
#[test]
@@ -332,6 +328,7 @@ fn test_ne() {
332328
assert!(parse("0.0.0") != parse("0.1.0"));
333329
assert!(parse("0.0.0") != parse("1.0.0"));
334330
assert!(parse("1.2.3-alpha") != parse("1.2.3-beta"));
331+
assert!(parse("1.2.3+23") != parse("1.2.3+42"));
335332
}
336333
337334
#[test]
@@ -342,6 +339,7 @@ fn test_lt() {
342339
assert!(parse("1.2.3-alpha1") < parse("1.2.3"));
343340
assert!(parse("1.2.3-alpha1") < parse("1.2.3-alpha2"));
344341
assert!(!(parse("1.2.3-alpha2") < parse("1.2.3-alpha2")));
342+
assert!(!(parse("1.2.3+23") < parse("1.2.3+42")));
345343
}
346344
347345
#[test]
@@ -351,6 +349,7 @@ fn test_le() {
351349
assert!(parse("1.2.0") <= parse("1.2.3-alpha2"));
352350
assert!(parse("1.2.3-alpha1") <= parse("1.2.3-alpha2"));
353351
assert!(parse("1.2.3-alpha2") <= parse("1.2.3-alpha2"));
352+
assert!(parse("1.2.3+23") <= parse("1.2.3+42"));
354353
}
355354
356355
#[test]
@@ -361,6 +360,7 @@ fn test_gt() {
361360
assert!(parse("1.2.3-alpha2") > parse("1.2.3-alpha1"));
362361
assert!(parse("1.2.3") > parse("1.2.3-alpha2"));
363362
assert!(!(parse("1.2.3-alpha2") > parse("1.2.3-alpha2")));
363+
assert!(!(parse("1.2.3+23") > parse("1.2.3+42")));
364364
}
365365
366366
#[test]
@@ -370,22 +370,20 @@ fn test_ge() {
370370
assert!(parse("1.2.3-alpha2") >= parse("1.2.0"));
371371
assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha1"));
372372
assert!(parse("1.2.3-alpha2") >= parse("1.2.3-alpha2"));
373+
assert!(parse("1.2.3+23") >= parse("1.2.3+42"));
373374
}
374375
375376
#[test]
376377
fn test_spec_order() {
377378
378379
let vs = ["1.0.0-alpha",
379380
"1.0.0-alpha.1",
381+
"1.0.0-alpha.beta",
382+
"1.0.0-beta",
380383
"1.0.0-beta.2",
381384
"1.0.0-beta.11",
382385
"1.0.0-rc.1",
383-
"1.0.0-rc.1+build.1",
384-
"1.0.0",
385-
"1.0.0+0.3.7",
386-
"1.3.7+build",
387-
"1.3.7+build.2.b8f12d7",
388-
"1.3.7+build.11.e0f985a"];
386+
"1.0.0"];
389387
let mut i = 1;
390388
while i < vs.len() {
391389
let a = parse(vs[i-1]).get();

branches/try2/src/libextra/smallintmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ impl<V> SmallIntMap<V> {
161161
/// Visit all key-value pairs in reverse order
162162
pub fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool {
163163
for uint::range_rev(self.v.len(), 0) |i| {
164-
match self.v[i - 1] {
165-
Some(ref elt) => if !it(i - 1, elt) { return false; },
164+
match self.v[i] {
165+
Some(ref elt) => if !it(i, elt) { return false; },
166166
None => ()
167167
}
168168
}

branches/try2/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/try2/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/try2/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/try2/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/try2/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/try2/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/try2/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]

branches/try2/src/librustdoc/desc_to_brief_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ mod test {
190190
#[test]
191191
fn should_promote_desc() {
192192
let doc = mk_doc(~"#[doc = \"desc\"] mod m { }");
193-
assert_eq!(doc.cratemod().mods()[0].brief(), Some(~"desc"));
193+
// hidden __std_macros module at the start.
194+
assert_eq!(doc.cratemod().mods()[1].brief(), Some(~"desc"));
194195
}
195196
196197
#[test]

0 commit comments

Comments
 (0)