Skip to content

Commit beffc27

Browse files
committed
---
yaml --- r: 212213 b: refs/heads/tmp c: ef72938 h: refs/heads/master i: 212211: 3616c06 v: v3
1 parent 7a5eba5 commit beffc27

File tree

27 files changed

+312
-236
lines changed

27 files changed

+312
-236
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 62e70d35be3fe532c26a400b499c58a18f18dd3a
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 7f3ae0aa26d24100379ae0f3eef29916a32f4e79
35+
refs/heads/tmp: ef72938a8b9171abc5c4b463d3e8345dc0e603a6
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: b77d60adb019bb5de05e884a99f3290ec4694137
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ Hajime Morrita <[email protected]>
338338
Hanno Braun <[email protected]>
339339
Harry Marr <[email protected]>
340340
341-
Heejong Ahn <[email protected]
341+
Heejong Ahn <[email protected]>
342342
Henrik Schopmans <[email protected]>
343343
Herman J. Radtke III <[email protected]>
344344
HeroesGrave <[email protected]>

branches/tmp/configure

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,12 @@ CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm/
13071307
for t in $CFG_HOST
13081308
do
13091309
do_reconfigure=1
1310+
is_msvc=0
1311+
case "$t" in
1312+
(*-msvc)
1313+
is_msvc=1
1314+
;;
1315+
esac
13101316

13111317
if [ -z $CFG_LLVM_ROOT ]
13121318
then
@@ -1326,7 +1332,13 @@ do
13261332
LLVM_ASSERTION_OPTS="--disable-assertions"
13271333
else
13281334
LLVM_ASSERTION_OPTS="--enable-assertions"
1329-
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
1335+
1336+
# Apparently even if we request assertions be enabled for MSVC,
1337+
# LLVM's CMake build system ignore this and outputs in `Release`
1338+
# anyway.
1339+
if [ ${is_msvc} -eq 0 ]; then
1340+
LLVM_INST_DIR=${LLVM_INST_DIR}+Asserts
1341+
fi
13301342
fi
13311343
else
13321344
msg "not reconfiguring LLVM, external LLVM root"
@@ -1356,14 +1368,7 @@ do
13561368
done
13571369
fi
13581370

1359-
use_cmake=0
1360-
case "$t" in
1361-
(*-msvc)
1362-
use_cmake=1
1363-
;;
1364-
esac
1365-
1366-
if [ ${do_reconfigure} -ne 0 ] && [ ${use_cmake} -ne 0 ]
1371+
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -ne 0 ]
13671372
then
13681373
msg "configuring LLVM for $t with cmake"
13691374

@@ -1388,7 +1393,7 @@ do
13881393
need_ok "LLVM cmake configure failed"
13891394
fi
13901395

1391-
if [ ${do_reconfigure} -ne 0 ] && [ ${use_cmake} -eq 0 ]
1396+
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -eq 0 ]
13921397
then
13931398
# LLVM's configure doesn't recognize the new Windows triples yet
13941399
gnu_t=$(to_gnu_triple $t)

branches/tmp/src/doc/reference.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,6 +3599,147 @@ The notation `&self` is a shorthand for `self: &Self`. In this case,
35993599
in the impl, `Self` refers to the value of type `String` that is the
36003600
receiver for a call to the method `make_string`.
36013601

3602+
## Subtyping
3603+
3604+
Subtyping is implicit and can occur at any stage in type checking or
3605+
inference. Subtyping in Rust is very restricted and occurs only due to
3606+
variance with respect to lifetimes and between types with higher ranked
3607+
lifetimes. If we were to erase lifetimes from types, then the only subtyping
3608+
would be due to type equality.
3609+
3610+
Consider the following example: string literals always have `'static`
3611+
lifetime. Nevertheless, we can assign `s` to `t`:
3612+
3613+
```
3614+
fn bar<'a>() {
3615+
let s: &'static str = "hi";
3616+
let t: &'a str = s;
3617+
}
3618+
```
3619+
Since `'static` "lives longer" than `'a`, `&'static str` is a subtype of
3620+
`&'a str`.
3621+
3622+
## Type coercions
3623+
3624+
Coercions are defined in [RFC401]. A coercion is implicit and has no syntax.
3625+
3626+
[RFC401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
3627+
3628+
### Coercion sites
3629+
3630+
A coercion can only occur at certain coercion sites in a program; these are
3631+
typically places where the desired type is explicit or can be dervied by
3632+
propagation from explicit types (without type inference). Possible coercion
3633+
sites are:
3634+
3635+
* `let` statements where an explicit type is given.
3636+
3637+
In `let _: U = e;`, `e` is coerced to have type `U`.
3638+
3639+
* `static` and `const` statements (similar to `let` statements).
3640+
3641+
* arguments for function calls.
3642+
3643+
The value being coerced is the
3644+
actual parameter and it is coerced to the type of the formal parameter. For
3645+
example, let `foo` be defined as `fn foo(x: U) { ... }` and call it as
3646+
`foo(e);`. Then `e` is coerced to have type `U`;
3647+
3648+
* instantiations of struct or variant fields.
3649+
3650+
Assume we have a `struct
3651+
Foo { x: U }` and instantiate it as `Foo { x: e }`. Then `e` is coerced to
3652+
have type `U`.
3653+
3654+
* function results (either the final line of a block if it is not semicolon
3655+
terminated or any expression in a `return` statement).
3656+
3657+
In `fn foo() -> U { e }`, `e` is coerced to to have type `U`.
3658+
3659+
If the expression in one of these coercion sites is a coercion-propagating
3660+
expression, then the relevant sub-expressions in that expression are also
3661+
coercion sites. Propagation recurses from these new coercion sites.
3662+
Propagating expressions and their relevant sub-expressions are:
3663+
3664+
* array literals, where the array has type `[U; n]`. Each sub-expression in
3665+
the array literal is a coercion site for coercion to type `U`.
3666+
3667+
* array literals with repeating syntax, where the array has type `[U; n]`. The
3668+
repeated sub-expression is a coercion site for coercion to type `U`.
3669+
3670+
* tuples, where a tuple is a coercion site to type `(U_0, U_1, ..., U_n)`.
3671+
Each sub-expression is a coercion site to the respective type, e.g. the
3672+
zeroth sub-expression is a coercion site to type `U_0`.
3673+
3674+
* parenthesised sub-expressions (`(e)`). If the expression has type `U`, then
3675+
the sub-expression is a coercion site to `U`.
3676+
3677+
* blocks. If a block has type `U`, then the last expression in the block (if
3678+
it is not semicolon-terminated) is a coercion site to `U`. This includes
3679+
blocks which are part of control flow statements, such as `if`/`else`, if
3680+
the block has a known type.
3681+
3682+
### Coercion types
3683+
3684+
Coercion is allowed between the following types:
3685+
3686+
* `T` to `U` if `T` is a subtype of `U` (*reflexive case*).
3687+
3688+
* `T_1` to `T_3` where `T_1` coerces to `T_2` and `T_2` coerces to `T_3`
3689+
(*transitive case*).
3690+
3691+
Note that this is not fully supported yet
3692+
3693+
* `&mut T` to `&T`.
3694+
3695+
* `*mut T` to `*const T`.
3696+
3697+
* `&T` to `*const T`.
3698+
3699+
* `&mut T` to `*mut T`.
3700+
3701+
* `&T` to `&U` if `T` implements `Deref<Target = U>`. For example:
3702+
3703+
```rust
3704+
use std::ops::Deref;
3705+
3706+
struct CharContainer {
3707+
value: char
3708+
}
3709+
3710+
impl Deref for CharContainer {
3711+
type Target = char;
3712+
3713+
fn deref<'a>(&'a self) -> &'a char {
3714+
&self.value
3715+
}
3716+
}
3717+
3718+
fn foo(arg: &char) {}
3719+
3720+
fn main() {
3721+
let x = &mut CharContainer { value: 'y' };
3722+
foo(x); //&mut CharContainer is coerced to &char.
3723+
}
3724+
```
3725+
* `&mut T` to `&mut U` if `T` implements `DerefMut<Target = U>`.
3726+
3727+
* TyCtor(`T`) to TyCtor(coerce_inner(`T`)), where TyCtor(`T`) is one of
3728+
- `&T`
3729+
- `&mut T`
3730+
- `*const T`
3731+
- `*mut T`
3732+
- `Box<T>`
3733+
3734+
and where
3735+
- coerce_inner(`[T, ..n]`) = `[T]`
3736+
- coerce_inner(`T`) = `U` where `T` is a concrete type which implements the
3737+
trait `U`.
3738+
3739+
In the future, coerce_inner will be recursively extended to tuples and
3740+
structs. In addition, coercions from sub-traits to super-traits will be
3741+
added. See [RFC401] for more details.
3742+
36023743
# Special traits
36033744

36043745
Several traits define special evaluation behavior.

branches/tmp/src/libcollections/linked_list.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,13 @@ impl<T> LinkedList<T> {
609609
length: len - at
610610
};
611611

612+
// Swap split_node.next with list_head (which is None), nulling out split_node.next,
613+
// as it is the new tail.
612614
mem::swap(&mut split_node.resolve().unwrap().next, &mut splitted_list.list_head);
615+
// Null out list_head.prev. Note this `unwrap` won't fail because if at == len
616+
// we already branched out at the top of the fn to return the empty list.
617+
splitted_list.list_head.as_mut().unwrap().prev = Rawlink::none();
618+
// Fix the tail ptr
613619
self.list_tail = split_node;
614620
self.length = at;
615621

@@ -1075,6 +1081,26 @@ mod tests {
10751081
}
10761082
}
10771083

1084+
#[test]
1085+
fn test_26021() {
1086+
use std::iter::ExactSizeIterator;
1087+
// There was a bug in split_off that failed to null out the RHS's head's prev ptr.
1088+
// This caused the RHS's dtor to walk up into the LHS at drop and delete all of
1089+
// its nodes.
1090+
//
1091+
// https://github.com/rust-lang/rust/issues/26021
1092+
let mut v1 = LinkedList::new();
1093+
v1.push_front(1u8);
1094+
v1.push_front(1u8);
1095+
v1.push_front(1u8);
1096+
v1.push_front(1u8);
1097+
let _ = v1.split_off(3); // Dropping this now should not cause laundry consumption
1098+
assert_eq!(v1.len(), 3);
1099+
1100+
assert_eq!(v1.iter().len(), 3);
1101+
assert_eq!(v1.iter().collect::<Vec<_>>().len(), 3);
1102+
}
1103+
10781104
#[cfg(test)]
10791105
fn fuzz_test(sz: i32) {
10801106
let mut m: LinkedList<_> = LinkedList::new();

branches/tmp/src/libcore/result.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@
223223
//! }
224224
//! ```
225225
//!
226-
//! `try!` is imported by the prelude, and is available everywhere.
226+
//! `try!` is imported by the prelude and is available everywhere, but it can only
227+
//! be used in functions that return `Result` because of the early return of
228+
//! `Err` that it provides.
227229
228230
#![stable(feature = "rust1", since = "1.0.0")]
229231

branches/tmp/src/liblibc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6308,8 +6308,8 @@ pub mod funcs {
63086308
lpOverlapped: LPOVERLAPPED) -> BOOL;
63096309
pub fn WriteFile(hFile: HANDLE,
63106310
lpBuffer: LPVOID,
6311-
nNumberOfBytesToRead: DWORD,
6312-
lpNumberOfBytesRead: LPDWORD,
6311+
nNumberOfBytesToWrite: DWORD,
6312+
lpNumberOfBytesWritten: LPDWORD,
63136313
lpOverlapped: LPOVERLAPPED) -> BOOL;
63146314
pub fn SetFilePointerEx(hFile: HANDLE,
63156315
liDistanceToMove: LARGE_INTEGER,

branches/tmp/src/librustc/metadata/csearch.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use metadata::common::*;
1414
use metadata::cstore;
1515
use metadata::decoder;
16-
use middle::def;
1716
use middle::lang_items;
1817
use middle::ty;
1918

@@ -114,12 +113,6 @@ pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
114113
decoder::maybe_get_item_ast(&*cdata, tcx, def.node, decode_inlined_item)
115114
}
116115

117-
pub fn get_enum_variant_defs(cstore: &cstore::CStore, enum_id: ast::DefId)
118-
-> Vec<(def::Def, ast::Name, ast::Visibility)> {
119-
let cdata = cstore.get_crate_data(enum_id.krate);
120-
decoder::get_enum_variant_defs(&*cstore.intr, &*cdata, enum_id.node)
121-
}
122-
123116
pub fn get_enum_variants<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
124117
-> Vec<Rc<ty::VariantInfo<'tcx>>> {
125118
let cstore = &tcx.sess.cstore;

branches/tmp/src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -268,30 +268,6 @@ fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
268268
doc_trait_ref(tp, tcx, cdata)
269269
}
270270

271-
struct EnumVariantIds<'a> {
272-
iter: reader::TaggedDocsIterator<'a>,
273-
cdata: Cmd<'a>,
274-
}
275-
276-
impl<'a> Iterator for EnumVariantIds<'a> {
277-
type Item = ast::DefId;
278-
279-
fn next(&mut self) -> Option<ast::DefId> {
280-
self.iter.next().map(|p| translated_def_id(self.cdata, p))
281-
}
282-
283-
fn size_hint(&self) -> (usize, Option<usize>) {
284-
self.iter.size_hint()
285-
}
286-
}
287-
288-
fn enum_variant_ids<'a>(item: rbml::Doc<'a>, cdata: Cmd<'a>) -> EnumVariantIds<'a> {
289-
EnumVariantIds {
290-
iter: reader::tagged_docs(item, tag_items_data_item_variant),
291-
cdata: cdata,
292-
}
293-
}
294-
295271
fn item_path(item_doc: rbml::Doc) -> Vec<ast_map::PathElem> {
296272
let path_doc = reader::get_doc(item_doc, tag_path);
297273
reader::docs(path_doc).filter_map(|(tag, elt_doc)| {
@@ -730,31 +706,14 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeI
730706
}
731707
}
732708

733-
pub fn get_enum_variant_defs(intr: &IdentInterner,
734-
cdata: Cmd,
735-
id: ast::NodeId)
736-
-> Vec<(def::Def, ast::Name, ast::Visibility)> {
737-
let data = cdata.data();
738-
let items = reader::get_doc(rbml::Doc::new(data), tag_items);
739-
let item = find_item(id, items);
740-
enum_variant_ids(item, cdata).map(|did| {
741-
let item = find_item(did.node, items);
742-
let name = item_name(intr, item);
743-
let visibility = item_visibility(item);
744-
match item_to_def_like(cdata, item, did) {
745-
DlDef(def @ def::DefVariant(..)) => (def, name, visibility),
746-
_ => unreachable!()
747-
}
748-
}).collect()
749-
}
750-
751709
pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
752710
tcx: &ty::ctxt<'tcx>) -> Vec<Rc<ty::VariantInfo<'tcx>>> {
753711
let data = cdata.data();
754712
let items = reader::get_doc(rbml::Doc::new(data), tag_items);
755713
let item = find_item(id, items);
756714
let mut disr_val = 0;
757-
enum_variant_ids(item, cdata).map(|did| {
715+
reader::tagged_docs(item, tag_items_data_item_variant).map(|p| {
716+
let did = translated_def_id(cdata, p);
758717
let item = find_item(did.node, items);
759718
let ctor_ty = item_type(ast::DefId { krate: cdata.cnum, node: id},
760719
item, tcx, cdata);

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,20 +448,6 @@ impl<T> VecPerParamSpace<T> {
448448
self.self_limit)
449449
}
450450

451-
pub fn map_move<U, F>(self, mut pred: F) -> VecPerParamSpace<U> where
452-
F: FnMut(T) -> U,
453-
{
454-
let SeparateVecsPerParamSpace {
455-
types: t,
456-
selfs: s,
457-
fns: f
458-
} = self.split();
459-
460-
VecPerParamSpace::new(t.into_iter().map(|p| pred(p)).collect(),
461-
s.into_iter().map(|p| pred(p)).collect(),
462-
f.into_iter().map(|p| pred(p)).collect())
463-
}
464-
465451
pub fn split(self) -> SeparateVecsPerParamSpace<T> {
466452
let VecPerParamSpace { type_limit, self_limit, content } = self;
467453

branches/tmp/src/librustc/middle/traits/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
329329
false
330330
}
331331
Ok(Some(s)) => {
332-
s.map_move_nested(|p| new_obligations.push(p));
332+
new_obligations.append(&mut s.nested_obligations());
333333
true
334334
}
335335
Err(selection_err) => {

0 commit comments

Comments
 (0)