Skip to content

Commit b508626

Browse files
committed
---
yaml --- r: 274147 b: refs/heads/stable c: e1cb0a3 h: refs/heads/master i: 274145: 37bc220 274143: d16c78a
1 parent 234d4e1 commit b508626

File tree

33 files changed

+439
-336
lines changed

33 files changed

+439
-336
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 2f4622a36fc45cc3ec130b52011a72e5ce2947f9
32+
refs/heads/stable: e1cb0a3508423383250662adb65137be4b86066b
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/configure

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,16 +1361,22 @@ for h in $CFG_HOST
13611361
do
13621362
for t in $CFG_TARGET
13631363
do
1364+
# host bin dir stage0
1365+
make_dir $h/stage0/bin
1366+
13641367
# host lib dir stage0
13651368
make_dir $h/stage0/lib
13661369

1370+
# host test dir stage0
1371+
make_dir $h/stage0/test
1372+
13671373
# target bin dir stage0
13681374
make_dir $h/stage0/lib/rustlib/$t/bin
13691375

13701376
# target lib dir stage0
13711377
make_dir $h/stage0/lib/rustlib/$t/lib
13721378

1373-
for i in 0 1 2 3
1379+
for i in 1 2 3
13741380
do
13751381
# host bin dir
13761382
make_dir $h/stage$i/bin

branches/stable/src/libcore/str/mod.rs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,34 @@ pub fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
244244
Ok(unsafe { from_utf8_unchecked(v) })
245245
}
246246

247+
/// Forms a str from a pointer and a length.
248+
///
249+
/// The `len` argument is the number of bytes in the string.
250+
///
251+
/// # Safety
252+
///
253+
/// This function is unsafe as there is no guarantee that the given pointer is
254+
/// valid for `len` bytes, nor whether the lifetime inferred is a suitable
255+
/// lifetime for the returned str.
256+
///
257+
/// The data must be valid UTF-8
258+
///
259+
/// `p` must be non-null, even for zero-length str.
260+
///
261+
/// # Caveat
262+
///
263+
/// The lifetime for the returned str is inferred from its usage. To
264+
/// prevent accidental misuse, it's suggested to tie the lifetime to whichever
265+
/// source lifetime is safe in the context, such as by providing a helper
266+
/// function taking the lifetime of a host value for the str, or by explicit
267+
/// annotation.
268+
/// Performs the same functionality as `from_raw_parts`, except that a mutable
269+
/// str is returned.
270+
///
271+
unsafe fn from_raw_parts_mut<'a>(p: *mut u8, len: usize) -> &'a mut str {
272+
mem::transmute::<&mut [u8], &mut str>(slice::from_raw_parts_mut(p, len))
273+
}
274+
247275
/// Converts a slice of bytes to a string slice without checking
248276
/// that the string contains valid UTF-8.
249277
///
@@ -1843,10 +1871,10 @@ impl StrExt for str {
18431871
// is_char_boundary checks that the index is in [0, .len()]
18441872
if self.is_char_boundary(mid) {
18451873
let len = self.len();
1874+
let ptr = self.as_ptr() as *mut u8;
18461875
unsafe {
1847-
let self2: &mut str = mem::transmute_copy(&self);
1848-
(self.slice_mut_unchecked(0, mid),
1849-
self2.slice_mut_unchecked(mid, len))
1876+
(from_raw_parts_mut(ptr, mid),
1877+
from_raw_parts_mut(ptr.offset(mid as isize), len - mid))
18501878
}
18511879
} else {
18521880
slice_error_fail(self, 0, mid)

branches/stable/src/liblibc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 9aa6600bd8f4e4f370a7d2fb76c4b3efc669cadf
1+
Subproject commit af77843345ec6fc7e51113bfd692138d89024bc0

branches/stable/src/librustc/middle/const_eval.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,20 +1233,11 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
12331233
rcvr_substs: subst::Substs<'tcx>)
12341234
-> Option<&'tcx Expr>
12351235
{
1236-
let subst::SeparateVecsPerParamSpace {
1237-
types: rcvr_type,
1238-
selfs: rcvr_self,
1239-
fns: _,
1240-
} = rcvr_substs.types.split();
1241-
let trait_substs =
1242-
subst::Substs::erased(subst::VecPerParamSpace::new(rcvr_type,
1243-
rcvr_self,
1244-
Vec::new()));
1245-
let trait_substs = tcx.mk_substs(trait_substs);
1246-
debug!("resolve_trait_associated_const: trait_substs={:?}",
1247-
trait_substs);
1248-
let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id,
1249-
substs: trait_substs });
1236+
let trait_ref = ty::Binder(
1237+
rcvr_substs.erase_regions().to_trait_ref(tcx, trait_id)
1238+
);
1239+
debug!("resolve_trait_associated_const: trait_ref={:?}",
1240+
trait_ref);
12501241

12511242
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
12521243
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);

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

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use self::ParamSpace::*;
1414
pub use self::RegionSubsts::*;
1515

1616
use middle::cstore;
17+
use middle::def_id::DefId;
1718
use middle::ty::{self, Ty};
1819
use middle::ty::fold::{TypeFoldable, TypeFolder};
1920

@@ -142,16 +143,34 @@ impl<'tcx> Substs<'tcx> {
142143
-> Substs<'tcx>
143144
{
144145
let Substs { types, regions } = self;
145-
let types = types.with_vec(FnSpace, m_types);
146-
let regions = regions.map(|r| r.with_vec(FnSpace, m_regions));
146+
let types = types.with_slice(FnSpace, &m_types);
147+
let regions = regions.map(|r| r.with_slice(FnSpace, &m_regions));
147148
Substs { types: types, regions: regions }
148149
}
149150

150-
pub fn method_to_trait(self) -> Substs<'tcx> {
151-
let Substs { mut types, regions } = self;
151+
pub fn with_method_from(self,
152+
meth_substs: &Substs<'tcx>)
153+
-> Substs<'tcx>
154+
{
155+
let Substs { types, regions } = self;
156+
let types = types.with_slice(FnSpace, meth_substs.types.get_slice(FnSpace));
157+
let regions = regions.map(|r| {
158+
r.with_slice(FnSpace, meth_substs.regions().get_slice(FnSpace))
159+
});
160+
Substs { types: types, regions: regions }
161+
}
162+
163+
/// Creates a trait-ref out of this substs, ignoring the FnSpace substs
164+
pub fn to_trait_ref(&self, tcx: &ty::ctxt<'tcx>, trait_id: DefId)
165+
-> ty::TraitRef<'tcx> {
166+
let Substs { mut types, regions } = self.clone();
152167
types.truncate(FnSpace, 0);
153168
let regions = regions.map(|mut r| { r.truncate(FnSpace, 0); r });
154-
Substs { types: types, regions: regions }
169+
170+
ty::TraitRef {
171+
def_id: trait_id,
172+
substs: tcx.mk_substs(Substs { types: types, regions: regions })
173+
}
155174
}
156175
}
157176

@@ -290,10 +309,6 @@ impl<T> VecPerParamSpace<T> {
290309
}
291310
}
292311

293-
pub fn params_from_type(types: Vec<T>) -> VecPerParamSpace<T> {
294-
VecPerParamSpace::empty().with_vec(TypeSpace, types)
295-
}
296-
297312
/// `t` is the type space.
298313
/// `s` is the self space.
299314
/// `f` is the fn space.
@@ -483,11 +498,15 @@ impl<T> VecPerParamSpace<T> {
483498
}
484499
}
485500

486-
pub fn with_vec(mut self, space: ParamSpace, vec: Vec<T>)
501+
pub fn with_slice(mut self, space: ParamSpace, slice: &[T])
487502
-> VecPerParamSpace<T>
503+
where T: Clone
488504
{
489505
assert!(self.is_empty_in(space));
490-
self.replace(space, vec);
506+
for t in slice {
507+
self.push(space, t.clone());
508+
}
509+
491510
self
492511
}
493512
}

branches/stable/src/librustc/middle/ty/util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ pub struct ImplMethod<'tcx> {
604604
}
605605

606606
impl<'tcx> ty::ctxt<'tcx> {
607-
#[inline(never)] // is this perfy enough?
608607
pub fn get_impl_method(&self,
609608
impl_def_id: DefId,
610609
substs: Substs<'tcx>,

branches/stable/src/librustc/mir/repr.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ pub enum Rvalue<'tcx> {
683683
Use(Operand<'tcx>),
684684

685685
// [x; 32]
686-
Repeat(Operand<'tcx>, Constant<'tcx>),
686+
Repeat(Operand<'tcx>, TypedConstVal<'tcx>),
687687

688688
// &x or &mut x
689689
Ref(Region, BorrowKind, Lvalue<'tcx>),
@@ -891,6 +891,20 @@ pub struct Constant<'tcx> {
891891
pub literal: Literal<'tcx>,
892892
}
893893

894+
#[derive(Clone, RustcEncodable, RustcDecodable)]
895+
pub struct TypedConstVal<'tcx> {
896+
pub ty: Ty<'tcx>,
897+
pub span: Span,
898+
pub value: ConstVal
899+
}
900+
901+
impl<'tcx> Debug for TypedConstVal<'tcx> {
902+
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
903+
try!(write!(fmt, "const "));
904+
fmt_const_val(fmt, &self.value)
905+
}
906+
}
907+
894908
#[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, RustcDecodable)]
895909
pub enum ItemKind {
896910
Constant,

branches/stable/src/librustc/mir/visit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ macro_rules! make_mir_visitor {
213213
}
214214

215215
Rvalue::Repeat(ref $($mutability)* value,
216-
ref $($mutability)* len) => {
216+
_) => {
217217
self.visit_operand(value);
218-
self.visit_constant(len);
219218
}
220219

221220
Rvalue::Ref(r, bk, ref $($mutability)* path) => {

branches/stable/src/librustc_data_structures/bitvec.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ impl BitVector {
2424
(self.data[word] & mask) != 0
2525
}
2626

27+
/// Returns true if the bit has changed.
2728
pub fn insert(&mut self, bit: usize) -> bool {
2829
let (word, mask) = word_mask(bit);
2930
let data = &mut self.data[word];
3031
let value = *data;
31-
*data = value | mask;
32-
(value | mask) != value
32+
let new_value = value | mask;
33+
*data = new_value;
34+
new_value != value
3335
}
3436

3537
pub fn insert_all(&mut self, all: &BitVector) -> bool {

branches/stable/src/librustc_lint/builtin.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,7 @@ impl LateLintPass for UnconditionalRecursion {
855855
// A trait method, from any number of possible sources.
856856
// Attempt to select a concrete impl before checking.
857857
ty::TraitContainer(trait_def_id) => {
858-
let trait_substs = callee_substs.clone().method_to_trait();
859-
let trait_substs = tcx.mk_substs(trait_substs);
860-
let trait_ref = ty::TraitRef::new(trait_def_id, trait_substs);
858+
let trait_ref = callee_substs.to_trait_ref(tcx, trait_def_id);
861859
let trait_ref = ty::Binder(trait_ref);
862860
let span = tcx.map.span(expr_id);
863861
let obligation =

branches/stable/src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<'a,'tcx> Builder<'a,'tcx> {
4444
}
4545
ExprKind::Repeat { value, count } => {
4646
let value_operand = unpack!(block = this.as_operand(block, value));
47-
let count = this.as_constant(count);
4847
block.and(Rvalue::Repeat(value_operand, count))
4948
}
5049
ExprKind::Borrow { region, borrow_kind, arg } => {

branches/stable/src/librustc_mir/hair/cx/expr.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use hair::cx::block;
1515
use hair::cx::to_ref::ToRef;
1616
use rustc::front::map;
1717
use rustc::middle::def::Def;
18+
use rustc::middle::const_eval;
1819
use rustc::middle::region::CodeExtent;
1920
use rustc::middle::pat_util;
2021
use rustc::middle::ty::{self, VariantDef, Ty};
@@ -325,14 +326,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
325326

326327
hir::ExprRepeat(ref v, ref c) => ExprKind::Repeat {
327328
value: v.to_ref(),
328-
count: Expr {
329+
count: TypedConstVal {
329330
ty: cx.tcx.expr_ty(c),
330-
temp_lifetime: None,
331331
span: c.span,
332-
kind: ExprKind::Literal {
333-
literal: cx.const_eval_literal(c)
334-
}
335-
}.to_ref()
332+
value: const_eval::eval_const_expr(cx.tcx, c)
333+
}
336334
},
337335
hir::ExprRet(ref v) =>
338336
ExprKind::Return { value: v.to_ref() },

branches/stable/src/librustc_mir/hair/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
//! unit-tested and separated from the Rust source and compiler data
1515
//! structures.
1616
17-
use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind};
17+
use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind,
18+
TypedConstVal};
1819
use rustc::middle::const_eval::ConstVal;
1920
use rustc::middle::def_id::DefId;
2021
use rustc::middle::region::CodeExtent;
@@ -213,10 +214,7 @@ pub enum ExprKind<'tcx> {
213214
},
214215
Repeat {
215216
value: ExprRef<'tcx>,
216-
// FIXME(#29789): Add a separate hair::Constant<'tcx> so this could be more explicit about
217-
// its contained data. Currently this should only contain expression of ExprKind::Literal
218-
// kind.
219-
count: ExprRef<'tcx>,
217+
count: TypedConstVal<'tcx>,
220218
},
221219
Vec {
222220
fields: Vec<ExprRef<'tcx>>,

branches/stable/src/librustc_mir/transform/erase_regions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl<'a, 'tcx> EraseRegions<'a, 'tcx> {
143143
Rvalue::Use(ref mut operand) => {
144144
self.erase_regions_operand(operand)
145145
}
146-
Rvalue::Repeat(ref mut operand, ref mut constant) => {
146+
Rvalue::Repeat(ref mut operand, ref mut value) => {
147147
self.erase_regions_operand(operand);
148-
self.erase_regions_constant(constant);
148+
value.ty = self.tcx.erase_regions(&value.ty);
149149
}
150150
Rvalue::Ref(ref mut region, _, ref mut lvalue) => {
151151
*region = ty::ReStatic;

branches/stable/src/librustc_resolve/build_reduced_graph.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
510510
self.structs.insert(variant_def_id, Vec::new());
511511
}
512512

513+
// Variants are always treated as importable to allow them to be glob used.
514+
// All variants are defined in both type and value namespaces as future-proofing.
513515
let child = self.add_child(name, parent, ForbidDuplicateTypesAndValues, variant.span);
514-
// variants are always treated as importable to allow them to be glob
515-
// used
516516
child.define_value(Def::Variant(item_id, self.ast_map.local_def_id(variant.node.data.id())),
517517
variant.span,
518518
DefModifiers::PUBLIC | DefModifiers::IMPORTABLE | variant_modifiers);
@@ -618,15 +618,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
618618
Def::Variant(_, variant_id) => {
619619
debug!("(building reduced graph for external crate) building variant {}",
620620
final_ident);
621-
// variants are always treated as importable to allow them to be
622-
// glob used
621+
// Variants are always treated as importable to allow them to be glob used.
622+
// All variants are defined in both type and value namespaces as future-proofing.
623623
let modifiers = DefModifiers::PUBLIC | DefModifiers::IMPORTABLE;
624+
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
625+
child_name_bindings.define_value(def, DUMMY_SP, modifiers);
624626
if self.session.cstore.variant_kind(variant_id) == Some(VariantKind::Struct) {
625-
child_name_bindings.define_type(def, DUMMY_SP, modifiers);
626627
// Not adding fields for variants as they are not accessed with a self receiver
627628
self.structs.insert(variant_id, Vec::new());
628-
} else {
629-
child_name_bindings.define_value(def, DUMMY_SP, modifiers);
630629
}
631630
}
632631
Def::Fn(..) |

branches/stable/src/librustc_trans/back/link.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ fn command_path(sess: &Session) -> OsString {
396396
if let Some(path) = env::var_os("PATH") {
397397
new_path.extend(env::split_paths(&path));
398398
}
399+
if sess.target.target.options.is_like_msvc {
400+
new_path.extend(msvc::host_dll_path());
401+
}
399402
env::join_paths(new_path).unwrap()
400403
}
401404

0 commit comments

Comments
 (0)