Skip to content

Commit 626b6c4

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 178615 b: refs/heads/snap-stage3 c: c3841b9 h: refs/heads/master i: 178613: 34f91a1 178611: 235efe5 178607: 1ac9fc6 v: v3
1 parent bd3b26e commit 626b6c4

File tree

16 files changed

+45
-229
lines changed

16 files changed

+45
-229
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: 3d072a193bfcb76206aab576049e696d6d8db25d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: fe4340ab18abc53af40e40a6696dfbe2375238b0
4+
refs/heads/snap-stage3: c3841b9c9f35f4e7fed9894558cbe1f068a3e01a
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcore/iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,7 @@ impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator {
18241824
}
18251825

18261826
/// An iterator with a `peek()` that returns an optional reference to the next element.
1827+
#[derive(Clone)]
18271828
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
18281829
#[stable(feature = "rust1", since = "1.0.0")]
18291830
pub struct Peekable<T, I> where I: Iterator<Item=T> {

branches/snap-stage3/src/libcore/ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ impl fmt::Debug for RangeFull {
977977
}
978978

979979
/// A (half-open) range which is bounded at both ends.
980-
#[derive(Copy, Clone, PartialEq, Eq)]
980+
#[derive(Clone, PartialEq, Eq)]
981981
#[lang="range"]
982982
#[stable(feature = "rust1", since = "1.0.0")]
983983
pub struct Range<Idx> {
@@ -995,7 +995,7 @@ impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
995995
}
996996

997997
/// A range which is only bounded below.
998-
#[derive(Copy, Clone, PartialEq, Eq)]
998+
#[derive(Clone, PartialEq, Eq)]
999999
#[lang="range_from"]
10001000
#[stable(feature = "rust1", since = "1.0.0")]
10011001
pub struct RangeFrom<Idx> {

branches/snap-stage3/src/librustc/middle/traits/coherence.rs

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::{Obligation, ObligationCause};
1515
use super::project;
1616
use super::util;
1717

18-
use middle::subst::{Subst, TypeSpace};
18+
use middle::subst::{Subst};
1919
use middle::ty::{self, Ty};
2020
use middle::infer::InferCtxt;
2121
use std::collections::HashSet;
@@ -89,28 +89,16 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>,
8989
return Ok(());
9090
}
9191

92-
// First, create an ordered iterator over all the type parameters to the trait, with the self
93-
// type appearing first.
94-
let input_tys = Some(trait_ref.self_ty());
95-
let input_tys = input_tys.iter().chain(trait_ref.substs.types.get_slice(TypeSpace).iter());
96-
let mut input_tys = input_tys;
97-
98-
// Find the first input type that either references a type parameter OR
99-
// some local type.
100-
match input_tys.find(|&&input_ty| references_local_or_type_parameter(tcx, input_ty)) {
101-
Some(&input_ty) => {
102-
// Within this first type, check that all type parameters are covered by a local
103-
// type constructor. Note that if there is no local type constructor, then any
104-
// type parameter at all will be an error.
105-
let covered_params = type_parameters_covered_by_ty(tcx, input_ty);
106-
let all_params = type_parameters_reachable_from_ty(input_ty);
107-
for &param in all_params.difference(&covered_params) {
108-
return Err(OrphanCheckErr::UncoveredTy(param));
109-
}
110-
}
111-
None => {
112-
return Err(OrphanCheckErr::NoLocalInputType);
113-
}
92+
// Otherwise, check that (1) all type parameters are covered.
93+
let covered_params = type_parameters_covered_by_ty(tcx, trait_ref.self_ty());
94+
let all_params = type_parameters_reachable_from_ty(trait_ref.self_ty());
95+
for &param in all_params.difference(&covered_params) {
96+
return Err(OrphanCheckErr::UncoveredTy(param));
97+
}
98+
99+
// And (2) some local type appears.
100+
if !trait_ref.self_ty().walk().any(|t| ty_is_local_constructor(tcx, t)) {
101+
return Err(OrphanCheckErr::NoLocalInputType);
114102
}
115103

116104
return Ok(());
@@ -174,17 +162,13 @@ fn type_parameters_covered_by_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
174162

175163
/// All type parameters reachable from `ty`
176164
fn type_parameters_reachable_from_ty<'tcx>(ty: Ty<'tcx>) -> HashSet<Ty<'tcx>> {
177-
ty.walk().filter(|&t| is_type_parameter(t)).collect()
178-
}
179-
180-
fn references_local_or_type_parameter<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
181-
ty.walk().any(|ty| is_type_parameter(ty) || ty_is_local_constructor(tcx, ty))
182-
}
183-
184-
fn is_type_parameter<'tcx>(ty: Ty<'tcx>) -> bool {
185-
match ty.sty {
186-
// FIXME(#20590) straighten story about projection types
187-
ty::ty_projection(..) | ty::ty_param(..) => true,
188-
_ => false,
189-
}
165+
ty.walk()
166+
.filter(|&t| {
167+
match t.sty {
168+
// FIXME(#20590) straighten story about projection types
169+
ty::ty_projection(..) | ty::ty_param(..) => true,
170+
_ => false,
171+
}
172+
})
173+
.collect()
190174
}

branches/snap-stage3/src/librustc_typeck/coherence/orphan.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
7777
Ok(()) => { }
7878
Err(traits::OrphanCheckErr::NoLocalInputType) => {
7979
if !ty::has_attr(self.tcx, trait_def_id, "old_orphan_check") {
80+
let self_ty = ty::lookup_item_type(self.tcx, def_id).ty;
8081
span_err!(
8182
self.tcx.sess, item.span, E0117,
82-
"the impl does not reference any \
83+
"the type `{}` does not reference any \
8384
types defined in this crate; \
8485
only traits defined in the current crate can be \
85-
implemented for arbitrary types");
86+
implemented for arbitrary types",
87+
self_ty.user_string(self.tcx));
8688
}
8789
}
8890
Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => {

branches/snap-stage3/src/libstd/collections/hash/table.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ use clone::Clone;
1616
use cmp;
1717
use hash::{Hash, Hasher};
1818
use iter::{Iterator, IteratorExt, ExactSizeIterator, count};
19-
use marker::{Copy, Send, Sync, Sized, self};
19+
use marker::{Copy, Sized, self};
2020
use mem::{min_align_of, size_of};
2121
use mem;
2222
use num::{Int, UnsignedInt};
2323
use ops::{Deref, DerefMut, Drop};
2424
use option::Option;
2525
use option::Option::{Some, None};
26-
use ptr::{self, PtrExt, copy_nonoverlapping_memory, zero_memory};
26+
use ptr::{Unique, PtrExt, copy_nonoverlapping_memory, zero_memory};
27+
use ptr;
2728
use rt::heap::{allocate, deallocate};
2829
use collections::hash_state::HashState;
2930

@@ -69,15 +70,12 @@ const EMPTY_BUCKET: u64 = 0u64;
6970
pub struct RawTable<K, V> {
7071
capacity: uint,
7172
size: uint,
72-
hashes: *mut u64,
73+
hashes: Unique<u64>,
7374
// Because K/V do not appear directly in any of the types in the struct,
7475
// inform rustc that in fact instances of K and V are reachable from here.
7576
marker: marker::CovariantType<(K,V)>,
7677
}
7778

78-
unsafe impl<K: Send, V: Send> Send for RawTable<K, V> {}
79-
unsafe impl<K: Sync, V: Sync> Sync for RawTable<K, V> {}
80-
8179
struct RawBucket<K, V> {
8280
hash: *mut u64,
8381
key: *mut K,
@@ -567,7 +565,7 @@ impl<K, V> RawTable<K, V> {
567565
return RawTable {
568566
size: 0,
569567
capacity: 0,
570-
hashes: ptr::null_mut(),
568+
hashes: Unique::null(),
571569
marker: marker::CovariantType,
572570
};
573571
}
@@ -606,7 +604,7 @@ impl<K, V> RawTable<K, V> {
606604
RawTable {
607605
capacity: capacity,
608606
size: 0,
609-
hashes: hashes,
607+
hashes: Unique(hashes),
610608
marker: marker::CovariantType,
611609
}
612610
}
@@ -615,14 +613,14 @@ impl<K, V> RawTable<K, V> {
615613
let hashes_size = self.capacity * size_of::<u64>();
616614
let keys_size = self.capacity * size_of::<K>();
617615

618-
let buffer = self.hashes as *mut u8;
616+
let buffer = self.hashes.0 as *mut u8;
619617
let (keys_offset, vals_offset) = calculate_offsets(hashes_size,
620618
keys_size, min_align_of::<K>(),
621619
min_align_of::<V>());
622620

623621
unsafe {
624622
RawBucket {
625-
hash: self.hashes,
623+
hash: self.hashes.0,
626624
key: buffer.offset(keys_offset as int) as *mut K,
627625
val: buffer.offset(vals_offset as int) as *mut V
628626
}
@@ -634,7 +632,7 @@ impl<K, V> RawTable<K, V> {
634632
pub fn new(capacity: uint) -> RawTable<K, V> {
635633
unsafe {
636634
let ret = RawTable::new_uninitialized(capacity);
637-
zero_memory(ret.hashes, capacity);
635+
zero_memory(ret.hashes.0, capacity);
638636
ret
639637
}
640638
}
@@ -654,7 +652,7 @@ impl<K, V> RawTable<K, V> {
654652
RawBuckets {
655653
raw: self.first_bucket_raw(),
656654
hashes_end: unsafe {
657-
self.hashes.offset(self.capacity as int)
655+
self.hashes.0.offset(self.capacity as int)
658656
},
659657
marker: marker::ContravariantLifetime,
660658
}
@@ -966,7 +964,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
966964
#[unsafe_destructor]
967965
impl<K, V> Drop for RawTable<K, V> {
968966
fn drop(&mut self) {
969-
if self.hashes.is_null() {
967+
if self.hashes.0.is_null() {
970968
return;
971969
}
972970
// This is done in reverse because we've likely partially taken
@@ -986,7 +984,7 @@ impl<K, V> Drop for RawTable<K, V> {
986984
vals_size, min_align_of::<V>());
987985

988986
unsafe {
989-
deallocate(self.hashes as *mut u8, size, align);
987+
deallocate(self.hashes.0 as *mut u8, size, align);
990988
// Remember how everything was allocated out of one buffer
991989
// during initialization? We only need one call to free here.
992990
}

branches/snap-stage3/src/libstd/thread.rs

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@
123123
//! * The `Thread::park()` function blocks the current thread unless or until
124124
//! the token is available for its thread handle, at which point It atomically
125125
//! consumes the token. It may also return *spuriously*, without consuming the
126-
//! token. `Thread::park_timeout()` does the same, but allows specifying a
127-
//! maximum time to block the thread for.
126+
//! token.
128127
//!
129128
//! * The `unpark()` method on a `Thread` atomically makes the token available
130129
//! if it wasn't already.
@@ -161,7 +160,6 @@ use string::String;
161160
use rt::{self, unwind};
162161
use old_io::{Writer, stdio};
163162
use thunk::Thunk;
164-
use time::Duration;
165163

166164
use sys::thread as imp;
167165
use sys_common::{stack, thread_info};
@@ -416,27 +414,6 @@ impl Thread {
416414
*guard = false;
417415
}
418416

419-
/// Block unless or until the current thread's token is made available or
420-
/// the specified duration has been reached (may wake spuriously).
421-
///
422-
/// The semantics of this function are equivalent to `park()` except that the
423-
/// thread will be blocked for roughly no longer than dur. This method
424-
/// should not be used for precise timing due to anomalies such as
425-
/// preemption or platform differences that may not cause the maximum
426-
/// amount of time waited to be precisely dur
427-
///
428-
/// See the module doc for more detail.
429-
#[unstable(feature = "std_misc", reason = "recently introduced")]
430-
pub fn park_timeout(dur: Duration) {
431-
let thread = Thread::current();
432-
let mut guard = thread.inner.lock.lock().unwrap();
433-
if !*guard {
434-
let (g, _) = thread.inner.cvar.wait_timeout(guard, dur).unwrap();
435-
guard = g;
436-
}
437-
*guard = false;
438-
}
439-
440417
/// Atomically makes the handle's token available if it is not already.
441418
///
442419
/// See the module doc for more detail.
@@ -542,7 +519,6 @@ mod test {
542519
use std::old_io::{ChanReader, ChanWriter};
543520
use super::{Thread, Builder};
544521
use thunk::Thunk;
545-
use time::Duration;
546522

547523
// !!! These tests are dangerous. If something is buggy, they will hang, !!!
548524
// !!! instead of exiting cleanly. This might wedge the buildbots. !!!
@@ -757,37 +733,6 @@ mod test {
757733
assert_eq!(output, "Hello, world!".to_string());
758734
}
759735

760-
#[test]
761-
fn test_park_timeout_unpark_before() {
762-
for _ in 0..10 {
763-
Thread::current().unpark();
764-
Thread::park_timeout(Duration::seconds(10_000_000));
765-
}
766-
}
767-
768-
#[test]
769-
fn test_park_timeout_unpark_not_called() {
770-
for _ in 0..10 {
771-
Thread::park_timeout(Duration::milliseconds(10));
772-
}
773-
}
774-
775-
#[test]
776-
fn test_park_timeout_unpark_called_other_thread() {
777-
use std::old_io;
778-
779-
for _ in 0..10 {
780-
let th = Thread::current();
781-
782-
let _guard = Thread::scoped(move || {
783-
old_io::timer::sleep(Duration::milliseconds(50));
784-
th.unpark();
785-
});
786-
787-
Thread::park_timeout(Duration::seconds(10_000_000));
788-
}
789-
}
790-
791736
// NOTE: the corresponding test for stderr is in run-pass/task-stderr, due
792737
// to the test harness apparently interfering with stderr configuration.
793738
}

branches/snap-stage3/src/test/compile-fail/coherence-all-remote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ extern crate "coherence-lib" as lib;
1414
use lib::Remote1;
1515

1616
impl<T> Remote1<T> for isize { }
17-
//~^ ERROR E0210
17+
//~^ ERROR E0117
1818

1919
fn main() { }

branches/snap-stage3/src/test/run-pass/coherence-bigint-int.rs renamed to branches/snap-stage3/src/test/compile-fail/coherence-bigint-int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ use lib::Remote1;
1515

1616
pub struct BigInt;
1717

18-
impl Remote1<BigInt> for isize { }
18+
impl Remote1<BigInt> for isize { } //~ ERROR E0117
1919

2020
fn main() { }

branches/snap-stage3/src/test/run-pass/coherence-bigint-vecint.rs renamed to branches/snap-stage3/src/test/compile-fail/coherence-bigint-vecint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ use lib::Remote1;
1515

1616
pub struct BigInt;
1717

18-
impl Remote1<BigInt> for Vec<isize> { }
18+
impl Remote1<BigInt> for Vec<isize> { } //~ ERROR E0117
1919

2020
fn main() { }

branches/snap-stage3/src/test/compile-fail/coherence-cow-no-cover.rs

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

branches/snap-stage3/src/test/compile-fail/coherence-orphan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct TheType;
2121

2222
impl TheTrait<usize> for isize { } //~ ERROR E0117
2323

24-
impl TheTrait<TheType> for isize { }
24+
impl TheTrait<TheType> for isize { } //~ ERROR E0117
2525

2626
impl TheTrait<isize> for TheType { }
2727

0 commit comments

Comments
 (0)