Skip to content

Commit f7d237f

Browse files
committed
---
yaml --- r: 92167 b: refs/heads/auto c: 3b14f25 h: refs/heads/master i: 92165: b707c9a 92163: 5eb2759 92159: 166798c v: v3
1 parent 81503ee commit f7d237f

File tree

12 files changed

+310
-600
lines changed

12 files changed

+310
-600
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 4e0cb316fc980f00e1b74f3fdb7a842b540be280
16+
refs/heads/auto: 3b14f25868dd0423b03b41ff413470866f774280
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ pub fn build_link_meta(sess: Session,
428428
}
429429

430430
fn len_and_str_lit(l: ast::lit) -> ~str {
431-
len_and_str(pprust::lit_to_str(@l))
431+
len_and_str(pprust::lit_to_str(&l))
432432
}
433433

434434
let cmh_items = attr::sort_meta_items(cmh_items);

branches/auto/src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
330330
};
331331

332332
debug!("Synthetic test module:\n{}\n",
333-
pprust::item_to_str(@item.clone(), cx.sess.intr()));
333+
pprust::item_to_str(&item, cx.sess.intr()));
334334

335335
return @item;
336336
}

branches/auto/src/librustc/middle/lint.rs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,27 +1028,47 @@ fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
10281028
}
10291029
}
10301030

1031+
enum Allocation {
1032+
VectorAllocation,
1033+
BoxAllocation
1034+
}
1035+
10311036
fn check_unnecessary_allocation(cx: &Context, e: &ast::Expr) {
1032-
// Warn if string and vector literals with sigils are immediately borrowed.
1033-
// Those can have the sigil removed.
1034-
match e.node {
1037+
// Warn if string and vector literals with sigils, or boxing expressions,
1038+
// are immediately borrowed.
1039+
let allocation = match e.node {
10351040
ast::ExprVstore(e2, ast::ExprVstoreUniq) |
10361041
ast::ExprVstore(e2, ast::ExprVstoreBox) => {
10371042
match e2.node {
10381043
ast::ExprLit(@codemap::Spanned{node: ast::lit_str(..), ..}) |
1039-
ast::ExprVec(..) => {}
1044+
ast::ExprVec(..) => VectorAllocation,
10401045
_ => return
10411046
}
10421047
}
1048+
ast::ExprUnary(_, ast::UnUniq, _) |
1049+
ast::ExprUnary(_, ast::UnBox(..), _) => BoxAllocation,
10431050

10441051
_ => return
1045-
}
1052+
};
1053+
1054+
let report = |msg| {
1055+
cx.span_lint(unnecessary_allocation, e.span, msg);
1056+
};
10461057

10471058
match cx.tcx.adjustments.find_copy(&e.id) {
1048-
Some(@ty::AutoDerefRef(ty::AutoDerefRef {
1049-
autoref: Some(ty::AutoBorrowVec(..)), .. })) => {
1050-
cx.span_lint(unnecessary_allocation, e.span,
1051-
"unnecessary allocation, the sigil can be removed");
1059+
Some(@ty::AutoDerefRef(ty::AutoDerefRef { autoref, .. })) => {
1060+
match (allocation, autoref) {
1061+
(VectorAllocation, Some(ty::AutoBorrowVec(..))) => {
1062+
report("unnecessary allocation, the sigil can be removed");
1063+
}
1064+
(BoxAllocation, Some(ty::AutoPtr(_, ast::MutImmutable))) => {
1065+
report("unnecessary allocation, use & instead");
1066+
}
1067+
(BoxAllocation, Some(ty::AutoPtr(_, ast::MutMutable))) => {
1068+
report("unnecessary allocation, use &mut instead");
1069+
}
1070+
_ => ()
1071+
}
10521072
}
10531073

10541074
_ => ()

branches/auto/src/libstd/any.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@
99
// except according to those terms.
1010

1111
//! This module implements the `Any` trait, which enables dynamic typing
12-
//! of any type, through runtime reflection.
13-
//!
14-
//! `Any` itself can be used to get a `TypeId`, and has more features when used as a trait object.
15-
//! As `&Any` (a borrowed trait object), it has the `is` and `as_ref` methods, to test if the
16-
//! contained value is of a given type, and to get a reference to the inner value as a type. As
17-
//! `&mut Any`, there is also the `as_mut` method, for getting a mutable reference to the inner
18-
//! value. `~Any` adds the `move` method, which will unwrap a `~T` from the object. See the
19-
//! extension traits (`*Ext`) for the full details.
12+
//! of any type.
2013
2114
use cast::transmute;
2215
use option::{Option, Some, None};

branches/auto/src/libstd/rand/distributions/exponential.rs

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)