Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oibit2 #19566

Merged
merged 2 commits into from
Dec 9, 2014
Merged

Oibit2 #19566

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/compiletest/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub enum Mode {
Codegen
}

impl Copy for Mode {}

impl FromStr for Mode {
fn from_str(s: &str) -> Option<Mode> {
match s {
Expand Down
3 changes: 3 additions & 0 deletions src/doc/guide-unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,9 @@ extern {
fn abort() -> !;
}

#[lang = "owned_box"]
pub struct Box<T>(*mut T);

#[lang="exchange_malloc"]
unsafe fn allocate(size: uint, _align: uint) -> *mut u8 {
let p = libc::malloc(size as libc::size_t) as *mut u8;
Expand Down
4 changes: 4 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,7 @@ Implementations are defined with the keyword `impl`.

```
# struct Point {x: f64, y: f64};
# impl Copy for Point {}
# type Surface = int;
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
Expand All @@ -1669,6 +1670,8 @@ struct Circle {
center: Point,
}

impl Copy for Circle {}

impl Shape for Circle {
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
fn bounding_box(&self) -> BoundingBox {
Expand Down Expand Up @@ -1791,6 +1794,7 @@ default visibility with the `priv` keyword. When an item is declared as `pub`,
it can be thought of as being accessible to the outside world. For example:

```
# #![allow(missing_copy_implementations)]
# fn main() {}
// Declare a private struct
struct Foo;
Expand Down
2 changes: 1 addition & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl<T> TypedArena<T> {
}

let ptr: &mut T = unsafe {
let ptr: &mut T = mem::transmute(self.ptr);
let ptr: &mut T = mem::transmute(self.ptr.clone());
ptr::write(ptr, object);
self.ptr.set(self.ptr.get().offset(1));
ptr
Expand Down
2 changes: 2 additions & 0 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
//! position: uint
//! }
//!
//! impl Copy for State {}
//!
//! // The priority queue depends on `Ord`.
//! // Explicitly implement the trait so the queue becomes a min-heap
//! // instead of a max-heap.
Expand Down
9 changes: 8 additions & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ pub struct DList<T> {
}

type Link<T> = Option<Box<Node<T>>>;
struct Rawlink<T> { p: *mut T }

struct Rawlink<T> {
p: *mut T,
}

impl<T> Copy for Rawlink<T> {}

struct Node<T> {
next: Link<T>,
Expand All @@ -59,6 +64,8 @@ impl<'a, T> Clone for Items<'a, T> {
fn clone(&self) -> Items<'a, T> { *self }
}

impl<'a,T> Copy for Items<'a,T> {}

/// An iterator over mutable references to the items of a `DList`.
pub struct MutItems<'a, T:'a> {
list: &'a mut DList<T>,
Expand Down
7 changes: 7 additions & 0 deletions src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub struct EnumSet<E> {
bits: uint
}

impl<E> Copy for EnumSet<E> {}

impl<E:CLike+fmt::Show> fmt::Show for EnumSet<E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "{{"));
Expand Down Expand Up @@ -269,6 +271,8 @@ mod test {
A, B, C
}

impl Copy for Foo {}

impl CLike for Foo {
fn to_uint(&self) -> uint {
*self as uint
Expand Down Expand Up @@ -477,6 +481,9 @@ mod test {
V50, V51, V52, V53, V54, V55, V56, V57, V58, V59,
V60, V61, V62, V63, V64, V65, V66, V67, V68, V69,
}

impl Copy for Bar {}

impl CLike for Bar {
fn to_uint(&self) -> uint {
*self as uint
Expand Down
3 changes: 3 additions & 0 deletions src/libcollections/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub struct SipState {
ntail: uint, // how many bytes in tail are valid
}

impl Copy for SipState {}

// sadly, these macro definitions can't appear later,
// because they're needed in the following defs;
// this design could be improved.
Expand Down Expand Up @@ -211,6 +213,7 @@ impl Default for SipState {

/// `SipHasher` computes the SipHash algorithm from a stream of bytes.
#[deriving(Clone)]
#[allow(missing_copy_implementations)]
pub struct SipHasher {
k0: u64,
k1: u64,
Expand Down
16 changes: 13 additions & 3 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ use self::Direction::*;
use alloc::boxed::Box;
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
use core::cmp;
use core::kinds::Sized;
use core::kinds::{Copy, Sized};
use core::mem::size_of;
use core::mem;
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
Expand Down Expand Up @@ -177,12 +177,16 @@ impl ElementSwaps {

enum Direction { Pos, Neg }

impl Copy for Direction {}

/// An `Index` and `Direction` together.
struct SizeDirection {
size: uint,
dir: Direction,
}

impl Copy for SizeDirection {}

impl Iterator<(uint, uint)> for ElementSwaps {
#[inline]
fn next(&mut self) -> Option<(uint, uint)> {
Expand Down Expand Up @@ -1482,11 +1486,17 @@ mod tests {
fn clone(&self) -> S {
self.f.set(self.f.get() + 1);
if self.f.get() == 10 { panic!() }
S { f: self.f, boxes: self.boxes.clone() }
S {
f: self.f.clone(),
boxes: self.boxes.clone(),
}
}
}

let s = S { f: Cell::new(0), boxes: (box 0, Rc::new(0)) };
let s = S {
f: Cell::new(0),
boxes: (box 0, Rc::new(0)),
};
let _ = Vec::from_elem(100, s);
}

Expand Down
34 changes: 21 additions & 13 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,32 @@ impl<'a> Iterator<char> for Decompositions<'a> {
_ => self.sorted = false
}

let decomposer = match self.kind {
Canonical => unicode::char::decompose_canonical,
Compatible => unicode::char::decompose_compatible
};

if !self.sorted {
for ch in self.iter {
let buffer = &mut self.buffer;
let sorted = &mut self.sorted;
decomposer(ch, |d| {
let class = unicode::char::canonical_combining_class(d);
if class == 0 && !*sorted {
canonical_sort(buffer.as_mut_slice());
*sorted = true;
{
let callback = |d| {
let class =
unicode::char::canonical_combining_class(d);
if class == 0 && !*sorted {
canonical_sort(buffer.as_mut_slice());
*sorted = true;
}
buffer.push((d, class));
};
match self.kind {
Canonical => {
unicode::char::decompose_canonical(ch, callback)
}
Compatible => {
unicode::char::decompose_compatible(ch, callback)
}
}
buffer.push((d, class));
});
if *sorted { break }
}
if *sorted {
break
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/libcore/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use self::Ordering::*;
use intrinsics;
use std::kinds::marker;
use cell::UnsafeCell;
use kinds::Copy;

/// A boolean type which can be safely shared between threads.
#[stable]
Expand Down Expand Up @@ -81,6 +82,8 @@ pub enum Ordering {
SeqCst,
}

impl Copy for Ordering {}

/// An `AtomicBool` initialized to `false`.
#[unstable = "may be renamed, pending conventions for static initalizers"]
pub const INIT_ATOMIC_BOOL: AtomicBool =
Expand Down
1 change: 1 addition & 0 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,4 @@ impl Iterator<char> for DefaultEscapedChars {
}
}
}

7 changes: 4 additions & 3 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@

pub use self::Ordering::*;

use kinds::Sized;
use option::Option;
use option::Option::{Some, None};
use kinds::{Copy, Sized};
use option::{Option, Some, None};

/// Trait for values that can be compared for equality and inequality.
///
Expand Down Expand Up @@ -106,6 +105,8 @@ pub enum Ordering {
Greater = 1i,
}

impl Copy for Ordering {}

impl Ordering {
/// Reverse the `Ordering`, so that `Less` becomes `Greater` and
/// vice versa.
Expand Down
4 changes: 4 additions & 0 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub type Result = result::Result<(), Error>;
#[experimental = "core and I/O reconciliation may alter this definition"]
pub struct Error;

impl Copy for Error {}

/// A collection of methods that are required to format a message into a stream.
///
/// This trait is the type which this modules requires when formatting
Expand Down Expand Up @@ -135,6 +137,8 @@ impl<'a> Argument<'a> {
}
}

impl<'a> Copy for Argument<'a> {}

impl<'a> Arguments<'a> {
/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use fmt;
use iter::DoubleEndedIteratorExt;
use kinds::Copy;
use num::{Int, cast};
use slice::SlicePrelude;

Expand Down Expand Up @@ -114,6 +115,8 @@ pub struct Radix {
base: u8,
}

impl Copy for Radix {}

impl Radix {
fn new(base: u8) -> Radix {
assert!(2 <= base && base <= 36, "the base must be in the range of 2..36: {}", base);
Expand All @@ -136,6 +139,8 @@ impl GenericRadix for Radix {
#[unstable = "may be renamed or move to a different module"]
pub struct RadixFmt<T, R>(T, R);

impl<T,R> Copy for RadixFmt<T,R> where T: Copy, R: Copy {}

/// Constructs a radix formatter in the range of `2..36`.
///
/// # Example
Expand Down
13 changes: 13 additions & 0 deletions src/libcore/fmt/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ pub use self::Alignment::*;
pub use self::Count::*;
pub use self::Position::*;
pub use self::Flag::*;
use kinds::Copy;

#[doc(hidden)]
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
}

impl<'a> Copy for Argument<'a> {}

#[doc(hidden)]
pub struct FormatSpec {
pub fill: char,
Expand All @@ -36,6 +39,8 @@ pub struct FormatSpec {
pub width: Count,
}

impl Copy for FormatSpec {}

/// Possible alignments that can be requested as part of a formatting directive.
#[deriving(PartialEq)]
pub enum Alignment {
Expand All @@ -49,16 +54,22 @@ pub enum Alignment {
AlignUnknown,
}

impl Copy for Alignment {}

#[doc(hidden)]
pub enum Count {
CountIs(uint), CountIsParam(uint), CountIsNextParam, CountImplied,
}

impl Copy for Count {}

#[doc(hidden)]
pub enum Position {
ArgumentNext, ArgumentIs(uint)
}

impl Copy for Position {}

/// Flags which can be passed to formatting via a directive.
///
/// These flags are discovered through the `flags` field of the `Formatter`
Expand All @@ -78,3 +89,5 @@ pub enum Flag {
/// being aware of the sign to be printed.
FlagSignAwareZeroPad,
}

impl Copy for Flag {}
6 changes: 6 additions & 0 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#![experimental]
#![allow(missing_docs)]

use kinds::Copy;

pub type GlueFn = extern "Rust" fn(*const i8);

#[lang="ty_desc"]
Expand All @@ -59,6 +61,8 @@ pub struct TyDesc {
pub name: &'static str,
}

impl Copy for TyDesc {}

extern "rust-intrinsic" {

// NB: These intrinsics take unsafe pointers because they mutate aliased
Expand Down Expand Up @@ -539,6 +543,8 @@ pub struct TypeId {
t: u64,
}

impl Copy for TypeId {}

impl TypeId {
/// Returns the `TypeId` of the type this generic function has been instantiated with
pub fn of<T: 'static>() -> TypeId {
Expand Down
Loading