Skip to content

Commit 75821eb

Browse files
committed
---
yaml --- r: 209588 b: refs/heads/try c: 77213d1 h: refs/heads/master v: v3
1 parent 12f608d commit 75821eb

Some content is hidden

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

59 files changed

+1034
-736
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: e47fb489c10f2d86216c3a75ad6cbde3742e9f0c
5+
refs/heads/try: 77213d1b28b307401d2bbb143168418bf7e6794c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/trpl/hello-cargo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ we hadn’t changed the source file, and so it just ran the binary. If we had
8989
made a modification, we would have seen it do both:
9090

9191
```bash
92-
$ cargo build
92+
$ cargo run
9393
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
9494
Running `target/debug/hello_world`
9595
Hello, world!

branches/try/src/doc/trpl/vectors.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
% Vectors
22

33
A *vector* is a dynamic or "growable" array, implemented as the standard
4-
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md) statement). Vectors always allocate their data on the heap. Vectors are to slices
5-
what `String` is to `&str`. You can create them with the `vec!` macro:
4+
library type [`Vec<T>`](../std/vec/) (Where `<T>` is a [Generic](./generics.md)
5+
statement). Vectors always allocate their data on the heap. Vectors are to
6+
[slices][slices] what [`String`][string] is to `&str`. You can
7+
create them with the `vec!` macro:
68

79
```{rust}
810
let v = vec![1, 2, 3]; // v: Vec<i32>
911
```
1012

13+
[slices]: primitive-types.html#slices
14+
[string]: strings.html
15+
1116
(Notice that unlike the `println!` macro we've used in the past, we use square
1217
brackets `[]` with `vec!`. Rust allows you to use either in either situation,
1318
this is just convention.)

branches/try/src/libcore/num/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,11 @@ macro_rules! int_impl {
13211321
#[stable(feature = "rust1", since = "1.0.0")]
13221322
#[inline]
13231323
pub fn abs(self) -> $T {
1324-
if self.is_negative() { -self } else { self }
1324+
if self.is_negative() {
1325+
self.wrapping_neg()
1326+
} else {
1327+
self
1328+
}
13251329
}
13261330

13271331
/// Returns a number representing sign of `self`.

branches/try/src/libcore/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ pub struct RangeFull;
969969
#[stable(feature = "rust1", since = "1.0.0")]
970970
impl fmt::Debug for RangeFull {
971971
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
972-
fmt::Debug::fmt("..", fmt)
972+
write!(fmt, "..")
973973
}
974974
}
975975

branches/try/src/librustc/metadata/tydecode.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,12 @@ fn parse_region_<F>(st: &mut PState, conv: &mut F) -> ty::Region where
341341
let index = parse_u32(st);
342342
assert_eq!(next(st), '|');
343343
let nm = token::str_to_ident(&parse_str(st, ']'));
344-
ty::ReEarlyBound(node_id, space, index, nm.name)
344+
ty::ReEarlyBound(ty::EarlyBoundRegion {
345+
param_id: node_id,
346+
space: space,
347+
index: index,
348+
name: nm.name
349+
})
345350
}
346351
'f' => {
347352
assert_eq!(next(st), '[');

branches/try/src/librustc/metadata/tyencode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ pub fn enc_region(w: &mut Encoder, cx: &ctxt, r: ty::Region) {
241241
enc_bound_region(w, cx, br);
242242
mywrite!(w, "]");
243243
}
244-
ty::ReEarlyBound(node_id, space, index, name) => {
244+
ty::ReEarlyBound(ref data) => {
245245
mywrite!(w, "B[{}|{}|{}|{}]",
246-
node_id,
247-
space.to_uint(),
248-
index,
249-
token::get_name(name));
246+
data.param_id,
247+
data.space.to_uint(),
248+
data.index,
249+
token::get_name(data.name));
250250
}
251251
ty::ReFree(ref fr) => {
252252
mywrite!(w, "f[");

branches/try/src/librustc/middle/astencode.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,13 @@ impl tr for ty::Region {
496496
ty::ReLateBound(debruijn, br) => {
497497
ty::ReLateBound(debruijn, br.tr(dcx))
498498
}
499-
ty::ReEarlyBound(id, space, index, ident) => {
500-
ty::ReEarlyBound(dcx.tr_id(id), space, index, ident)
499+
ty::ReEarlyBound(data) => {
500+
ty::ReEarlyBound(ty::EarlyBoundRegion {
501+
param_id: dcx.tr_id(data.param_id),
502+
space: data.space,
503+
index: data.index,
504+
name: data.name,
505+
})
501506
}
502507
ty::ReScope(scope) => {
503508
ty::ReScope(scope.tr(dcx))

branches/try/src/librustc/middle/region.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,14 +603,11 @@ impl RegionMaps {
603603
self.sub_free_region(sub_fr, super_fr)
604604
}
605605

606-
(ty::ReEarlyBound(param_id_a, param_space_a, index_a, _),
607-
ty::ReEarlyBound(param_id_b, param_space_b, index_b, _)) => {
606+
(ty::ReEarlyBound(data_a), ty::ReEarlyBound(data_b)) => {
608607
// This case is used only to make sure that explicitly-
609608
// specified `Self` types match the real self type in
610-
// implementations.
611-
param_id_a == param_id_b &&
612-
param_space_a == param_space_b &&
613-
index_a == index_b
609+
// implementations. Yuck.
610+
data_a == data_b
614611
}
615612

616613
_ => {

branches/try/src/librustc/middle/subst.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,11 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
622622
// regions that appear in a function signature is done using
623623
// the specialized routine `ty::replace_late_regions()`.
624624
match r {
625-
ty::ReEarlyBound(_, space, i, region_name) => {
625+
ty::ReEarlyBound(data) => {
626626
match self.substs.regions {
627627
ErasedRegions => ty::ReStatic,
628628
NonerasedRegions(ref regions) =>
629-
match regions.opt_get(space, i as usize) {
629+
match regions.opt_get(data.space, data.index as usize) {
630630
Some(&r) => {
631631
self.shift_region_through_binders(r)
632632
}
@@ -635,11 +635,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
635635
self.tcx().sess.span_bug(
636636
span,
637637
&format!("Type parameter out of range \
638-
when substituting in region {} (root type={}) \
639-
(space={:?}, index={})",
640-
region_name.as_str(),
641-
self.root_ty.repr(self.tcx()),
642-
space, i));
638+
when substituting in region {} (root type={}) \
639+
(space={:?}, index={})",
640+
data.name.as_str(),
641+
self.root_ty.repr(self.tcx()),
642+
data.space,
643+
data.index));
643644
}
644645
}
645646
}

branches/try/src/librustc/middle/ty.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,7 @@ pub enum Region {
11341134
// Region bound in a type or fn declaration which will be
11351135
// substituted 'early' -- that is, at the same time when type
11361136
// parameters are substituted.
1137-
ReEarlyBound(/* param id */ ast::NodeId,
1138-
subst::ParamSpace,
1139-
/*index*/ u32,
1140-
ast::Name),
1137+
ReEarlyBound(EarlyBoundRegion),
11411138

11421139
// Region bound in a function scope, which will be substituted when the
11431140
// function is called.
@@ -1169,6 +1166,14 @@ pub enum Region {
11691166
ReEmpty,
11701167
}
11711168

1169+
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
1170+
pub struct EarlyBoundRegion {
1171+
pub param_id: ast::NodeId,
1172+
pub space: subst::ParamSpace,
1173+
pub index: u32,
1174+
pub name: ast::Name,
1175+
}
1176+
11721177
/// Upvars do not get their own node-id. Instead, we use the pair of
11731178
/// the original var id (that is, the root variable that is referenced
11741179
/// by the upvar) and the id of the closure expression.
@@ -1761,7 +1766,12 @@ pub struct RegionParameterDef {
17611766

17621767
impl RegionParameterDef {
17631768
pub fn to_early_bound_region(&self) -> ty::Region {
1764-
ty::ReEarlyBound(self.def_id.node, self.space, self.index, self.name)
1769+
ty::ReEarlyBound(ty::EarlyBoundRegion {
1770+
param_id: self.def_id.node,
1771+
space: self.space,
1772+
index: self.index,
1773+
name: self.name,
1774+
})
17651775
}
17661776
pub fn to_bound_region(&self) -> ty::BoundRegion {
17671777
ty::BoundRegion::BrNamed(self.def_id, self.name)
@@ -7071,8 +7081,7 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>,
70717081
let meth_regions: Vec<ty::Region> =
70727082
method.generics.regions.get_slice(subst::FnSpace)
70737083
.iter()
7074-
.map(|def| ty::ReEarlyBound(def.def_id.node, def.space,
7075-
def.index, def.name))
7084+
.map(|def| def.to_early_bound_region())
70767085
.collect();
70777086
trait_ref.substs.clone().with_method(meth_tps, meth_regions)
70787087
}

branches/try/src/librustc/session/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
606606
"Force overflow checks on or off"),
607607
force_dropflag_checks: Option<bool> = (None, parse_opt_bool,
608608
"Force drop flag checks on or off"),
609+
trace_macros: bool = (false, parse_bool,
610+
"For every macro invocation, print its name and arguments"),
609611
}
610612

611613
pub fn default_lib_output() -> CrateType {
@@ -667,7 +669,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
667669
Ok(t) => t,
668670
Err(e) => {
669671
sp.handler().fatal(&format!("Error loading target specification: {}", e));
670-
}
672+
}
671673
};
672674

673675
let (int_type, uint_type) = match &target.target_pointer_width[..] {

branches/try/src/librustc/util/ppaux.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
163163

164164
ReEmpty => { ("the empty lifetime".to_string(), None) }
165165

166-
ReEarlyBound(_, _, _, name) => {
167-
(format!("{}", token::get_name(name)), None)
166+
ReEarlyBound(ref data) => {
167+
(format!("{}", token::get_name(data.name)), None)
168168
}
169169

170170
// I believe these cases should not occur (except when debugging,
@@ -223,8 +223,8 @@ pub fn region_to_string(cx: &ctxt, prefix: &str, space: bool, region: Region) ->
223223
// `explain_region()` or `note_and_explain_region()`.
224224
match region {
225225
ty::ReScope(_) => prefix.to_string(),
226-
ty::ReEarlyBound(_, _, _, name) => {
227-
token::get_name(name).to_string()
226+
ty::ReEarlyBound(ref data) => {
227+
token::get_name(data.name).to_string()
228228
}
229229
ty::ReLateBound(_, br) => bound_region_to_string(cx, prefix, space, br),
230230
ty::ReFree(ref fr) => bound_region_to_string(cx, prefix, space, fr.bound_region),
@@ -810,8 +810,12 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
810810
// to enumerate the `for<...>` etc because the debruijn index
811811
// tells you everything you need to know.
812812
let base = ty::item_path_str(tcx, self.def_id);
813-
parameterized(tcx, &base, self.substs, self.def_id, &[],
814-
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone())
813+
let result = parameterized(tcx, &base, self.substs, self.def_id, &[],
814+
|| ty::lookup_trait_def(tcx, self.def_id).generics.clone());
815+
match self.substs.self_ty() {
816+
None => result,
817+
Some(sty) => format!("<{} as {}>", sty.repr(tcx), result)
818+
}
815819
}
816820
}
817821

@@ -899,12 +903,12 @@ impl<'tcx> Repr<'tcx> for ty::BoundRegion {
899903
impl<'tcx> Repr<'tcx> for ty::Region {
900904
fn repr(&self, tcx: &ctxt) -> String {
901905
match *self {
902-
ty::ReEarlyBound(id, space, index, name) => {
906+
ty::ReEarlyBound(ref data) => {
903907
format!("ReEarlyBound({}, {:?}, {}, {})",
904-
id,
905-
space,
906-
index,
907-
token::get_name(name))
908+
data.param_id,
909+
data.space,
910+
data.index,
911+
token::get_name(data.name))
908912
}
909913

910914
ty::ReLateBound(binder_id, ref bound_region) => {
@@ -1504,8 +1508,7 @@ impl<'tcx> UserString<'tcx> for ty::ProjectionPredicate<'tcx> {
15041508

15051509
impl<'tcx> Repr<'tcx> for ty::ProjectionTy<'tcx> {
15061510
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
1507-
format!("<{} as {}>::{}",
1508-
self.trait_ref.substs.self_ty().repr(tcx),
1511+
format!("{}::{}",
15091512
self.trait_ref.repr(tcx),
15101513
self.item_name.repr(tcx))
15111514
}

branches/try/src/librustc_driver/driver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
483483
crate_name: crate_name.to_string(),
484484
features: Some(&features),
485485
recursion_limit: sess.recursion_limit.get(),
486+
trace_mac: sess.opts.debugging_opts.trace_macros,
486487
};
487488
let ret = syntax::ext::expand::expand_crate(&sess.parse_sess,
488489
cfg,

branches/try/src/librustc_driver/test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,12 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
290290
-> ty::Region
291291
{
292292
let name = token::intern(name);
293-
ty::ReEarlyBound(ast::DUMMY_NODE_ID, space, index, name)
293+
ty::ReEarlyBound(ty::EarlyBoundRegion {
294+
param_id: ast::DUMMY_NODE_ID,
295+
space: space,
296+
index: index,
297+
name: name
298+
})
294299
}
295300

296301
pub fn re_late_bound_with_debruijn(&self, id: u32, debruijn: ty::DebruijnIndex) -> ty::Region {

branches/try/src/librustc_trans/trans/base.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,25 @@ fn cast_shift_rhs<F, G>(op: ast::BinOp_,
566566
}
567567
}
568568

569+
pub fn llty_and_min_for_signed_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
570+
val_t: Ty<'tcx>) -> (Type, u64) {
571+
match val_t.sty {
572+
ty::ty_int(t) => {
573+
let llty = Type::int_from_ty(cx.ccx(), t);
574+
let min = match t {
575+
ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
576+
ast::TyIs => i64::MIN as u64,
577+
ast::TyI8 => i8::MIN as u64,
578+
ast::TyI16 => i16::MIN as u64,
579+
ast::TyI32 => i32::MIN as u64,
580+
ast::TyI64 => i64::MIN as u64,
581+
};
582+
(llty, min)
583+
}
584+
_ => unreachable!(),
585+
}
586+
}
587+
569588
pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
570589
cx: Block<'blk, 'tcx>,
571590
call_info: NodeIdAndSpan,
@@ -620,21 +639,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
620639
// signed division/remainder which would trigger overflow. For unsigned
621640
// integers, no action beyond checking for zero need be taken.
622641
if is_signed {
623-
let (llty, min) = match rhs_t.sty {
624-
ty::ty_int(t) => {
625-
let llty = Type::int_from_ty(cx.ccx(), t);
626-
let min = match t {
627-
ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
628-
ast::TyIs => i64::MIN as u64,
629-
ast::TyI8 => i8::MIN as u64,
630-
ast::TyI16 => i16::MIN as u64,
631-
ast::TyI32 => i32::MIN as u64,
632-
ast::TyI64 => i64::MIN as u64,
633-
};
634-
(llty, min)
635-
}
636-
_ => unreachable!(),
637-
};
642+
let (llty, min) = llty_and_min_for_signed_ty(cx, rhs_t);
638643
let minus_one = ICmp(bcx, llvm::IntEQ, rhs,
639644
C_integral(llty, !0, false), debug_loc);
640645
with_cond(bcx, minus_one, |bcx| {

branches/try/src/librustc_trans/trans/expr.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,11 +1530,26 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
15301530
ast::UnNeg => {
15311531
let datum = unpack_datum!(bcx, trans(bcx, sub_expr));
15321532
let val = datum.to_llscalarish(bcx);
1533-
let llneg = {
1533+
let (bcx, llneg) = {
15341534
if ty::type_is_fp(un_ty) {
1535-
FNeg(bcx, val, debug_loc)
1535+
let result = FNeg(bcx, val, debug_loc);
1536+
(bcx, result)
15361537
} else {
1537-
Neg(bcx, val, debug_loc)
1538+
let is_signed = ty::type_is_signed(un_ty);
1539+
let result = Neg(bcx, val, debug_loc);
1540+
let bcx = if bcx.ccx().check_overflow() && is_signed {
1541+
let (llty, min) = base::llty_and_min_for_signed_ty(bcx, un_ty);
1542+
let is_min = ICmp(bcx, llvm::IntEQ, val,
1543+
C_integral(llty, min, true), debug_loc);
1544+
with_cond(bcx, is_min, |bcx| {
1545+
let msg = InternedString::new(
1546+
"attempted to negate with overflow");
1547+
controlflow::trans_fail(bcx, expr_info(expr), msg)
1548+
})
1549+
} else {
1550+
bcx
1551+
};
1552+
(bcx, result)
15381553
}
15391554
};
15401555
immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock()

0 commit comments

Comments
 (0)