Skip to content

Commit 1b06fd4

Browse files
committed
---
yaml --- r: 277619 b: refs/heads/try c: 74d1520 h: refs/heads/master i: 277617: 16fb2bd 277615: b8e778c
1 parent edfd372 commit 1b06fd4

File tree

20 files changed

+106
-311
lines changed

20 files changed

+106
-311
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: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 7a0ccc458f32b2cb2dee33d7a02954a70c09c34b
4+
refs/heads/try: 74d1520c22943a0306c856c1fb873826c3c0760f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/mk/tests.mk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
636636
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
637637
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
638638
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
639-
--cc '$$(CC_$(3))' \
640-
--cxx '$$(CXX_$(3))' \
641-
--cflags "$$(CFG_GCCISH_CFLAGS_$(3))" \
642-
--llvm-components "$$(LLVM_ALL_COMPONENTS_$(3))" \
643-
--llvm-cxxflags "$$(LLVM_CXXFLAGS_$(3))" \
639+
--cc '$$(CC_$(2))' \
640+
--cxx '$$(CXX_$(2))' \
641+
--cflags "$$(CFG_GCCISH_CFLAGS_$(2))" \
642+
--llvm-components "$$(LLVM_ALL_COMPONENTS_$(2))" \
643+
--llvm-cxxflags "$$(LLVM_CXXFLAGS_$(2))" \
644644
$$(CTEST_TESTARGS)
645645

646646
ifdef CFG_VALGRIND_RPASS

branches/try/src/doc/book/getting-started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ we’ll talk about Cargo, Rust’s build system and package manager.
88

99
The first step to using Rust is to install it. Generally speaking, you’ll need
1010
an Internet connection to run the commands in this section, as we’ll be
11-
downloading Rust from the Internet.
11+
downloading Rust from the internet.
1212

1313
We’ll be showing off a number of commands using a terminal, and those lines all
1414
start with `$`. We don't need to type in the `$`s, they are there to indicate
@@ -399,13 +399,13 @@ Let’s convert the Hello World program to Cargo. To Cargo-fy a project, you nee
399399
to do three things:
400400

401401
1. Put your source file in the right directory.
402-
2. Get rid of the old executable (`main.exe` on Windows, `main` everywhere
403-
else).
402+
2. Get rid of the old executable (`main.exe` on Windows, `main` everywhere else)
403+
and make a new one.
404404
3. Make a Cargo configuration file.
405405

406406
Let's get started!
407407

408-
### Creating a Source Directory and Removing the Old Executable
408+
### Creating a new Executable and Source Directory
409409

410410
First, go back to your terminal, move to your *hello_world* directory, and
411411
enter the following commands:

branches/try/src/libcollections/fmt.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
//! precision := count | '*'
334334
//! type := identifier | ''
335335
//! count := parameter | integer
336-
//! parameter := argument '$'
336+
//! parameter := integer '$'
337337
//! ```
338338
//!
339339
//! # Formatting Parameters
@@ -403,12 +403,11 @@
403403
//! println!("Hello {:5}!", "x");
404404
//! println!("Hello {:1$}!", "x", 5);
405405
//! println!("Hello {1:0$}!", 5, "x");
406-
//! println!("Hello {:width$}!", "x", width = 5);
407406
//! ```
408407
//!
409408
//! Referring to an argument with the dollar syntax does not affect the "next
410-
//! argument" counter, so it's usually a good idea to refer to arguments by
411-
//! position, or use named arguments.
409+
//! argument" counter, so it's usually a good idea to refer to all arguments by
410+
//! their position explicitly.
412411
//!
413412
//! ## Precision
414413
//!
@@ -427,7 +426,7 @@
427426
//!
428427
//! the integer `N` itself is the precision.
429428
//!
430-
//! 2. An integer or name followed by dollar sign `.N$`:
429+
//! 2. An integer followed by dollar sign `.N$`:
431430
//!
432431
//! use format *argument* `N` (which must be a `usize`) as the precision.
433432
//!
@@ -457,10 +456,6 @@
457456
//! // Hello {next arg (x)} is {arg 2 (0.01) with precision
458457
//! // specified in its predecessor (5)}
459458
//! println!("Hello {} is {2:.*}", "x", 5, 0.01);
460-
//!
461-
//! // Hello {next arg (x)} is {arg "number" (0.01) with precision specified
462-
//! // in arg "prec" (5)}
463-
//! println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
464459
//! ```
465460
//!
466461
//! All print the same thing:

branches/try/src/libcore/mem.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ pub use intrinsics::transmute;
110110
/// }
111111
/// }
112112
/// ```
113-
#[inline]
114113
#[stable(feature = "rust1", since = "1.0.0")]
115114
pub fn forget<T>(t: T) {
116115
unsafe { intrinsics::forget(t) }

branches/try/src/librustc_borrowck/diagnostics.rs

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -314,82 +314,6 @@ let c = &i; // still ok!
314314
```
315315
"##,
316316

317-
E0501: r##"
318-
This error indicates that a mutable variable is being used while it is still
319-
captured by a closure. Because the closure has borrowed the variable, it is not
320-
available for use until the closure goes out of scope.
321-
322-
Note that a capture will either move or borrow a variable, but in this
323-
situation, the closure is borrowing the variable. Take a look at
324-
http://rustbyexample.com/fn/closures/capture.html for more information about
325-
capturing.
326-
327-
Example of erroneous code:
328-
329-
```compile_fail
330-
fn inside_closure(x: &mut i32) {
331-
// Actions which require unique access
332-
}
333-
334-
fn outside_closure(x: &mut i32) {
335-
// Actions which require unique access
336-
}
337-
338-
fn foo(a: &mut i32) {
339-
let bar = || {
340-
inside_closure(a)
341-
};
342-
outside_closure(a); // error: cannot borrow `*a` as mutable because previous
343-
// closure requires unique access.
344-
}
345-
```
346-
347-
To fix this error, you can place the closure in its own scope:
348-
349-
```
350-
fn inside_closure(x: &mut i32) {}
351-
fn outside_closure(x: &mut i32) {}
352-
353-
fn foo(a: &mut i32) {
354-
{
355-
let bar = || {
356-
inside_closure(a)
357-
};
358-
} // borrow on `a` ends.
359-
outside_closure(a); // ok!
360-
}
361-
```
362-
363-
Or you can pass the variable as a parameter to the closure:
364-
365-
```
366-
fn inside_closure(x: &mut i32) {}
367-
fn outside_closure(x: &mut i32) {}
368-
369-
fn foo(a: &mut i32) {
370-
let bar = |s: &mut i32| {
371-
inside_closure(s)
372-
};
373-
outside_closure(a);
374-
bar(a);
375-
}
376-
```
377-
378-
It may be possible to define the closure later:
379-
380-
```
381-
fn inside_closure(x: &mut i32) {}
382-
fn outside_closure(x: &mut i32) {}
383-
384-
fn foo(a: &mut i32) {
385-
outside_closure(a);
386-
let bar = || {
387-
inside_closure(a)
388-
};
389-
}
390-
```
391-
"##,
392-
393317
E0507: r##"
394318
You tried to move out of a value which was borrowed. Erroneous code example:
395319
@@ -512,6 +436,7 @@ register_diagnostics! {
512436
E0388, // {} in a static location
513437
E0389, // {} in a `&` reference
514438
E0500, // closure requires unique access to `..` but .. is already borrowed
439+
E0501, // cannot borrow `..`.. as .. because previous closure requires unique access
515440
E0502, // cannot borrow `..`.. as .. because .. is also borrowed as ...
516441
E0503, // cannot use `..` because it was mutably borrowed
517442
E0504, // cannot move `..` into closure because it is borrowed

branches/try/src/librustc_const_eval/eval.rs

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ pub enum ErrKind {
377377
NotOn(ConstVal),
378378
CallOn(ConstVal),
379379

380+
NegateWithOverflow(i64),
381+
AddiWithOverflow(i64, i64),
382+
SubiWithOverflow(i64, i64),
383+
MuliWithOverflow(i64, i64),
384+
AdduWithOverflow(u64, u64),
385+
SubuWithOverflow(u64, u64),
386+
MuluWithOverflow(u64, u64),
380387
DivideByZero,
381388
DivideWithOverflow,
382389
ModuloByZero,
@@ -408,7 +415,6 @@ pub enum ErrKind {
408415
TypeMismatch(String, ConstInt),
409416
BadType(ConstVal),
410417
ErroneousReferencedConstant(Box<ConstEvalErr>),
411-
CharCast(ConstInt),
412418
}
413419

414420
impl From<ConstMathErr> for ErrKind {
@@ -433,6 +439,13 @@ impl ConstEvalErr {
433439
NotOn(ref const_val) => format!("not on {}", const_val.description()).into_cow(),
434440
CallOn(ref const_val) => format!("call on {}", const_val.description()).into_cow(),
435441

442+
NegateWithOverflow(..) => "attempted to negate with overflow".into_cow(),
443+
AddiWithOverflow(..) => "attempted to add with overflow".into_cow(),
444+
SubiWithOverflow(..) => "attempted to sub with overflow".into_cow(),
445+
MuliWithOverflow(..) => "attempted to mul with overflow".into_cow(),
446+
AdduWithOverflow(..) => "attempted to add with overflow".into_cow(),
447+
SubuWithOverflow(..) => "attempted to sub with overflow".into_cow(),
448+
MuluWithOverflow(..) => "attempted to mul with overflow".into_cow(),
436449
DivideByZero => "attempted to divide by zero".into_cow(),
437450
DivideWithOverflow => "attempted to divide with overflow".into_cow(),
438451
ModuloByZero => "attempted remainder with a divisor of zero".into_cow(),
@@ -469,9 +482,6 @@ impl ConstEvalErr {
469482
},
470483
BadType(ref i) => format!("value of wrong type: {:?}", i).into_cow(),
471484
ErroneousReferencedConstant(_) => "could not evaluate referenced constant".into_cow(),
472-
CharCast(ref got) => {
473-
format!("only `u8` can be cast as `char`, not `{}`", got.description()).into_cow()
474-
},
475485
}
476486
}
477487
}
@@ -814,10 +824,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
814824
debug!("const call({:?})", call_args);
815825
eval_const_expr_partial(tcx, &result, ty_hint, Some(&call_args))?
816826
},
817-
hir::ExprLit(ref lit) => match lit_to_const(&lit.node, tcx, ety, lit.span) {
818-
Ok(val) => val,
819-
Err(err) => signal!(e, err),
820-
},
827+
hir::ExprLit(ref lit) => lit_to_const(&lit.node, tcx, ety, lit.span)?,
821828
hir::ExprBlock(ref block) => {
822829
match block.expr {
823830
Some(ref expr) => eval_const_expr_partial(tcx, &expr, ty_hint, fn_args)?,
@@ -923,10 +930,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
923930
};
924931

925932
match (ety.map(|t| &t.sty), result) {
926-
(Some(ref ty_hint), Integral(i)) => match infer(i, tcx, ty_hint) {
927-
Ok(inferred) => Ok(Integral(inferred)),
928-
Err(err) => signal!(e, err),
929-
},
933+
(Some(ref ty_hint), Integral(i)) => Ok(Integral(infer(i, tcx, ty_hint, e.span)?)),
930934
(_, result) => Ok(result),
931935
}
932936
}
@@ -935,9 +939,15 @@ fn infer<'tcx>(
935939
i: ConstInt,
936940
tcx: &TyCtxt<'tcx>,
937941
ty_hint: &ty::TypeVariants<'tcx>,
938-
) -> Result<ConstInt, ErrKind> {
942+
span: Span
943+
) -> Result<ConstInt, ConstEvalErr> {
939944
use syntax::ast::*;
940945

946+
let err = |e| ConstEvalErr {
947+
span: span,
948+
kind: e,
949+
};
950+
941951
match (ty_hint, i) {
942952
(&ty::TyInt(IntTy::I8), result @ I8(_)) => Ok(result),
943953
(&ty::TyInt(IntTy::I16), result @ I16(_)) => Ok(result),
@@ -983,17 +993,17 @@ fn infer<'tcx>(
983993
Err(_) => Ok(Usize(ConstUsize::Us32(i as u32))),
984994
}
985995
},
986-
(&ty::TyUint(_), InferSigned(_)) => Err(IntermediateUnsignedNegative),
996+
(&ty::TyUint(_), InferSigned(_)) => Err(err(IntermediateUnsignedNegative)),
987997

988-
(&ty::TyInt(ity), i) => Err(TypeMismatch(ity.to_string(), i)),
989-
(&ty::TyUint(ity), i) => Err(TypeMismatch(ity.to_string(), i)),
998+
(&ty::TyInt(ity), i) => Err(err(TypeMismatch(ity.to_string(), i))),
999+
(&ty::TyUint(ity), i) => Err(err(TypeMismatch(ity.to_string(), i))),
9901000

9911001
(&ty::TyEnum(ref adt, _), i) => {
9921002
let hints = tcx.lookup_repr_hints(adt.did);
9931003
let int_ty = tcx.enum_repr_type(hints.iter().next());
994-
infer(i, tcx, &int_ty.to_ty(tcx).sty)
1004+
infer(i, tcx, &int_ty.to_ty(tcx).sty, span)
9951005
},
996-
(_, i) => Err(BadType(ConstVal::Integral(i))),
1006+
(_, i) => Err(err(BadType(ConstVal::Integral(i)))),
9971007
}
9981008
}
9991009

@@ -1079,22 +1089,23 @@ fn cast_const_int<'tcx>(tcx: &TyCtxt<'tcx>, val: ConstInt, ty: ty::Ty) -> CastRe
10791089
Err(_) => Ok(Integral(Usize(ConstUsize::Us32(v as u32)))),
10801090
}
10811091
},
1082-
ty::TyFloat(ast::FloatTy::F64) => match val.erase_type() {
1083-
Infer(u) => Ok(Float(u as f64)),
1084-
InferSigned(i) => Ok(Float(i as f64)),
1085-
_ => bug!("ConstInt::erase_type returned something other than Infer/InferSigned"),
1092+
ty::TyFloat(ast::FloatTy::F64) if val.is_negative() => {
1093+
// FIXME: this could probably be prettier
1094+
// there's no easy way to turn an `Infer` into a f64
1095+
let val = (-val).map_err(Math)?;
1096+
let val = val.to_u64().unwrap() as f64;
1097+
let val = -val;
1098+
Ok(Float(val))
10861099
},
1087-
ty::TyFloat(ast::FloatTy::F32) => match val.erase_type() {
1088-
Infer(u) => Ok(Float(u as f32 as f64)),
1089-
InferSigned(i) => Ok(Float(i as f32 as f64)),
1090-
_ => bug!("ConstInt::erase_type returned something other than Infer/InferSigned"),
1100+
ty::TyFloat(ast::FloatTy::F64) => Ok(Float(val.to_u64().unwrap() as f64)),
1101+
ty::TyFloat(ast::FloatTy::F32) if val.is_negative() => {
1102+
let val = (-val).map_err(Math)?;
1103+
let val = val.to_u64().unwrap() as f32;
1104+
let val = -val;
1105+
Ok(Float(val as f64))
10911106
},
1107+
ty::TyFloat(ast::FloatTy::F32) => Ok(Float(val.to_u64().unwrap() as f32 as f64)),
10921108
ty::TyRawPtr(_) => Err(ErrKind::UnimplementedConstVal("casting an address to a raw ptr")),
1093-
ty::TyChar => match infer(val, tcx, &ty::TyUint(ast::UintTy::U8)) {
1094-
Ok(U8(u)) => Ok(Char(u as char)),
1095-
// can only occur before typeck, typeck blocks `T as char` for `T` != `u8`
1096-
_ => Err(CharCast(val)),
1097-
},
10981109
_ => Err(CannotCast),
10991110
}
11001111
}
@@ -1125,36 +1136,36 @@ fn lit_to_const<'tcx>(lit: &ast::LitKind,
11251136
tcx: &TyCtxt<'tcx>,
11261137
ty_hint: Option<Ty<'tcx>>,
11271138
span: Span,
1128-
) -> Result<ConstVal, ErrKind> {
1139+
) -> Result<ConstVal, ConstEvalErr> {
11291140
use syntax::ast::*;
11301141
use syntax::ast::LitIntType::*;
11311142
match *lit {
11321143
LitKind::Str(ref s, _) => Ok(Str((*s).clone())),
11331144
LitKind::ByteStr(ref data) => Ok(ByteStr(data.clone())),
11341145
LitKind::Byte(n) => Ok(Integral(U8(n))),
11351146
LitKind::Int(n, Signed(ity)) => {
1136-
infer(InferSigned(n as i64), tcx, &ty::TyInt(ity)).map(Integral)
1147+
infer(InferSigned(n as i64), tcx, &ty::TyInt(ity), span).map(Integral)
11371148
},
11381149

11391150
LitKind::Int(n, Unsuffixed) => {
11401151
match ty_hint.map(|t| &t.sty) {
11411152
Some(&ty::TyInt(ity)) => {
1142-
infer(InferSigned(n as i64), tcx, &ty::TyInt(ity)).map(Integral)
1153+
infer(InferSigned(n as i64), tcx, &ty::TyInt(ity), span).map(Integral)
11431154
},
11441155
Some(&ty::TyUint(uty)) => {
1145-
infer(Infer(n), tcx, &ty::TyUint(uty)).map(Integral)
1156+
infer(Infer(n), tcx, &ty::TyUint(uty), span).map(Integral)
11461157
},
11471158
None => Ok(Integral(Infer(n))),
11481159
Some(&ty::TyEnum(ref adt, _)) => {
11491160
let hints = tcx.lookup_repr_hints(adt.did);
11501161
let int_ty = tcx.enum_repr_type(hints.iter().next());
1151-
infer(Infer(n), tcx, &int_ty.to_ty(tcx).sty).map(Integral)
1162+
infer(Infer(n), tcx, &int_ty.to_ty(tcx).sty, span).map(Integral)
11521163
},
11531164
Some(ty_hint) => bug!("bad ty_hint: {:?}, {:?}", ty_hint, lit),
11541165
}
11551166
},
11561167
LitKind::Int(n, Unsigned(ity)) => {
1157-
infer(Infer(n), tcx, &ty::TyUint(ity)).map(Integral)
1168+
infer(Infer(n), tcx, &ty::TyUint(ity), span).map(Integral)
11581169
},
11591170

11601171
LitKind::Float(ref n, _) |

0 commit comments

Comments
 (0)