auto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakis
This commit is contained in:
commit
c56e59c722
278 changed files with 2250 additions and 512 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>,
|
||||
|
@ -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>,
|
||||
|
|
|
@ -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, "{{"));
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
@ -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,
|
||||
|
|
|
@ -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};
|
||||
|
@ -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)> {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
@ -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 =
|
||||
|
|
|
@ -519,3 +519,4 @@ impl Iterator<char> for DefaultEscapedChars {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
@ -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.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
use fmt;
|
||||
use iter::DoubleEndedIteratorExt;
|
||||
use kinds::Copy;
|
||||
use num::{Int, cast};
|
||||
use slice::SlicePrelude;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
|
|
@ -20,6 +20,7 @@ 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> {
|
||||
|
@ -27,6 +28,8 @@ pub struct Argument<'a> {
|
|||
pub format: FormatSpec,
|
||||
}
|
||||
|
||||
impl<'a> Copy for Argument<'a> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct FormatSpec {
|
||||
pub fill: char,
|
||||
|
@ -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 {
|
||||
|
@ -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`
|
||||
|
@ -78,3 +89,5 @@ pub enum Flag {
|
|||
/// being aware of the sign to be printed.
|
||||
FlagSignAwareZeroPad,
|
||||
}
|
||||
|
||||
impl Copy for Flag {}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#![experimental]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use kinds::Copy;
|
||||
|
||||
pub type GlueFn = extern "Rust" fn(*const i8);
|
||||
|
||||
#[lang="ty_desc"]
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
|
|
@ -59,6 +59,7 @@ pub use self::MinMaxResult::*;
|
|||
use clone::Clone;
|
||||
use cmp;
|
||||
use cmp::Ord;
|
||||
use kinds::Copy;
|
||||
use mem;
|
||||
use num::{ToPrimitive, Int};
|
||||
use ops::{Add, Deref};
|
||||
|
@ -1166,7 +1167,8 @@ pub struct Cycle<T> {
|
|||
iter: T,
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl<T:Copy> Copy for Cycle<T> {}
|
||||
|
||||
impl<A, T: Clone + Iterator<A>> Iterator<A> for Cycle<T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<A> {
|
||||
|
@ -1576,7 +1578,8 @@ pub struct Peekable<A, T> {
|
|||
peeked: Option<A>,
|
||||
}
|
||||
|
||||
#[unstable = "trait is unstable"]
|
||||
impl<T:Copy,A:Copy> Copy for Peekable<A,T> {}
|
||||
|
||||
impl<A, T: Iterator<A>> Iterator<A> for Peekable<A, T> {
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<A> {
|
||||
|
@ -2115,6 +2118,8 @@ pub struct Counter<A> {
|
|||
step: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> Copy for Counter<A> {}
|
||||
|
||||
/// Creates a new counter with the specified start/step
|
||||
#[inline]
|
||||
#[unstable = "may be renamed"]
|
||||
|
@ -2146,6 +2151,8 @@ pub struct Range<A> {
|
|||
one: A,
|
||||
}
|
||||
|
||||
impl<A:Copy> Copy for Range<A> {}
|
||||
|
||||
/// Returns an iterator over the given range [start, stop) (that is, starting
|
||||
/// at start (inclusive), and ending at stop (exclusive)).
|
||||
///
|
||||
|
|
|
@ -91,6 +91,8 @@ pub trait Sync for Sized? {
|
|||
/// implemented using unsafe code. In that case, you may want to embed
|
||||
/// some of the marker types below into your type.
|
||||
pub mod marker {
|
||||
use super::Copy;
|
||||
|
||||
/// A marker type whose type parameter `T` is considered to be
|
||||
/// covariant with respect to the type itself. This is (typically)
|
||||
/// used to indicate that an instance of the type `T` is being stored
|
||||
|
@ -132,6 +134,8 @@ pub mod marker {
|
|||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct CovariantType<T>;
|
||||
|
||||
impl<T> Copy for CovariantType<T> {}
|
||||
|
||||
/// A marker type whose type parameter `T` is considered to be
|
||||
/// contravariant with respect to the type itself. This is (typically)
|
||||
/// used to indicate that an instance of the type `T` will be consumed
|
||||
|
@ -175,6 +179,8 @@ pub mod marker {
|
|||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct ContravariantType<T>;
|
||||
|
||||
impl<T> Copy for ContravariantType<T> {}
|
||||
|
||||
/// A marker type whose type parameter `T` is considered to be
|
||||
/// invariant with respect to the type itself. This is (typically)
|
||||
/// used to indicate that instances of the type `T` may be read or
|
||||
|
@ -200,6 +206,8 @@ pub mod marker {
|
|||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct InvariantType<T>;
|
||||
|
||||
impl<T> Copy for InvariantType<T> {}
|
||||
|
||||
/// As `CovariantType`, but for lifetime parameters. Using
|
||||
/// `CovariantLifetime<'a>` indicates that it is ok to substitute
|
||||
/// a *longer* lifetime for `'a` than the one you originally
|
||||
|
@ -220,6 +228,8 @@ pub mod marker {
|
|||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct CovariantLifetime<'a>;
|
||||
|
||||
impl<'a> Copy for CovariantLifetime<'a> {}
|
||||
|
||||
/// As `ContravariantType`, but for lifetime parameters. Using
|
||||
/// `ContravariantLifetime<'a>` indicates that it is ok to
|
||||
/// substitute a *shorter* lifetime for `'a` than the one you
|
||||
|
@ -236,6 +246,8 @@ pub mod marker {
|
|||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct ContravariantLifetime<'a>;
|
||||
|
||||
impl<'a> Copy for ContravariantLifetime<'a> {}
|
||||
|
||||
/// As `InvariantType`, but for lifetime parameters. Using
|
||||
/// `InvariantLifetime<'a>` indicates that it is not ok to
|
||||
/// substitute any other lifetime for `'a` besides its original
|
||||
|
@ -253,6 +265,7 @@ pub mod marker {
|
|||
/// their instances remain thread-local.
|
||||
#[lang="no_send_bound"]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct NoSend;
|
||||
|
||||
/// A type which is considered "not POD", meaning that it is not
|
||||
|
@ -260,6 +273,7 @@ pub mod marker {
|
|||
/// ensure that they are never copied, even if they lack a destructor.
|
||||
#[lang="no_copy_bound"]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct NoCopy;
|
||||
|
||||
/// A type which is considered "not sync", meaning that
|
||||
|
@ -267,11 +281,14 @@ pub mod marker {
|
|||
/// shared between tasks.
|
||||
#[lang="no_sync_bound"]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct NoSync;
|
||||
|
||||
/// A type which is considered managed by the GC. This is typically
|
||||
/// embedded in other types.
|
||||
#[lang="managed_bound"]
|
||||
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct Managed;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
html_playground_url = "http://play.rust-lang.org/")]
|
||||
|
||||
#![no_std]
|
||||
#![allow(unknown_features)]
|
||||
#![allow(unknown_features, raw_pointer_deriving)]
|
||||
#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
|
||||
#![feature(simd, unsafe_destructor, slicing_syntax)]
|
||||
#![feature(default_type_params)]
|
||||
|
|
|
@ -1240,6 +1240,8 @@ pub enum FPCategory {
|
|||
FPNormal,
|
||||
}
|
||||
|
||||
impl Copy for FPCategory {}
|
||||
|
||||
/// A built-in floating point number.
|
||||
// FIXME(#5527): In a future version of Rust, many of these functions will
|
||||
// become constants.
|
||||
|
|
|
@ -90,6 +90,8 @@ pub trait Drop {
|
|||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Add<Foo, Foo> for Foo {
|
||||
/// fn add(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Adding!");
|
||||
|
@ -128,6 +130,8 @@ add_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
|
|||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Sub<Foo, Foo> for Foo {
|
||||
/// fn sub(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Subtracting!");
|
||||
|
@ -166,6 +170,8 @@ sub_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
|
|||
/// ```rust
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Mul<Foo, Foo> for Foo {
|
||||
/// fn mul(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Multiplying!");
|
||||
|
@ -204,6 +210,8 @@ mul_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Div<Foo, Foo> for Foo {
|
||||
/// fn div(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Dividing!");
|
||||
|
@ -242,6 +250,8 @@ div_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Rem<Foo, Foo> for Foo {
|
||||
/// fn rem(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Remainder-ing!");
|
||||
|
@ -294,6 +304,8 @@ rem_float_impl!(f64, fmod)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Neg<Foo> for Foo {
|
||||
/// fn neg(&self) -> Foo {
|
||||
/// println!("Negating!");
|
||||
|
@ -348,6 +360,8 @@ neg_uint_impl!(u64, i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Not<Foo> for Foo {
|
||||
/// fn not(&self) -> Foo {
|
||||
/// println!("Not-ing!");
|
||||
|
@ -387,6 +401,8 @@ not_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitAnd<Foo, Foo> for Foo {
|
||||
/// fn bitand(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise And-ing!");
|
||||
|
@ -425,6 +441,8 @@ bitand_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitOr<Foo, Foo> for Foo {
|
||||
/// fn bitor(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise Or-ing!");
|
||||
|
@ -463,6 +481,8 @@ bitor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl BitXor<Foo, Foo> for Foo {
|
||||
/// fn bitxor(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Bitwise Xor-ing!");
|
||||
|
@ -501,6 +521,8 @@ bitxor_impl!(bool uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Shl<Foo, Foo> for Foo {
|
||||
/// fn shl(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Shifting left!");
|
||||
|
@ -541,6 +563,8 @@ shl_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Shr<Foo, Foo> for Foo {
|
||||
/// fn shr(&self, _rhs: &Foo) -> Foo {
|
||||
/// println!("Shifting right!");
|
||||
|
@ -580,6 +604,8 @@ shr_impl!(uint u8 u16 u32 u64 int i8 i16 i32 i64)
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Index<Foo, Foo> for Foo {
|
||||
/// fn index<'a>(&'a self, _index: &Foo) -> &'a Foo {
|
||||
/// println!("Indexing!");
|
||||
|
@ -608,6 +634,8 @@ pub trait Index<Sized? Index, Sized? Result> for Sized? {
|
|||
/// ```
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl IndexMut<Foo, Foo> for Foo {
|
||||
/// fn index_mut<'a>(&'a mut self, _index: &Foo) -> &'a mut Foo {
|
||||
/// println!("Indexing!");
|
||||
|
@ -636,6 +664,8 @@ pub trait IndexMut<Sized? Index, Sized? Result> for Sized? {
|
|||
/// ```ignore
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl Slice<Foo, Foo> for Foo {
|
||||
/// fn as_slice_<'a>(&'a self) -> &'a Foo {
|
||||
/// println!("Slicing!");
|
||||
|
@ -682,6 +712,8 @@ pub trait Slice<Sized? Idx, Sized? Result> for Sized? {
|
|||
/// ```ignore
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
///
|
||||
/// impl SliceMut<Foo, Foo> for Foo {
|
||||
/// fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
|
||||
/// println!("Slicing!");
|
||||
|
|
|
@ -147,7 +147,9 @@ pub use self::Option::*;
|
|||
|
||||
use cmp::{Eq, Ord};
|
||||
use default::Default;
|
||||
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, ExactSizeIterator};
|
||||
use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator};
|
||||
use iter::{ExactSizeIterator};
|
||||
use kinds::Copy;
|
||||
use mem;
|
||||
use result::Result;
|
||||
use result::Result::{Ok, Err};
|
||||
|
@ -857,3 +859,6 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T:Copy> Copy for Option<T> {}
|
||||
|
||||
|
|
|
@ -437,3 +437,4 @@ impl<T> PartialOrd for *mut T {
|
|||
#[inline]
|
||||
fn ge(&self, other: &*mut T) -> bool { *self >= *other }
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
//!
|
||||
//! Their definition should always match the ABI defined in `rustc::back::abi`.
|
||||
|
||||
use kinds::Copy;
|
||||
use mem;
|
||||
use kinds::Sized;
|
||||
|
||||
|
@ -28,6 +29,8 @@ pub struct Slice<T> {
|
|||
pub len: uint,
|
||||
}
|
||||
|
||||
impl<T> Copy for Slice<T> {}
|
||||
|
||||
/// The representation of a Rust closure
|
||||
#[repr(C)]
|
||||
pub struct Closure {
|
||||
|
@ -35,6 +38,8 @@ pub struct Closure {
|
|||
pub env: *mut (),
|
||||
}
|
||||
|
||||
impl Copy for Closure {}
|
||||
|
||||
/// The representation of a Rust procedure (`proc()`)
|
||||
#[repr(C)]
|
||||
pub struct Procedure {
|
||||
|
@ -42,6 +47,8 @@ pub struct Procedure {
|
|||
pub env: *mut (),
|
||||
}
|
||||
|
||||
impl Copy for Procedure {}
|
||||
|
||||
/// The representation of a Rust trait object.
|
||||
///
|
||||
/// This struct does not have a `Repr` implementation
|
||||
|
@ -52,6 +59,8 @@ pub struct TraitObject {
|
|||
pub vtable: *mut (),
|
||||
}
|
||||
|
||||
impl Copy for TraitObject {}
|
||||
|
||||
/// This trait is meant to map equivalences between raw structs and their
|
||||
/// corresponding rust values.
|
||||
pub trait Repr<T> for Sized? {
|
||||
|
|
|
@ -232,6 +232,7 @@
|
|||
|
||||
pub use self::Result::*;
|
||||
|
||||
use kinds::Copy;
|
||||
use std::fmt::Show;
|
||||
use slice;
|
||||
use slice::AsSlice;
|
||||
|
@ -916,3 +917,7 @@ pub fn fold<T,
|
|||
}
|
||||
Ok(init)
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl<T:Copy,U:Copy> Copy for Result<T,U> {}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#![allow(non_camel_case_types)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use kinds::Copy;
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
|
@ -46,6 +48,8 @@ pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
|
|||
pub i8, pub i8, pub i8, pub i8,
|
||||
pub i8, pub i8, pub i8, pub i8);
|
||||
|
||||
impl Copy for i8x16 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
|
@ -53,18 +57,24 @@ pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
|
|||
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
|
||||
pub i16, pub i16, pub i16, pub i16);
|
||||
|
||||
impl Copy for i16x8 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
|
||||
|
||||
impl Copy for i32x4 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct i64x2(pub i64, pub i64);
|
||||
|
||||
impl Copy for i64x2 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
|
@ -74,6 +84,8 @@ pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
|
|||
pub u8, pub u8, pub u8, pub u8,
|
||||
pub u8, pub u8, pub u8, pub u8);
|
||||
|
||||
impl Copy for u8x16 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
|
@ -81,26 +93,37 @@ pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
|
|||
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
|
||||
pub u16, pub u16, pub u16, pub u16);
|
||||
|
||||
impl Copy for u16x8 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
|
||||
|
||||
impl Copy for u32x4 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct u64x2(pub u64, pub u64);
|
||||
|
||||
impl Copy for u64x2 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
|
||||
|
||||
impl Copy for f32x4 {}
|
||||
|
||||
#[experimental]
|
||||
#[simd]
|
||||
#[deriving(Show)]
|
||||
#[repr(C)]
|
||||
pub struct f64x2(pub f64, pub f64);
|
||||
|
||||
impl Copy for f64x2 {}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ use cmp::Ordering::{Less, Equal, Greater};
|
|||
use cmp;
|
||||
use default::Default;
|
||||
use iter::*;
|
||||
use kinds::Copy;
|
||||
use num::Int;
|
||||
use ops;
|
||||
use option::Option;
|
||||
|
@ -1157,6 +1158,8 @@ impl<'a, T> Items<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a,T> Copy for Items<'a,T> {}
|
||||
|
||||
iterator!{struct Items -> *const T, &'a T}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
|
@ -1607,6 +1610,8 @@ pub enum BinarySearchResult {
|
|||
NotFound(uint)
|
||||
}
|
||||
|
||||
impl Copy for BinarySearchResult {}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
impl BinarySearchResult {
|
||||
/// Converts a `Found` to `Some`, `NotFound` to `None`.
|
||||
|
@ -1920,3 +1925,4 @@ impl_int_slice!(u16, i16)
|
|||
impl_int_slice!(u32, i32)
|
||||
impl_int_slice!(u64, i64)
|
||||
impl_int_slice!(uint, int)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ use default::Default;
|
|||
use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
|
||||
use iter::{DoubleEndedIteratorExt, ExactSizeIterator};
|
||||
use iter::range;
|
||||
use kinds::Sized;
|
||||
use kinds::{Copy, Sized};
|
||||
use mem;
|
||||
use num::Int;
|
||||
use option::Option;
|
||||
|
@ -176,6 +176,8 @@ pub struct Chars<'a> {
|
|||
iter: slice::Items<'a, u8>
|
||||
}
|
||||
|
||||
impl<'a> Copy for Chars<'a> {}
|
||||
|
||||
// Return the initial codepoint accumulator for the first byte.
|
||||
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
|
||||
// for width 3, and 3 bits for width 4
|
||||
|
@ -996,6 +998,8 @@ pub enum Utf16Item {
|
|||
LoneSurrogate(u16)
|
||||
}
|
||||
|
||||
impl Copy for Utf16Item {}
|
||||
|
||||
impl Utf16Item {
|
||||
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
|
||||
/// replacement character (U+FFFD).
|
||||
|
@ -1139,6 +1143,8 @@ pub struct CharRange {
|
|||
pub next: uint,
|
||||
}
|
||||
|
||||
impl Copy for CharRange {}
|
||||
|
||||
/// Mask of the value bits of a continuation byte
|
||||
const CONT_MASK: u8 = 0b0011_1111u8;
|
||||
/// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte
|
||||
|
@ -2315,3 +2321,4 @@ impl StrPrelude for str {
|
|||
impl<'a> Default for &'a str {
|
||||
fn default() -> &'a str { "" }
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ pub enum Piece<'a> {
|
|||
NextArgument(Argument<'a>),
|
||||
}
|
||||
|
||||
impl<'a> Copy for Piece<'a> {}
|
||||
|
||||
/// Representation of an argument specification.
|
||||
#[deriving(PartialEq)]
|
||||
pub struct Argument<'a> {
|
||||
|
@ -53,6 +55,8 @@ pub struct Argument<'a> {
|
|||
pub format: FormatSpec<'a>,
|
||||
}
|
||||
|
||||
impl<'a> Copy for Argument<'a> {}
|
||||
|
||||
/// Specification for the formatting of an argument in the format string.
|
||||
#[deriving(PartialEq)]
|
||||
pub struct FormatSpec<'a> {
|
||||
|
@ -72,6 +76,8 @@ pub struct FormatSpec<'a> {
|
|||
pub ty: &'a str
|
||||
}
|
||||
|
||||
impl<'a> Copy for FormatSpec<'a> {}
|
||||
|
||||
/// Enum describing where an argument for a format can be located.
|
||||
#[deriving(PartialEq)]
|
||||
pub enum Position<'a> {
|
||||
|
@ -83,6 +89,8 @@ pub enum Position<'a> {
|
|||
ArgumentNamed(&'a str),
|
||||
}
|
||||
|
||||
impl<'a> Copy for Position<'a> {}
|
||||
|
||||
/// Enum of alignments which are supported.
|
||||
#[deriving(PartialEq)]
|
||||
pub enum Alignment {
|
||||
|
@ -96,6 +104,8 @@ pub enum Alignment {
|
|||
AlignUnknown,
|
||||
}
|
||||
|
||||
impl Copy for Alignment {}
|
||||
|
||||
/// Various flags which can be applied to format strings. The meaning of these
|
||||
/// flags is defined by the formatters themselves.
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -112,6 +122,8 @@ pub enum Flag {
|
|||
FlagSignAwareZeroPad,
|
||||
}
|
||||
|
||||
impl Copy for Flag {}
|
||||
|
||||
/// A count is used for the precision and width parameters of an integer, and
|
||||
/// can reference either an argument or a literal integer.
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -128,6 +140,8 @@ pub enum Count<'a> {
|
|||
CountImplied,
|
||||
}
|
||||
|
||||
impl<'a> Copy for Count<'a> {}
|
||||
|
||||
/// The parser structure for interpreting the input format string. This is
|
||||
/// modelled as an iterator over `Piece` structures to form a stream of tokens
|
||||
/// being output.
|
||||
|
|
|
@ -97,6 +97,9 @@ use self::HasArg::*;
|
|||
use self::Occur::*;
|
||||
use self::Fail::*;
|
||||
use self::Optval::*;
|
||||
use self::SplitWithinState::*;
|
||||
use self::Whitespace::*;
|
||||
use self::LengthLimit::*;
|
||||
|
||||
use std::fmt;
|
||||
use std::result::Result::{Err, Ok};
|
||||
|
@ -125,6 +128,8 @@ pub enum HasArg {
|
|||
Maybe,
|
||||
}
|
||||
|
||||
impl Copy for HasArg {}
|
||||
|
||||
/// Describes how often an option may occur.
|
||||
#[deriving(Clone, PartialEq, Eq)]
|
||||
pub enum Occur {
|
||||
|
@ -136,6 +141,8 @@ pub enum Occur {
|
|||
Multi,
|
||||
}
|
||||
|
||||
impl Copy for Occur {}
|
||||
|
||||
/// A description of a possible option.
|
||||
#[deriving(Clone, PartialEq, Eq)]
|
||||
pub struct Opt {
|
||||
|
@ -203,6 +210,19 @@ pub enum Fail {
|
|||
UnexpectedArgument(String),
|
||||
}
|
||||
|
||||
/// The type of failure that occurred.
|
||||
#[deriving(PartialEq, Eq)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum FailType {
|
||||
ArgumentMissing_,
|
||||
UnrecognizedOption_,
|
||||
OptionMissing_,
|
||||
OptionDuplicated_,
|
||||
UnexpectedArgument_,
|
||||
}
|
||||
|
||||
impl Copy for FailType {}
|
||||
|
||||
/// The result of parsing a command line with a set of options.
|
||||
pub type Result = result::Result<Matches, Fail>;
|
||||
|
||||
|
@ -824,14 +844,17 @@ enum SplitWithinState {
|
|||
B, // words
|
||||
C, // internal and trailing whitespace
|
||||
}
|
||||
impl Copy for SplitWithinState {}
|
||||
enum Whitespace {
|
||||
Ws, // current char is whitespace
|
||||
Cr // current char is not whitespace
|
||||
}
|
||||
impl Copy for Whitespace {}
|
||||
enum LengthLimit {
|
||||
UnderLim, // current char makes current substring still fit in limit
|
||||
OverLim // current char makes current substring no longer fit in limit
|
||||
}
|
||||
impl Copy for LengthLimit {}
|
||||
|
||||
|
||||
/// Splits a string into substrings with possibly internal whitespace,
|
||||
|
@ -847,9 +870,6 @@ enum LengthLimit {
|
|||
/// sequence longer than the limit.
|
||||
fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool)
|
||||
-> bool {
|
||||
use self::SplitWithinState::*;
|
||||
use self::Whitespace::*;
|
||||
use self::LengthLimit::*;
|
||||
// Just for fun, let's write this as a state machine:
|
||||
|
||||
let mut slice_start = 0;
|
||||
|
|
|
@ -76,6 +76,7 @@
|
|||
#![allow(non_upper_case_globals)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(raw_pointer_deriving)]
|
||||
|
||||
extern crate core;
|
||||
|
||||
|
@ -340,12 +341,15 @@ pub mod types {
|
|||
/// variants, because the compiler complains about the repr attribute
|
||||
/// otherwise.
|
||||
#[repr(u8)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum c_void {
|
||||
__variant1,
|
||||
__variant2,
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum FILE {}
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum fpos_t {}
|
||||
}
|
||||
pub mod c99 {
|
||||
|
@ -359,7 +363,9 @@ pub mod types {
|
|||
pub type uint64_t = u64;
|
||||
}
|
||||
pub mod posix88 {
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DIR {}
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum dirent_t {}
|
||||
}
|
||||
pub mod posix01 {}
|
||||
|
@ -380,7 +386,7 @@ pub mod types {
|
|||
pub type pthread_t = c_ulong;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct glob_t {
|
||||
#[deriving(Copy)] pub struct glob_t {
|
||||
pub gl_pathc: size_t,
|
||||
pub gl_pathv: *mut *mut c_char,
|
||||
pub gl_offs: size_t,
|
||||
|
@ -393,18 +399,18 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timeval {
|
||||
#[deriving(Copy)] pub struct timeval {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_usec: suseconds_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
#[deriving(Copy)] pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
pub enum timezone {}
|
||||
#[deriving(Copy)] pub enum timezone {}
|
||||
|
||||
pub type sighandler_t = size_t;
|
||||
}
|
||||
|
@ -417,29 +423,29 @@ pub mod types {
|
|||
pub type in_port_t = u16;
|
||||
pub type in_addr_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct sockaddr {
|
||||
#[deriving(Copy)] pub struct sockaddr {
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [u8, ..14],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_storage {
|
||||
#[deriving(Copy)] pub struct sockaddr_storage {
|
||||
pub ss_family: sa_family_t,
|
||||
pub __ss_align: i64,
|
||||
pub __ss_pad2: [u8, ..112],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in {
|
||||
#[deriving(Copy)] pub struct sockaddr_in {
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
pub sin_addr: in_addr,
|
||||
pub sin_zero: [u8, ..8],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in_addr {
|
||||
#[deriving(Copy)] pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in6 {
|
||||
#[deriving(Copy)] pub struct sockaddr_in6 {
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
pub sin6_flowinfo: u32,
|
||||
|
@ -447,21 +453,21 @@ pub mod types {
|
|||
pub sin6_scope_id: u32,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
#[deriving(Copy)] pub struct in6_addr {
|
||||
pub s6_addr: [u16, ..8]
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip_mreq {
|
||||
#[deriving(Copy)] pub struct ip_mreq {
|
||||
pub imr_multiaddr: in_addr,
|
||||
pub imr_interface: in_addr,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip6_mreq {
|
||||
#[deriving(Copy)] pub struct ip6_mreq {
|
||||
pub ipv6mr_multiaddr: in6_addr,
|
||||
pub ipv6mr_interface: c_uint,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct addrinfo {
|
||||
#[deriving(Copy)] pub struct addrinfo {
|
||||
pub ai_flags: c_int,
|
||||
pub ai_family: c_int,
|
||||
pub ai_socktype: c_int,
|
||||
|
@ -483,13 +489,13 @@ pub mod types {
|
|||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_un {
|
||||
#[deriving(Copy)] pub struct sockaddr_un {
|
||||
pub sun_family: sa_family_t,
|
||||
pub sun_path: [c_char, ..108]
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ifaddrs {
|
||||
#[deriving(Copy)] pub struct ifaddrs {
|
||||
pub ifa_next: *mut ifaddrs,
|
||||
pub ifa_name: *mut c_char,
|
||||
pub ifa_flags: c_uint,
|
||||
|
@ -572,7 +578,7 @@ pub mod types {
|
|||
pub type blkcnt_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub __pad1: c_short,
|
||||
pub st_ino: ino_t,
|
||||
|
@ -596,13 +602,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __size: [u32, ..9]
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +623,7 @@ pub mod types {
|
|||
pub type blkcnt_t = u32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: c_ulonglong,
|
||||
pub __pad0: [c_uchar, ..4],
|
||||
pub __st_ino: ino_t,
|
||||
|
@ -640,13 +646,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __size: [u32, ..9]
|
||||
}
|
||||
}
|
||||
|
@ -662,7 +668,7 @@ pub mod types {
|
|||
pub type blkcnt_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: c_ulong,
|
||||
pub st_pad1: [c_long, ..3],
|
||||
pub st_ino: ino_t,
|
||||
|
@ -686,13 +692,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __size: [u32, ..9]
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +707,7 @@ pub mod types {
|
|||
pub mod extra {
|
||||
use types::os::arch::c95::{c_ushort, c_int, c_uchar};
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_ll {
|
||||
#[deriving(Copy)] pub struct sockaddr_ll {
|
||||
pub sll_family: c_ushort,
|
||||
pub sll_protocol: c_ushort,
|
||||
pub sll_ifindex: c_int,
|
||||
|
@ -764,7 +770,7 @@ pub mod types {
|
|||
pub type blksize_t = i64;
|
||||
pub type blkcnt_t = i64;
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_ino: ino_t,
|
||||
pub st_nlink: nlink_t,
|
||||
|
@ -786,13 +792,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __size: [u64, ..7]
|
||||
}
|
||||
}
|
||||
|
@ -802,7 +808,7 @@ pub mod types {
|
|||
}
|
||||
pub mod extra {
|
||||
use types::os::arch::c95::{c_ushort, c_int, c_uchar};
|
||||
pub struct sockaddr_ll {
|
||||
#[deriving(Copy)] pub struct sockaddr_ll {
|
||||
pub sll_family: c_ushort,
|
||||
pub sll_protocol: c_ushort,
|
||||
pub sll_ifindex: c_int,
|
||||
|
@ -828,7 +834,7 @@ pub mod types {
|
|||
pub type pthread_t = uintptr_t;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct glob_t {
|
||||
#[deriving(Copy)] pub struct glob_t {
|
||||
pub gl_pathc: size_t,
|
||||
pub __unused1: size_t,
|
||||
pub gl_offs: size_t,
|
||||
|
@ -845,18 +851,18 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timeval {
|
||||
#[deriving(Copy)] pub struct timeval {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_usec: suseconds_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
#[deriving(Copy)] pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
pub enum timezone {}
|
||||
#[deriving(Copy)] pub enum timezone {}
|
||||
|
||||
pub type sighandler_t = size_t;
|
||||
}
|
||||
|
@ -869,13 +875,13 @@ pub mod types {
|
|||
pub type in_port_t = u16;
|
||||
pub type in_addr_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct sockaddr {
|
||||
#[deriving(Copy)] pub struct sockaddr {
|
||||
pub sa_len: u8,
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [u8, ..14],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_storage {
|
||||
#[deriving(Copy)] pub struct sockaddr_storage {
|
||||
pub ss_len: u8,
|
||||
pub ss_family: sa_family_t,
|
||||
pub __ss_pad1: [u8, ..6],
|
||||
|
@ -883,7 +889,7 @@ pub mod types {
|
|||
pub __ss_pad2: [u8, ..112],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in {
|
||||
#[deriving(Copy)] pub struct sockaddr_in {
|
||||
pub sin_len: u8,
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
|
@ -891,11 +897,11 @@ pub mod types {
|
|||
pub sin_zero: [u8, ..8],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in_addr {
|
||||
#[deriving(Copy)] pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in6 {
|
||||
#[deriving(Copy)] pub struct sockaddr_in6 {
|
||||
pub sin6_len: u8,
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
|
@ -904,21 +910,21 @@ pub mod types {
|
|||
pub sin6_scope_id: u32,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
#[deriving(Copy)] pub struct in6_addr {
|
||||
pub s6_addr: [u16, ..8]
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip_mreq {
|
||||
#[deriving(Copy)] pub struct ip_mreq {
|
||||
pub imr_multiaddr: in_addr,
|
||||
pub imr_interface: in_addr,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip6_mreq {
|
||||
#[deriving(Copy)] pub struct ip6_mreq {
|
||||
pub ipv6mr_multiaddr: in6_addr,
|
||||
pub ipv6mr_interface: c_uint,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct addrinfo {
|
||||
#[deriving(Copy)] pub struct addrinfo {
|
||||
pub ai_flags: c_int,
|
||||
pub ai_family: c_int,
|
||||
pub ai_socktype: c_int,
|
||||
|
@ -929,13 +935,13 @@ pub mod types {
|
|||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_un {
|
||||
#[deriving(Copy)] pub struct sockaddr_un {
|
||||
pub sun_len: u8,
|
||||
pub sun_family: sa_family_t,
|
||||
pub sun_path: [c_char, ..104]
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ifaddrs {
|
||||
#[deriving(Copy)] pub struct ifaddrs {
|
||||
pub ifa_next: *mut ifaddrs,
|
||||
pub ifa_name: *mut c_char,
|
||||
pub ifa_flags: c_uint,
|
||||
|
@ -1002,7 +1008,7 @@ pub mod types {
|
|||
pub type blkcnt_t = i64;
|
||||
pub type fflags_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_ino: ino_t,
|
||||
pub st_mode: mode_t,
|
||||
|
@ -1028,7 +1034,7 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
@ -1056,7 +1062,7 @@ pub mod types {
|
|||
pub type pthread_t = uintptr_t;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct glob_t {
|
||||
#[deriving(Copy)] pub struct glob_t {
|
||||
pub gl_pathc: size_t,
|
||||
pub __unused1: size_t,
|
||||
pub gl_offs: size_t,
|
||||
|
@ -1073,18 +1079,18 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timeval {
|
||||
#[deriving(Copy)] pub struct timeval {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_usec: suseconds_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
#[deriving(Copy)] pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
pub enum timezone {}
|
||||
#[deriving(Copy)] pub enum timezone {}
|
||||
|
||||
pub type sighandler_t = size_t;
|
||||
}
|
||||
|
@ -1096,13 +1102,13 @@ pub mod types {
|
|||
pub type in_port_t = u16;
|
||||
pub type in_addr_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct sockaddr {
|
||||
#[deriving(Copy)] pub struct sockaddr {
|
||||
pub sa_len: u8,
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [u8, ..14],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_storage {
|
||||
#[deriving(Copy)] pub struct sockaddr_storage {
|
||||
pub ss_len: u8,
|
||||
pub ss_family: sa_family_t,
|
||||
pub __ss_pad1: [u8, ..6],
|
||||
|
@ -1110,7 +1116,7 @@ pub mod types {
|
|||
pub __ss_pad2: [u8, ..112],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in {
|
||||
#[deriving(Copy)] pub struct sockaddr_in {
|
||||
pub sin_len: u8,
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
|
@ -1118,11 +1124,11 @@ pub mod types {
|
|||
pub sin_zero: [u8, ..8],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in_addr {
|
||||
#[deriving(Copy)] pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in6 {
|
||||
#[deriving(Copy)] pub struct sockaddr_in6 {
|
||||
pub sin6_len: u8,
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
|
@ -1131,21 +1137,21 @@ pub mod types {
|
|||
pub sin6_scope_id: u32,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
#[deriving(Copy)] pub struct in6_addr {
|
||||
pub s6_addr: [u16, ..8]
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip_mreq {
|
||||
#[deriving(Copy)] pub struct ip_mreq {
|
||||
pub imr_multiaddr: in_addr,
|
||||
pub imr_interface: in_addr,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip6_mreq {
|
||||
#[deriving(Copy)] pub struct ip6_mreq {
|
||||
pub ipv6mr_multiaddr: in6_addr,
|
||||
pub ipv6mr_interface: c_uint,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct addrinfo {
|
||||
#[deriving(Copy)] pub struct addrinfo {
|
||||
pub ai_flags: c_int,
|
||||
pub ai_family: c_int,
|
||||
pub ai_socktype: c_int,
|
||||
|
@ -1156,7 +1162,7 @@ pub mod types {
|
|||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_un {
|
||||
#[deriving(Copy)] pub struct sockaddr_un {
|
||||
pub sun_len: u8,
|
||||
pub sun_family: sa_family_t,
|
||||
pub sun_path: [c_char, ..104]
|
||||
|
@ -1219,7 +1225,7 @@ pub mod types {
|
|||
pub type fflags_t = u32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_ino: ino_t,
|
||||
pub st_nlink: nlink_t,
|
||||
pub st_dev: dev_t,
|
||||
|
@ -1244,7 +1250,7 @@ pub mod types {
|
|||
pub st_qspare2: int64_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
@ -1271,7 +1277,7 @@ pub mod types {
|
|||
// pub Note: this is the struct called stat64 in Windows. Not stat,
|
||||
// nor stati64.
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_ino: ino_t,
|
||||
pub st_mode: u16,
|
||||
|
@ -1287,24 +1293,24 @@ pub mod types {
|
|||
|
||||
// note that this is called utimbuf64 in Windows
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time64_t,
|
||||
pub modtime: time64_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timeval {
|
||||
#[deriving(Copy)] pub struct timeval {
|
||||
pub tv_sec: c_long,
|
||||
pub tv_usec: c_long,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
#[deriving(Copy)] pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
pub enum timezone {}
|
||||
#[deriving(Copy)] pub enum timezone {}
|
||||
}
|
||||
|
||||
pub mod bsd44 {
|
||||
|
@ -1317,30 +1323,30 @@ pub mod types {
|
|||
pub type in_port_t = u16;
|
||||
pub type in_addr_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct sockaddr {
|
||||
#[deriving(Copy)] pub struct sockaddr {
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [u8, ..14],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_storage {
|
||||
#[deriving(Copy)] pub struct sockaddr_storage {
|
||||
pub ss_family: sa_family_t,
|
||||
pub __ss_pad1: [u8, ..6],
|
||||
pub __ss_align: i64,
|
||||
pub __ss_pad2: [u8, ..112],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in {
|
||||
#[deriving(Copy)] pub struct sockaddr_in {
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
pub sin_addr: in_addr,
|
||||
pub sin_zero: [u8, ..8],
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in_addr {
|
||||
#[deriving(Copy)] pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in6 {
|
||||
#[deriving(Copy)] pub struct sockaddr_in6 {
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
pub sin6_flowinfo: u32,
|
||||
|
@ -1348,21 +1354,21 @@ pub mod types {
|
|||
pub sin6_scope_id: u32,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
#[deriving(Copy)] pub struct in6_addr {
|
||||
pub s6_addr: [u16, ..8]
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip_mreq {
|
||||
#[deriving(Copy)] pub struct ip_mreq {
|
||||
pub imr_multiaddr: in_addr,
|
||||
pub imr_interface: in_addr,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct ip6_mreq {
|
||||
#[deriving(Copy)] pub struct ip6_mreq {
|
||||
pub ipv6mr_multiaddr: in6_addr,
|
||||
pub ipv6mr_interface: c_uint,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct addrinfo {
|
||||
#[deriving(Copy)] pub struct addrinfo {
|
||||
pub ai_flags: c_int,
|
||||
pub ai_family: c_int,
|
||||
pub ai_socktype: c_int,
|
||||
|
@ -1373,7 +1379,7 @@ pub mod types {
|
|||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_un {
|
||||
#[deriving(Copy)] pub struct sockaddr_un {
|
||||
pub sun_family: sa_family_t,
|
||||
pub sun_path: [c_char, ..108]
|
||||
}
|
||||
|
@ -1501,7 +1507,7 @@ pub mod types {
|
|||
pub type LPCH = *mut CHAR;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SECURITY_ATTRIBUTES {
|
||||
#[deriving(Copy)] pub struct SECURITY_ATTRIBUTES {
|
||||
pub nLength: DWORD,
|
||||
pub lpSecurityDescriptor: LPVOID,
|
||||
pub bInheritHandle: BOOL,
|
||||
|
@ -1525,7 +1531,7 @@ pub mod types {
|
|||
pub type int64 = i64;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct STARTUPINFO {
|
||||
#[deriving(Copy)] pub struct STARTUPINFO {
|
||||
pub cb: DWORD,
|
||||
pub lpReserved: LPWSTR,
|
||||
pub lpDesktop: LPWSTR,
|
||||
|
@ -1548,7 +1554,7 @@ pub mod types {
|
|||
pub type LPSTARTUPINFO = *mut STARTUPINFO;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct PROCESS_INFORMATION {
|
||||
#[deriving(Copy)] pub struct PROCESS_INFORMATION {
|
||||
pub hProcess: HANDLE,
|
||||
pub hThread: HANDLE,
|
||||
pub dwProcessId: DWORD,
|
||||
|
@ -1557,7 +1563,7 @@ pub mod types {
|
|||
pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SYSTEM_INFO {
|
||||
#[deriving(Copy)] pub struct SYSTEM_INFO {
|
||||
pub wProcessorArchitecture: WORD,
|
||||
pub wReserved: WORD,
|
||||
pub dwPageSize: DWORD,
|
||||
|
@ -1573,7 +1579,7 @@ pub mod types {
|
|||
pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct MEMORY_BASIC_INFORMATION {
|
||||
#[deriving(Copy)] pub struct MEMORY_BASIC_INFORMATION {
|
||||
pub BaseAddress: LPVOID,
|
||||
pub AllocationBase: LPVOID,
|
||||
pub AllocationProtect: DWORD,
|
||||
|
@ -1585,7 +1591,7 @@ pub mod types {
|
|||
pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct OVERLAPPED {
|
||||
#[deriving(Copy)] pub struct OVERLAPPED {
|
||||
pub Internal: *mut c_ulong,
|
||||
pub InternalHigh: *mut c_ulong,
|
||||
pub Offset: DWORD,
|
||||
|
@ -1596,7 +1602,7 @@ pub mod types {
|
|||
pub type LPOVERLAPPED = *mut OVERLAPPED;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct FILETIME {
|
||||
#[deriving(Copy)] pub struct FILETIME {
|
||||
pub dwLowDateTime: DWORD,
|
||||
pub dwHighDateTime: DWORD,
|
||||
}
|
||||
|
@ -1604,7 +1610,7 @@ pub mod types {
|
|||
pub type LPFILETIME = *mut FILETIME;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct GUID {
|
||||
#[deriving(Copy)] pub struct GUID {
|
||||
pub Data1: DWORD,
|
||||
pub Data2: WORD,
|
||||
pub Data3: WORD,
|
||||
|
@ -1612,7 +1618,7 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct WSAPROTOCOLCHAIN {
|
||||
#[deriving(Copy)] pub struct WSAPROTOCOLCHAIN {
|
||||
pub ChainLen: c_int,
|
||||
pub ChainEntries: [DWORD, ..MAX_PROTOCOL_CHAIN as uint],
|
||||
}
|
||||
|
@ -1620,7 +1626,7 @@ pub mod types {
|
|||
pub type LPWSAPROTOCOLCHAIN = *mut WSAPROTOCOLCHAIN;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct WSAPROTOCOL_INFO {
|
||||
#[deriving(Copy)] pub struct WSAPROTOCOL_INFO {
|
||||
pub dwServiceFlags1: DWORD,
|
||||
pub dwServiceFlags2: DWORD,
|
||||
pub dwServiceFlags3: DWORD,
|
||||
|
@ -1648,7 +1654,7 @@ pub mod types {
|
|||
pub type GROUP = c_uint;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct WIN32_FIND_DATAW {
|
||||
#[deriving(Copy)] pub struct WIN32_FIND_DATAW {
|
||||
pub dwFileAttributes: DWORD,
|
||||
pub ftCreationTime: FILETIME,
|
||||
pub ftLastAccessTime: FILETIME,
|
||||
|
@ -1671,14 +1677,14 @@ pub mod types {
|
|||
pub mod common {
|
||||
pub mod posix01 {
|
||||
use types::common::c95::c_void;
|
||||
use types::os::arch::c95::{c_char, c_int, size_t,
|
||||
time_t, suseconds_t, c_long};
|
||||
use types::os::arch::c95::{c_char, c_int, size_t, time_t};
|
||||
use types::os::arch::c95::{suseconds_t, c_long};
|
||||
use types::os::arch::c99::{uintptr_t};
|
||||
|
||||
pub type pthread_t = uintptr_t;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct glob_t {
|
||||
#[deriving(Copy)] pub struct glob_t {
|
||||
pub gl_pathc: size_t,
|
||||
pub __unused1: c_int,
|
||||
pub gl_offs: size_t,
|
||||
|
@ -1695,18 +1701,18 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timeval {
|
||||
#[deriving(Copy)] pub struct timeval {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_usec: suseconds_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct timespec {
|
||||
#[deriving(Copy)] pub struct timespec {
|
||||
pub tv_sec: time_t,
|
||||
pub tv_nsec: c_long,
|
||||
}
|
||||
|
||||
pub enum timezone {}
|
||||
#[deriving(Copy)] pub enum timezone {}
|
||||
|
||||
pub type sighandler_t = size_t;
|
||||
}
|
||||
|
@ -1720,33 +1726,37 @@ pub mod types {
|
|||
pub type in_port_t = u16;
|
||||
pub type in_addr_t = u32;
|
||||
#[repr(C)]
|
||||
pub struct sockaddr {
|
||||
#[deriving(Copy)] pub struct sockaddr {
|
||||
pub sa_len: u8,
|
||||
pub sa_family: sa_family_t,
|
||||
pub sa_data: [u8, ..14],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_storage {
|
||||
#[deriving(Copy)] pub struct sockaddr_storage {
|
||||
pub ss_len: u8,
|
||||
pub ss_family: sa_family_t,
|
||||
pub __ss_pad1: [u8, ..6],
|
||||
pub __ss_align: i64,
|
||||
pub __ss_pad2: [u8, ..112],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in {
|
||||
#[deriving(Copy)] pub struct sockaddr_in {
|
||||
pub sin_len: u8,
|
||||
pub sin_family: sa_family_t,
|
||||
pub sin_port: in_port_t,
|
||||
pub sin_addr: in_addr,
|
||||
pub sin_zero: [u8, ..8],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct in_addr {
|
||||
#[deriving(Copy)] pub struct in_addr {
|
||||
pub s_addr: in_addr_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_in6 {
|
||||
#[deriving(Copy)] pub struct sockaddr_in6 {
|
||||
pub sin6_len: u8,
|
||||
pub sin6_family: sa_family_t,
|
||||
pub sin6_port: in_port_t,
|
||||
|
@ -1754,22 +1764,26 @@ pub mod types {
|
|||
pub sin6_addr: in6_addr,
|
||||
pub sin6_scope_id: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct in6_addr {
|
||||
#[deriving(Copy)] pub struct in6_addr {
|
||||
pub s6_addr: [u16, ..8]
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ip_mreq {
|
||||
#[deriving(Copy)] pub struct ip_mreq {
|
||||
pub imr_multiaddr: in_addr,
|
||||
pub imr_interface: in_addr,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ip6_mreq {
|
||||
#[deriving(Copy)] pub struct ip6_mreq {
|
||||
pub ipv6mr_multiaddr: in6_addr,
|
||||
pub ipv6mr_interface: c_uint,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct addrinfo {
|
||||
#[deriving(Copy)] pub struct addrinfo {
|
||||
pub ai_flags: c_int,
|
||||
pub ai_family: c_int,
|
||||
pub ai_socktype: c_int,
|
||||
|
@ -1779,14 +1793,16 @@ pub mod types {
|
|||
pub ai_addr: *mut sockaddr,
|
||||
pub ai_next: *mut addrinfo,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct sockaddr_un {
|
||||
#[deriving(Copy)] pub struct sockaddr_un {
|
||||
pub sun_len: u8,
|
||||
pub sun_family: sa_family_t,
|
||||
pub sun_path: [c_char, ..104]
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ifaddrs {
|
||||
#[deriving(Copy)] pub struct ifaddrs {
|
||||
pub ifa_next: *mut ifaddrs,
|
||||
pub ifa_name: *mut c_char,
|
||||
pub ifa_flags: c_uint,
|
||||
|
@ -1849,7 +1865,7 @@ pub mod types {
|
|||
pub type blkcnt_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_mode: mode_t,
|
||||
pub st_nlink: nlink_t,
|
||||
|
@ -1875,13 +1891,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __sig: c_long,
|
||||
pub __opaque: [c_char, ..36]
|
||||
}
|
||||
|
@ -1892,7 +1908,7 @@ pub mod types {
|
|||
}
|
||||
pub mod extra {
|
||||
#[repr(C)]
|
||||
pub struct mach_timebase_info {
|
||||
#[deriving(Copy)] pub struct mach_timebase_info {
|
||||
pub numer: u32,
|
||||
pub denom: u32,
|
||||
}
|
||||
|
@ -1953,7 +1969,7 @@ pub mod types {
|
|||
pub type blkcnt_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
#[deriving(Copy)] pub struct stat {
|
||||
pub st_dev: dev_t,
|
||||
pub st_mode: mode_t,
|
||||
pub st_nlink: nlink_t,
|
||||
|
@ -1979,13 +1995,13 @@ pub mod types {
|
|||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct utimbuf {
|
||||
#[deriving(Copy)] pub struct utimbuf {
|
||||
pub actime: time_t,
|
||||
pub modtime: time_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct pthread_attr_t {
|
||||
#[deriving(Copy)] pub struct pthread_attr_t {
|
||||
pub __sig: c_long,
|
||||
pub __opaque: [c_char, ..56]
|
||||
}
|
||||
|
@ -1996,7 +2012,7 @@ pub mod types {
|
|||
}
|
||||
pub mod extra {
|
||||
#[repr(C)]
|
||||
pub struct mach_timebase_info {
|
||||
#[deriving(Copy)] pub struct mach_timebase_info {
|
||||
pub numer: u32,
|
||||
pub denom: u32,
|
||||
}
|
||||
|
@ -4990,3 +5006,9 @@ pub mod funcs {
|
|||
pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen correctly
|
||||
|
||||
#[test] fn work_on_windows() { } // FIXME #10872 needed for a happy windows
|
||||
|
||||
#[doc(hidden)]
|
||||
#[cfg(not(test))]
|
||||
mod std {
|
||||
pub use core::kinds;
|
||||
}
|
||||
|
|
|
@ -234,6 +234,8 @@ struct DefaultLogger {
|
|||
#[deriving(PartialEq, PartialOrd)]
|
||||
pub struct LogLevel(pub u32);
|
||||
|
||||
impl Copy for LogLevel {}
|
||||
|
||||
impl fmt::Show for LogLevel {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
let LogLevel(level) = *self;
|
||||
|
@ -344,6 +346,8 @@ pub struct LogLocation {
|
|||
pub line: uint,
|
||||
}
|
||||
|
||||
impl Copy for LogLocation {}
|
||||
|
||||
/// Tests whether a given module's name is enabled for a particular level of
|
||||
/// logging. This is the second layer of defense about determining whether a
|
||||
/// module's log statement should be emitted or not.
|
||||
|
|
|
@ -35,6 +35,8 @@ pub struct ChaChaRng {
|
|||
index: uint, // Index into state
|
||||
}
|
||||
|
||||
impl Copy for ChaChaRng {}
|
||||
|
||||
static EMPTY: ChaChaRng = ChaChaRng {
|
||||
buffer: [0, ..STATE_WORDS],
|
||||
state: [0, ..STATE_WORDS],
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
//! The exponential distribution.
|
||||
|
||||
use core::kinds::Copy;
|
||||
use core::num::Float;
|
||||
|
||||
use {Rng, Rand};
|
||||
|
@ -31,6 +32,8 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
|
|||
/// College, Oxford
|
||||
pub struct Exp1(pub f64);
|
||||
|
||||
impl Copy for Exp1 {}
|
||||
|
||||
// This could be done via `-rng.gen::<f64>().ln()` but that is slower.
|
||||
impl Rand for Exp1 {
|
||||
#[inline]
|
||||
|
@ -71,6 +74,8 @@ pub struct Exp {
|
|||
lambda_inverse: f64
|
||||
}
|
||||
|
||||
impl Copy for Exp {}
|
||||
|
||||
impl Exp {
|
||||
/// Construct a new `Exp` with the given shape parameter
|
||||
/// `lambda`. Panics if `lambda <= 0`.
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
//! The normal and derived distributions.
|
||||
|
||||
use core::kinds::Copy;
|
||||
use core::num::Float;
|
||||
|
||||
use {Rng, Rand, Open01};
|
||||
|
@ -30,6 +31,8 @@ use distributions::{ziggurat, ziggurat_tables, Sample, IndependentSample};
|
|||
/// College, Oxford
|
||||
pub struct StandardNormal(pub f64);
|
||||
|
||||
impl Copy for StandardNormal {}
|
||||
|
||||
impl Rand for StandardNormal {
|
||||
fn rand<R:Rng>(rng: &mut R) -> StandardNormal {
|
||||
#[inline]
|
||||
|
@ -88,6 +91,8 @@ pub struct Normal {
|
|||
std_dev: f64,
|
||||
}
|
||||
|
||||
impl Copy for Normal {}
|
||||
|
||||
impl Normal {
|
||||
/// Construct a new `Normal` distribution with the given mean and
|
||||
/// standard deviation.
|
||||
|
@ -134,6 +139,8 @@ pub struct LogNormal {
|
|||
norm: Normal
|
||||
}
|
||||
|
||||
impl Copy for LogNormal {}
|
||||
|
||||
impl LogNormal {
|
||||
/// Construct a new `LogNormal` distribution with the given mean
|
||||
/// and standard deviation.
|
||||
|
|
|
@ -37,6 +37,9 @@ pub struct IsaacRng {
|
|||
b: u32,
|
||||
c: u32
|
||||
}
|
||||
|
||||
impl Copy for IsaacRng {}
|
||||
|
||||
static EMPTY: IsaacRng = IsaacRng {
|
||||
cnt: 0,
|
||||
rsl: [0, ..RAND_SIZE_UINT],
|
||||
|
@ -271,6 +274,8 @@ pub struct Isaac64Rng {
|
|||
c: u64,
|
||||
}
|
||||
|
||||
impl Copy for Isaac64Rng {}
|
||||
|
||||
static EMPTY_64: Isaac64Rng = Isaac64Rng {
|
||||
cnt: 0,
|
||||
rsl: [0, .. RAND_SIZE_64],
|
||||
|
|
|
@ -377,6 +377,7 @@ pub trait SeedableRng<Seed>: Rng {
|
|||
/// [1]: Marsaglia, George (July 2003). ["Xorshift
|
||||
/// RNGs"](http://www.jstatsoft.org/v08/i14/paper). *Journal of
|
||||
/// Statistical Software*. Vol. 8 (Issue 14).
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct XorShiftRng {
|
||||
x: u32,
|
||||
y: u32,
|
||||
|
@ -384,6 +385,17 @@ pub struct XorShiftRng {
|
|||
w: u32,
|
||||
}
|
||||
|
||||
impl Clone for XorShiftRng {
|
||||
fn clone(&self) -> XorShiftRng {
|
||||
XorShiftRng {
|
||||
x: self.x,
|
||||
y: self.y,
|
||||
z: self.z,
|
||||
w: self.w,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl XorShiftRng {
|
||||
/// Creates a new XorShiftRng instance which is not seeded.
|
||||
///
|
||||
|
|
|
@ -135,6 +135,8 @@ pub trait Reseeder<R> {
|
|||
/// replacing the RNG with the result of a `Default::default` call.
|
||||
pub struct ReseedWithDefault;
|
||||
|
||||
impl Copy for ReseedWithDefault {}
|
||||
|
||||
impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
|
||||
fn reseed(&mut self, rng: &mut R) {
|
||||
*rng = Default::default();
|
||||
|
|
|
@ -47,6 +47,8 @@ pub struct Doc<'a> {
|
|||
pub end: uint,
|
||||
}
|
||||
|
||||
impl<'doc> Copy for Doc<'doc> {}
|
||||
|
||||
impl<'doc> Doc<'doc> {
|
||||
pub fn new(data: &'doc [u8]) -> Doc<'doc> {
|
||||
Doc { data: data, start: 0u, end: data.len() }
|
||||
|
@ -104,6 +106,8 @@ pub enum EbmlEncoderTag {
|
|||
EsLabel, // Used only when debugging
|
||||
}
|
||||
|
||||
impl Copy for EbmlEncoderTag {}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub enum Error {
|
||||
IntTooBig(uint),
|
||||
|
@ -151,6 +155,8 @@ pub mod reader {
|
|||
pub next: uint
|
||||
}
|
||||
|
||||
impl Copy for Res {}
|
||||
|
||||
#[inline(never)]
|
||||
fn vuint_at_slow(data: &[u8], start: uint) -> DecodeResult<Res> {
|
||||
let a = data[start];
|
||||
|
|
|
@ -83,6 +83,8 @@ pub enum Greed {
|
|||
Ungreedy,
|
||||
}
|
||||
|
||||
impl Copy for Greed {}
|
||||
|
||||
impl Greed {
|
||||
pub fn is_greedy(&self) -> bool {
|
||||
match *self {
|
||||
|
|
|
@ -135,8 +135,12 @@ pub struct ExNative {
|
|||
pub prog: fn(MatchKind, &str, uint, uint) -> Vec<Option<uint>>
|
||||
}
|
||||
|
||||
impl Copy for ExNative {}
|
||||
|
||||
impl Clone for ExNative {
|
||||
fn clone(&self) -> ExNative { *self }
|
||||
fn clone(&self) -> ExNative {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Show for Regex {
|
||||
|
@ -917,7 +921,7 @@ fn exec_slice(re: &Regex, which: MatchKind,
|
|||
input: &str, s: uint, e: uint) -> CaptureLocs {
|
||||
match *re {
|
||||
Dynamic(ExDynamic { ref prog, .. }) => vm::run(which, prog, input, s, e),
|
||||
Native(ExNative { prog, .. }) => prog(which, input, s, e),
|
||||
Native(ExNative { ref prog, .. }) => (*prog)(which, input, s, e),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ pub enum MatchKind {
|
|||
Submatches,
|
||||
}
|
||||
|
||||
impl Copy for MatchKind {}
|
||||
|
||||
/// Runs an NFA simulation on the compiled expression given on the search text
|
||||
/// `input`. The search begins at byte index `start` and ends at byte index
|
||||
/// `end`. (The range is specified here so that zero-width assertions will work
|
||||
|
@ -107,6 +109,8 @@ pub enum StepState {
|
|||
StepContinue,
|
||||
}
|
||||
|
||||
impl Copy for StepState {}
|
||||
|
||||
impl<'r, 't> Nfa<'r, 't> {
|
||||
fn run(&mut self) -> CaptureLocs {
|
||||
let ncaps = match self.which {
|
||||
|
|
|
@ -28,6 +28,7 @@ use self::MethodContext::*;
|
|||
|
||||
use metadata::csearch;
|
||||
use middle::def::*;
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::{def, pat_util, stability};
|
||||
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
|
||||
|
@ -40,11 +41,12 @@ use std::collections::hash_map::{Occupied, Vacant};
|
|||
use std::num::SignedInt;
|
||||
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
|
||||
use syntax::{abi, ast, ast_map};
|
||||
use syntax::ast_util::{mod, is_shift_binop};
|
||||
use syntax::ast_util::is_shift_binop;
|
||||
use syntax::attr::{mod, AttrMetaMethods};
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::{TyI, TyU, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
|
||||
use syntax::ast_util;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{mod, Visitor};
|
||||
|
||||
|
@ -53,6 +55,8 @@ declare_lint!(WHILE_TRUE, Warn,
|
|||
|
||||
pub struct WhileTrue;
|
||||
|
||||
impl Copy for WhileTrue {}
|
||||
|
||||
impl LintPass for WhileTrue {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(WHILE_TRUE)
|
||||
|
@ -75,6 +79,8 @@ declare_lint!(UNUSED_TYPECASTS, Allow,
|
|||
|
||||
pub struct UnusedCasts;
|
||||
|
||||
impl Copy for UnusedCasts {}
|
||||
|
||||
impl LintPass for UnusedCasts {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_TYPECASTS)
|
||||
|
@ -107,6 +113,8 @@ pub struct TypeLimits {
|
|||
negated_expr_id: ast::NodeId,
|
||||
}
|
||||
|
||||
impl Copy for TypeLimits {}
|
||||
|
||||
impl TypeLimits {
|
||||
pub fn new() -> TypeLimits {
|
||||
TypeLimits {
|
||||
|
@ -415,6 +423,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> {
|
|||
|
||||
pub struct ImproperCTypes;
|
||||
|
||||
impl Copy for ImproperCTypes {}
|
||||
|
||||
impl LintPass for ImproperCTypes {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(IMPROPER_CTYPES)
|
||||
|
@ -454,6 +464,8 @@ declare_lint!(BOX_POINTERS, Allow,
|
|||
|
||||
pub struct BoxPointers;
|
||||
|
||||
impl Copy for BoxPointers {}
|
||||
|
||||
impl BoxPointers {
|
||||
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
|
||||
span: Span, ty: Ty<'tcx>) {
|
||||
|
@ -587,6 +599,8 @@ declare_lint!(UNUSED_ATTRIBUTES, Warn,
|
|||
|
||||
pub struct UnusedAttributes;
|
||||
|
||||
impl Copy for UnusedAttributes {}
|
||||
|
||||
impl LintPass for UnusedAttributes {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_ATTRIBUTES)
|
||||
|
@ -666,6 +680,8 @@ declare_lint!(pub PATH_STATEMENTS, Warn,
|
|||
|
||||
pub struct PathStatements;
|
||||
|
||||
impl Copy for PathStatements {}
|
||||
|
||||
impl LintPass for PathStatements {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(PATH_STATEMENTS)
|
||||
|
@ -693,6 +709,8 @@ declare_lint!(pub UNUSED_RESULTS, Allow,
|
|||
|
||||
pub struct UnusedResults;
|
||||
|
||||
impl Copy for UnusedResults {}
|
||||
|
||||
impl LintPass for UnusedResults {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_MUST_USE, UNUSED_RESULTS)
|
||||
|
@ -757,6 +775,8 @@ declare_lint!(pub NON_CAMEL_CASE_TYPES, Warn,
|
|||
|
||||
pub struct NonCamelCaseTypes;
|
||||
|
||||
impl Copy for NonCamelCaseTypes {}
|
||||
|
||||
impl NonCamelCaseTypes {
|
||||
fn check_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
|
||||
fn is_camel_case(ident: ast::Ident) -> bool {
|
||||
|
@ -876,6 +896,8 @@ declare_lint!(pub NON_SNAKE_CASE, Warn,
|
|||
|
||||
pub struct NonSnakeCase;
|
||||
|
||||
impl Copy for NonSnakeCase {}
|
||||
|
||||
impl NonSnakeCase {
|
||||
fn check_snake_case(&self, cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
|
||||
fn is_snake_case(ident: ast::Ident) -> bool {
|
||||
|
@ -985,6 +1007,8 @@ declare_lint!(pub NON_UPPER_CASE_GLOBALS, Warn,
|
|||
|
||||
pub struct NonUpperCaseGlobals;
|
||||
|
||||
impl Copy for NonUpperCaseGlobals {}
|
||||
|
||||
impl LintPass for NonUpperCaseGlobals {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(NON_UPPER_CASE_GLOBALS)
|
||||
|
@ -1034,6 +1058,8 @@ declare_lint!(UNUSED_PARENS, Warn,
|
|||
|
||||
pub struct UnusedParens;
|
||||
|
||||
impl Copy for UnusedParens {}
|
||||
|
||||
impl UnusedParens {
|
||||
fn check_unused_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str,
|
||||
struct_lit_needs_parens: bool) {
|
||||
|
@ -1124,6 +1150,8 @@ declare_lint!(UNUSED_IMPORT_BRACES, Allow,
|
|||
|
||||
pub struct UnusedImportBraces;
|
||||
|
||||
impl Copy for UnusedImportBraces {}
|
||||
|
||||
impl LintPass for UnusedImportBraces {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_IMPORT_BRACES)
|
||||
|
@ -1159,6 +1187,8 @@ declare_lint!(NON_SHORTHAND_FIELD_PATTERNS, Warn,
|
|||
|
||||
pub struct NonShorthandFieldPatterns;
|
||||
|
||||
impl Copy for NonShorthandFieldPatterns {}
|
||||
|
||||
impl LintPass for NonShorthandFieldPatterns {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(NON_SHORTHAND_FIELD_PATTERNS)
|
||||
|
@ -1188,6 +1218,8 @@ declare_lint!(pub UNUSED_UNSAFE, Warn,
|
|||
|
||||
pub struct UnusedUnsafe;
|
||||
|
||||
impl Copy for UnusedUnsafe {}
|
||||
|
||||
impl LintPass for UnusedUnsafe {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_UNSAFE)
|
||||
|
@ -1209,6 +1241,8 @@ declare_lint!(UNSAFE_BLOCKS, Allow,
|
|||
|
||||
pub struct UnsafeBlocks;
|
||||
|
||||
impl Copy for UnsafeBlocks {}
|
||||
|
||||
impl LintPass for UnsafeBlocks {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNSAFE_BLOCKS)
|
||||
|
@ -1229,6 +1263,8 @@ declare_lint!(pub UNUSED_MUT, Warn,
|
|||
|
||||
pub struct UnusedMut;
|
||||
|
||||
impl Copy for UnusedMut {}
|
||||
|
||||
impl UnusedMut {
|
||||
fn check_unused_mut_pat(&self, cx: &Context, pats: &[P<ast::Pat>]) {
|
||||
// collect all mutable pattern and group their NodeIDs by their Identifier to
|
||||
|
@ -1294,6 +1330,8 @@ declare_lint!(UNUSED_ALLOCATION, Warn,
|
|||
|
||||
pub struct UnusedAllocation;
|
||||
|
||||
impl Copy for UnusedAllocation {}
|
||||
|
||||
impl LintPass for UnusedAllocation {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(UNUSED_ALLOCATION)
|
||||
|
@ -1479,6 +1517,61 @@ impl LintPass for MissingDoc {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct MissingCopyImplementations;
|
||||
|
||||
impl Copy for MissingCopyImplementations {}
|
||||
|
||||
impl LintPass for MissingCopyImplementations {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(MISSING_COPY_IMPLEMENTATIONS)
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &Context, item: &ast::Item) {
|
||||
if !cx.exported_items.contains(&item.id) {
|
||||
return
|
||||
}
|
||||
if cx.tcx
|
||||
.destructor_for_type
|
||||
.borrow()
|
||||
.contains_key(&ast_util::local_def(item.id)) {
|
||||
return
|
||||
}
|
||||
let ty = match item.node {
|
||||
ast::ItemStruct(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
return
|
||||
}
|
||||
ty::mk_struct(cx.tcx,
|
||||
ast_util::local_def(item.id),
|
||||
Substs::empty())
|
||||
}
|
||||
ast::ItemEnum(_, ref ast_generics) => {
|
||||
if ast_generics.is_parameterized() {
|
||||
return
|
||||
}
|
||||
ty::mk_enum(cx.tcx,
|
||||
ast_util::local_def(item.id),
|
||||
Substs::empty())
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
let parameter_environment = ty::empty_parameter_environment();
|
||||
if !ty::type_moves_by_default(cx.tcx,
|
||||
ty,
|
||||
¶meter_environment) {
|
||||
return
|
||||
}
|
||||
if ty::can_type_implement_copy(cx.tcx,
|
||||
ty,
|
||||
¶meter_environment).is_ok() {
|
||||
cx.span_lint(MISSING_COPY_IMPLEMENTATIONS,
|
||||
item.span,
|
||||
"type could implement `Copy`; consider adding `impl \
|
||||
Copy`")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare_lint!(DEPRECATED, Warn,
|
||||
"detects use of #[deprecated] items")
|
||||
|
||||
|
@ -1493,6 +1586,8 @@ declare_lint!(UNSTABLE, Allow,
|
|||
/// `#[unstable]` attributes, or no stability attribute.
|
||||
pub struct Stability;
|
||||
|
||||
impl Copy for Stability {}
|
||||
|
||||
impl Stability {
|
||||
fn lint(&self, cx: &Context, id: ast::DefId, span: Span) {
|
||||
let stability = stability::lookup(cx.tcx, id);
|
||||
|
@ -1682,10 +1777,15 @@ declare_lint!(pub VARIANT_SIZE_DIFFERENCES, Allow,
|
|||
declare_lint!(pub FAT_PTR_TRANSMUTES, Allow,
|
||||
"detects transmutes of fat pointers")
|
||||
|
||||
declare_lint!(pub MISSING_COPY_IMPLEMENTATIONS, Warn,
|
||||
"detects potentially-forgotten implementations of `Copy`")
|
||||
|
||||
/// Does nothing as a lint pass, but registers some `Lint`s
|
||||
/// which are used by other parts of the compiler.
|
||||
pub struct HardwiredLints;
|
||||
|
||||
impl Copy for HardwiredLints {}
|
||||
|
||||
impl LintPass for HardwiredLints {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(
|
||||
|
|
|
@ -204,6 +204,7 @@ impl LintStore {
|
|||
UnusedMut,
|
||||
UnusedAllocation,
|
||||
Stability,
|
||||
MissingCopyImplementations,
|
||||
)
|
||||
|
||||
add_builtin_with_new!(sess,
|
||||
|
|
|
@ -64,6 +64,8 @@ pub struct Lint {
|
|||
pub desc: &'static str,
|
||||
}
|
||||
|
||||
impl Copy for Lint {}
|
||||
|
||||
impl Lint {
|
||||
/// Get the lint's name, with ASCII letters converted to lowercase.
|
||||
pub fn name_lower(&self) -> String {
|
||||
|
@ -179,6 +181,8 @@ pub struct LintId {
|
|||
lint: &'static Lint,
|
||||
}
|
||||
|
||||
impl Copy for LintId {}
|
||||
|
||||
impl PartialEq for LintId {
|
||||
fn eq(&self, other: &LintId) -> bool {
|
||||
(self.lint as *const Lint) == (other.lint as *const Lint)
|
||||
|
@ -214,6 +218,8 @@ pub enum Level {
|
|||
Allow, Warn, Deny, Forbid
|
||||
}
|
||||
|
||||
impl Copy for Level {}
|
||||
|
||||
impl Level {
|
||||
/// Convert a level to a lower-case string.
|
||||
pub fn as_str(self) -> &'static str {
|
||||
|
@ -251,6 +257,8 @@ pub enum LintSource {
|
|||
CommandLine,
|
||||
}
|
||||
|
||||
impl Copy for LintSource {}
|
||||
|
||||
pub type LevelSource = (Level, LintSource);
|
||||
|
||||
pub mod builtin;
|
||||
|
|
|
@ -144,6 +144,8 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
|
|||
tag_table_capture_modes = 0x56,
|
||||
tag_table_object_cast_map = 0x57,
|
||||
}
|
||||
|
||||
impl Copy for astencode_tag {}
|
||||
static first_astencode_tag: uint = tag_ast as uint;
|
||||
static last_astencode_tag: uint = tag_table_object_cast_map as uint;
|
||||
impl astencode_tag {
|
||||
|
|
|
@ -275,8 +275,10 @@ fn visit_item(e: &Env, i: &ast::Item) {
|
|||
}
|
||||
}
|
||||
|
||||
fn register_native_lib(sess: &Session, span: Option<Span>, name: String,
|
||||
kind: cstore::NativeLibaryKind) {
|
||||
fn register_native_lib(sess: &Session,
|
||||
span: Option<Span>,
|
||||
name: String,
|
||||
kind: cstore::NativeLibraryKind) {
|
||||
if name.is_empty() {
|
||||
match span {
|
||||
Some(span) => {
|
||||
|
|
|
@ -40,6 +40,8 @@ pub struct MethodInfo {
|
|||
pub vis: ast::Visibility,
|
||||
}
|
||||
|
||||
impl Copy for MethodInfo {}
|
||||
|
||||
pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> String {
|
||||
let cdata = cstore.get_crate_data(def.krate);
|
||||
decoder::get_symbol(cdata.data(), def.node)
|
||||
|
@ -273,9 +275,8 @@ pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
decoder::get_impl_vtables(&*cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
pub fn get_native_libraries(cstore: &cstore::CStore,
|
||||
crate_num: ast::CrateNum)
|
||||
-> Vec<(cstore::NativeLibaryKind, String)> {
|
||||
pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
|
||||
-> Vec<(cstore::NativeLibraryKind, String)> {
|
||||
let cdata = cstore.get_crate_data(crate_num);
|
||||
decoder::get_native_libraries(&*cdata)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
pub use self::MetadataBlob::*;
|
||||
pub use self::LinkagePreference::*;
|
||||
pub use self::NativeLibaryKind::*;
|
||||
pub use self::NativeLibraryKind::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use metadata::decoder;
|
||||
|
@ -54,13 +54,17 @@ pub enum LinkagePreference {
|
|||
RequireStatic,
|
||||
}
|
||||
|
||||
#[deriving(PartialEq, FromPrimitive, Clone)]
|
||||
pub enum NativeLibaryKind {
|
||||
impl Copy for LinkagePreference {}
|
||||
|
||||
#[deriving(Clone, PartialEq, FromPrimitive)]
|
||||
pub enum NativeLibraryKind {
|
||||
NativeStatic, // native static library (.a archive)
|
||||
NativeFramework, // OSX-specific
|
||||
NativeUnknown, // default way to specify a dynamic library
|
||||
}
|
||||
|
||||
impl Copy for NativeLibraryKind {}
|
||||
|
||||
// Where a crate came from on the local filesystem. One of these two options
|
||||
// must be non-None.
|
||||
#[deriving(PartialEq, Clone)]
|
||||
|
@ -75,7 +79,7 @@ pub struct CStore {
|
|||
/// Map from NodeId's of local extern crate statements to crate numbers
|
||||
extern_mod_crate_map: RefCell<NodeMap<ast::CrateNum>>,
|
||||
used_crate_sources: RefCell<Vec<CrateSource>>,
|
||||
used_libraries: RefCell<Vec<(String, NativeLibaryKind)>>,
|
||||
used_libraries: RefCell<Vec<(String, NativeLibraryKind)>>,
|
||||
used_link_args: RefCell<Vec<String>>,
|
||||
pub intr: Rc<IdentInterner>,
|
||||
}
|
||||
|
@ -186,13 +190,14 @@ impl CStore {
|
|||
libs
|
||||
}
|
||||
|
||||
pub fn add_used_library(&self, lib: String, kind: NativeLibaryKind) {
|
||||
pub fn add_used_library(&self, lib: String, kind: NativeLibraryKind) {
|
||||
assert!(!lib.is_empty());
|
||||
self.used_libraries.borrow_mut().push((lib, kind));
|
||||
}
|
||||
|
||||
pub fn get_used_libraries<'a>(&'a self)
|
||||
-> &'a RefCell<Vec<(String, NativeLibaryKind)> > {
|
||||
-> &'a RefCell<Vec<(String,
|
||||
NativeLibraryKind)>> {
|
||||
&self.used_libraries
|
||||
}
|
||||
|
||||
|
|
|
@ -442,6 +442,8 @@ pub enum DefLike {
|
|||
DlField
|
||||
}
|
||||
|
||||
impl Copy for DefLike {}
|
||||
|
||||
/// Iterates over the language items in the given crate.
|
||||
pub fn each_lang_item(cdata: Cmd, f: |ast::NodeId, uint| -> bool) -> bool {
|
||||
let root = rbml::Doc::new(cdata.data());
|
||||
|
@ -1267,14 +1269,14 @@ pub fn get_trait_of_item(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
|
|||
|
||||
|
||||
pub fn get_native_libraries(cdata: Cmd)
|
||||
-> Vec<(cstore::NativeLibaryKind, String)> {
|
||||
-> Vec<(cstore::NativeLibraryKind, String)> {
|
||||
let libraries = reader::get_doc(rbml::Doc::new(cdata.data()),
|
||||
tag_native_libraries);
|
||||
let mut result = Vec::new();
|
||||
reader::tagged_docs(libraries, tag_native_libraries_lib, |lib_doc| {
|
||||
let kind_doc = reader::get_doc(lib_doc, tag_native_libraries_kind);
|
||||
let name_doc = reader::get_doc(lib_doc, tag_native_libraries_name);
|
||||
let kind: cstore::NativeLibaryKind =
|
||||
let kind: cstore::NativeLibraryKind =
|
||||
FromPrimitive::from_u32(reader::doc_as_u32(kind_doc)).unwrap();
|
||||
let name = name_doc.as_str().to_string();
|
||||
result.push((kind, name));
|
||||
|
|
|
@ -20,7 +20,12 @@ use std::os;
|
|||
|
||||
use util::fs as myfs;
|
||||
|
||||
pub enum FileMatch { FileMatches, FileDoesntMatch }
|
||||
pub enum FileMatch {
|
||||
FileMatches,
|
||||
FileDoesntMatch,
|
||||
}
|
||||
|
||||
impl Copy for FileMatch {}
|
||||
|
||||
// A module for searching for libraries
|
||||
// FIXME (#2658): I'm not happy how this module turned out. Should
|
||||
|
|
|
@ -61,6 +61,8 @@ pub enum DefIdSource {
|
|||
// Identifies an unboxed closure
|
||||
UnboxedClosureSource
|
||||
}
|
||||
|
||||
impl Copy for DefIdSource {}
|
||||
pub type conv_did<'a> =
|
||||
|source: DefIdSource, ast::DefId|: 'a -> ast::DefId;
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@ use middle::borrowck::LoanPathKind::*;
|
|||
use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::region;
|
||||
use middle::ty::ParameterEnvironment;
|
||||
use middle::ty;
|
||||
use syntax::ast::NodeId;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use util::ppaux::Repr;
|
||||
|
@ -89,6 +91,7 @@ struct CheckLoanCtxt<'a, 'tcx: 'a> {
|
|||
dfcx_loans: &'a LoanDataFlow<'a, 'tcx>,
|
||||
move_data: move_data::FlowedMoveData<'a, 'tcx>,
|
||||
all_loans: &'a [Loan<'tcx>],
|
||||
param_env: &'a ParameterEnvironment<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
|
||||
|
@ -193,19 +196,25 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
dfcx_loans: &LoanDataFlow<'b, 'tcx>,
|
||||
move_data: move_data::FlowedMoveData<'c, 'tcx>,
|
||||
all_loans: &[Loan<'tcx>],
|
||||
fn_id: NodeId,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block) {
|
||||
debug!("check_loans(body id={})", body.id);
|
||||
|
||||
let param_env = ParameterEnvironment::for_item(bccx.tcx, fn_id);
|
||||
|
||||
let mut clcx = CheckLoanCtxt {
|
||||
bccx: bccx,
|
||||
dfcx_loans: dfcx_loans,
|
||||
move_data: move_data,
|
||||
all_loans: all_loans,
|
||||
param_env: ¶m_env,
|
||||
};
|
||||
|
||||
{
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut clcx, bccx.tcx);
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut clcx,
|
||||
bccx.tcx,
|
||||
param_env.clone());
|
||||
euv.walk_fn(decl, body);
|
||||
}
|
||||
}
|
||||
|
@ -700,7 +709,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
use_kind,
|
||||
&**lp,
|
||||
the_move,
|
||||
moved_lp);
|
||||
moved_lp,
|
||||
self.param_env);
|
||||
false
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ use middle::borrowck::move_data::MoveData;
|
|||
use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::region;
|
||||
use middle::ty::ParameterEnvironment;
|
||||
use middle::ty;
|
||||
use util::ppaux::{Repr};
|
||||
|
||||
|
@ -37,10 +38,11 @@ mod gather_moves;
|
|||
mod move_error;
|
||||
|
||||
pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
fn_id: NodeId,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block)
|
||||
-> (Vec<Loan<'tcx>>, move_data::MoveData<'tcx>)
|
||||
{
|
||||
-> (Vec<Loan<'tcx>>,
|
||||
move_data::MoveData<'tcx>) {
|
||||
let mut glcx = GatherLoanCtxt {
|
||||
bccx: bccx,
|
||||
all_loans: Vec::new(),
|
||||
|
@ -49,8 +51,12 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
|||
move_error_collector: move_error::MoveErrorCollector::new(),
|
||||
};
|
||||
|
||||
let param_env = ParameterEnvironment::for_item(bccx.tcx, fn_id);
|
||||
|
||||
{
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut glcx, bccx.tcx);
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut glcx,
|
||||
bccx.tcx,
|
||||
param_env);
|
||||
euv.walk_fn(decl, body);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ pub enum Variant {
|
|||
Assigns,
|
||||
}
|
||||
|
||||
impl Copy for Variant {}
|
||||
|
||||
impl Variant {
|
||||
pub fn short_name(&self) -> &'static str {
|
||||
match *self {
|
||||
|
|
|
@ -25,7 +25,7 @@ use middle::dataflow::DataFlowOperator;
|
|||
use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::region;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::ty::{mod, ParameterEnvironment, Ty};
|
||||
use util::ppaux::{note_and_explain_region, Repr, UserString};
|
||||
|
||||
use std::rc::Rc;
|
||||
|
@ -62,6 +62,8 @@ pub mod move_data;
|
|||
#[deriving(Clone)]
|
||||
pub struct LoanDataFlowOperator;
|
||||
|
||||
impl Copy for LoanDataFlowOperator {}
|
||||
|
||||
pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator>;
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
|
||||
|
@ -146,8 +148,13 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
|
|||
move_data::fragments::instrument_move_fragments(&flowed_moves.move_data,
|
||||
this.tcx, sp, id);
|
||||
|
||||
check_loans::check_loans(this, &loan_dfcx, flowed_moves,
|
||||
all_loans.as_slice(), decl, body);
|
||||
check_loans::check_loans(this,
|
||||
&loan_dfcx,
|
||||
flowed_moves,
|
||||
all_loans.as_slice(),
|
||||
id,
|
||||
decl,
|
||||
body);
|
||||
|
||||
visit::walk_fn(this, fk, decl, body, sp);
|
||||
}
|
||||
|
@ -162,7 +169,7 @@ fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
|||
// Check the body of fn items.
|
||||
let id_range = ast_util::compute_id_range_for_fn_body(fk, decl, body, sp, id);
|
||||
let (all_loans, move_data) =
|
||||
gather_loans::gather_loans_in_fn(this, decl, body);
|
||||
gather_loans::gather_loans_in_fn(this, id, decl, body);
|
||||
|
||||
let mut loan_dfcx =
|
||||
DataFlowContext::new(this.tcx,
|
||||
|
@ -339,6 +346,8 @@ pub enum LoanPathElem {
|
|||
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
|
||||
}
|
||||
|
||||
impl Copy for LoanPathElem {}
|
||||
|
||||
pub fn closure_to_block(closure_id: ast::NodeId,
|
||||
tcx: &ty::ctxt) -> ast::NodeId {
|
||||
match tcx.map.get(closure_id) {
|
||||
|
@ -484,6 +493,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option<Rc<LoanPath<'tcx>>> {
|
|||
|
||||
// Errors that can occur
|
||||
#[deriving(PartialEq)]
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum bckerr_code {
|
||||
err_mutbl,
|
||||
err_out_of_scope(ty::Region, ty::Region), // superscope, subscope
|
||||
|
@ -505,12 +515,16 @@ pub enum AliasableViolationKind {
|
|||
BorrowViolation(euv::LoanCause)
|
||||
}
|
||||
|
||||
impl Copy for AliasableViolationKind {}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub enum MovedValueUseKind {
|
||||
MovedInUse,
|
||||
MovedInCapture,
|
||||
}
|
||||
|
||||
impl Copy for MovedValueUseKind {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Misc
|
||||
|
||||
|
@ -545,7 +559,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
use_kind: MovedValueUseKind,
|
||||
lp: &LoanPath<'tcx>,
|
||||
the_move: &move_data::Move,
|
||||
moved_lp: &LoanPath<'tcx>) {
|
||||
moved_lp: &LoanPath<'tcx>,
|
||||
param_env: &ParameterEnvironment<'tcx>) {
|
||||
let verb = match use_kind {
|
||||
MovedInUse => "use",
|
||||
MovedInCapture => "capture",
|
||||
|
@ -621,7 +636,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
r).as_slice())
|
||||
}
|
||||
};
|
||||
let (suggestion, _) = move_suggestion(self.tcx, expr_ty,
|
||||
let (suggestion, _) = move_suggestion(self.tcx, param_env, expr_ty,
|
||||
("moved by default", ""));
|
||||
self.tcx.sess.span_note(
|
||||
expr_span,
|
||||
|
@ -659,7 +674,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
r).as_slice())
|
||||
}
|
||||
};
|
||||
let (suggestion, help) = move_suggestion(self.tcx, expr_ty,
|
||||
let (suggestion, help) = move_suggestion(self.tcx,
|
||||
param_env,
|
||||
expr_ty,
|
||||
("moved by default", "make a copy and \
|
||||
capture that instead to override"));
|
||||
self.tcx.sess.span_note(
|
||||
|
@ -674,7 +691,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn move_suggestion<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>,
|
||||
fn move_suggestion<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
param_env: &ty::ParameterEnvironment<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
default_msgs: (&'static str, &'static str))
|
||||
-> (&'static str, &'static str) {
|
||||
match ty.sty {
|
||||
|
@ -684,7 +703,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
|||
}) =>
|
||||
("a non-copyable stack closure",
|
||||
"capture it in a new closure, e.g. `|x| f(x)`, to override"),
|
||||
_ if ty::type_moves_by_default(tcx, ty) =>
|
||||
_ if ty::type_moves_by_default(tcx, ty, param_env) =>
|
||||
("non-copyable",
|
||||
"perhaps you meant to use `clone()`?"),
|
||||
_ => default_msgs,
|
||||
|
|
|
@ -81,6 +81,8 @@ pub struct FlowedMoveData<'a, 'tcx: 'a> {
|
|||
#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)]
|
||||
pub struct MovePathIndex(uint);
|
||||
|
||||
impl Copy for MovePathIndex {}
|
||||
|
||||
impl MovePathIndex {
|
||||
fn get(&self) -> uint {
|
||||
let MovePathIndex(v) = *self; v
|
||||
|
@ -101,6 +103,8 @@ static InvalidMovePathIndex: MovePathIndex =
|
|||
#[deriving(PartialEq)]
|
||||
pub struct MoveIndex(uint);
|
||||
|
||||
impl Copy for MoveIndex {}
|
||||
|
||||
impl MoveIndex {
|
||||
fn get(&self) -> uint {
|
||||
let MoveIndex(v) = *self; v
|
||||
|
@ -138,6 +142,8 @@ pub enum MoveKind {
|
|||
Captured // Closure creation that moves a value
|
||||
}
|
||||
|
||||
impl Copy for MoveKind {}
|
||||
|
||||
pub struct Move {
|
||||
/// Path being moved.
|
||||
pub path: MovePathIndex,
|
||||
|
@ -152,6 +158,8 @@ pub struct Move {
|
|||
pub next_move: MoveIndex
|
||||
}
|
||||
|
||||
impl Copy for Move {}
|
||||
|
||||
pub struct Assignment {
|
||||
/// Path being assigned.
|
||||
pub path: MovePathIndex,
|
||||
|
@ -163,6 +171,8 @@ pub struct Assignment {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Copy for Assignment {}
|
||||
|
||||
pub struct VariantMatch {
|
||||
/// downcast to the variant.
|
||||
pub path: MovePathIndex,
|
||||
|
@ -177,14 +187,20 @@ pub struct VariantMatch {
|
|||
pub mode: euv::MatchMode
|
||||
}
|
||||
|
||||
impl Copy for VariantMatch {}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct MoveDataFlowOperator;
|
||||
|
||||
impl Copy for MoveDataFlowOperator {}
|
||||
|
||||
pub type MoveDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, MoveDataFlowOperator>;
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct AssignDataFlowOperator;
|
||||
|
||||
impl Copy for AssignDataFlowOperator {}
|
||||
|
||||
pub type AssignDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, AssignDataFlowOperator>;
|
||||
|
||||
fn loan_path_is_precise(loan_path: &LoanPath) -> bool {
|
||||
|
|
|
@ -32,6 +32,8 @@ struct LoopScope {
|
|||
break_index: CFGIndex, // where to go on a `break
|
||||
}
|
||||
|
||||
impl Copy for LoopScope {}
|
||||
|
||||
pub fn construct(tcx: &ty::ctxt,
|
||||
blk: &ast::Block) -> CFG {
|
||||
let mut graph = graph::Graph::new();
|
||||
|
|
|
@ -30,6 +30,8 @@ pub struct CFGNodeData {
|
|||
pub id: ast::NodeId
|
||||
}
|
||||
|
||||
impl Copy for CFGNodeData {}
|
||||
|
||||
pub struct CFGEdgeData {
|
||||
pub exiting_scopes: Vec<ast::NodeId>
|
||||
}
|
||||
|
|
|
@ -21,11 +21,15 @@ enum Context {
|
|||
Normal, Loop, Closure
|
||||
}
|
||||
|
||||
impl Copy for Context {}
|
||||
|
||||
struct CheckLoopVisitor<'a> {
|
||||
sess: &'a Session,
|
||||
cx: Context
|
||||
}
|
||||
|
||||
impl<'a> Copy for CheckLoopVisitor<'a> {}
|
||||
|
||||
pub fn check_crate(sess: &Session, krate: &ast::Crate) {
|
||||
visit::walk_crate(&mut CheckLoopVisitor { sess: sess, cx: Normal }, krate)
|
||||
}
|
||||
|
|
|
@ -99,7 +99,8 @@ impl<'a> FromIterator<Vec<&'a Pat>> for Matrix<'a> {
|
|||
}
|
||||
|
||||
pub struct MatchCheckCtxt<'a, 'tcx: 'a> {
|
||||
pub tcx: &'a ty::ctxt<'tcx>
|
||||
pub tcx: &'a ty::ctxt<'tcx>,
|
||||
pub param_env: ParameterEnvironment<'tcx>,
|
||||
}
|
||||
|
||||
#[deriving(Clone, PartialEq)]
|
||||
|
@ -131,6 +132,8 @@ enum WitnessPreference {
|
|||
LeaveOutWitness
|
||||
}
|
||||
|
||||
impl Copy for WitnessPreference {}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &ast::Expr) {
|
||||
check_expr(self, ex);
|
||||
|
@ -145,7 +148,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn check_crate(tcx: &ty::ctxt) {
|
||||
visit::walk_crate(&mut MatchCheckCtxt { tcx: tcx }, tcx.map.krate());
|
||||
visit::walk_crate(&mut MatchCheckCtxt {
|
||||
tcx: tcx,
|
||||
param_env: ty::empty_parameter_environment(),
|
||||
}, tcx.map.krate());
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
|
@ -954,8 +960,14 @@ fn check_fn(cx: &mut MatchCheckCtxt,
|
|||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
sp: Span,
|
||||
_: NodeId) {
|
||||
fn_id: NodeId) {
|
||||
match kind {
|
||||
visit::FkFnBlock => {}
|
||||
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
|
||||
}
|
||||
|
||||
visit::walk_fn(cx, kind, decl, body, sp);
|
||||
|
||||
for input in decl.inputs.iter() {
|
||||
is_refutable(cx, &*input.pat, |pat| {
|
||||
span_err!(cx.tcx.sess, input.pat.span, E0006,
|
||||
|
@ -1020,7 +1032,9 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
|
|||
match p.node {
|
||||
ast::PatIdent(ast::BindByValue(_), _, ref sub) => {
|
||||
let pat_ty = ty::node_id_to_type(tcx, p.id);
|
||||
if ty::type_moves_by_default(tcx, pat_ty) {
|
||||
if ty::type_moves_by_default(tcx,
|
||||
pat_ty,
|
||||
&cx.param_env) {
|
||||
check_move(p, sub.as_ref().map(|p| &**p));
|
||||
}
|
||||
}
|
||||
|
@ -1048,7 +1062,9 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
|
|||
let mut checker = MutationChecker {
|
||||
cx: cx,
|
||||
};
|
||||
let mut visitor = ExprUseVisitor::new(&mut checker, checker.cx.tcx);
|
||||
let mut visitor = ExprUseVisitor::new(&mut checker,
|
||||
checker.cx.tcx,
|
||||
cx.param_env.clone());
|
||||
visitor.walk_expr(guard);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
use middle::expr_use_visitor as euv;
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::ty::ParameterEnvironment;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_string;
|
||||
|
||||
|
@ -36,9 +37,10 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
|||
fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block,
|
||||
s: Span,
|
||||
_: ast::NodeId) {
|
||||
fn_id: ast::NodeId) {
|
||||
{
|
||||
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
|
||||
let param_env = ParameterEnvironment::for_item(self.tcx, fn_id);
|
||||
let mut euv = euv::ExprUseVisitor::new(self, self.tcx, param_env);
|
||||
euv.walk_fn(fd, b);
|
||||
}
|
||||
visit::walk_fn(self, fk, fd, b, s)
|
||||
|
|
|
@ -47,13 +47,16 @@ enum Mode {
|
|||
InNothing,
|
||||
}
|
||||
|
||||
impl Copy for Mode {}
|
||||
|
||||
struct CheckStaticVisitor<'a, 'tcx: 'a> {
|
||||
tcx: &'a ty::ctxt<'tcx>,
|
||||
mode: Mode,
|
||||
checker: &'a mut GlobalChecker,
|
||||
}
|
||||
|
||||
struct GlobalVisitor<'a, 'b, 'tcx: 'b>(euv::ExprUseVisitor<'a, 'b, 'tcx, ty::ctxt<'tcx>>);
|
||||
struct GlobalVisitor<'a,'b,'tcx:'a+'b>(
|
||||
euv::ExprUseVisitor<'a,'b,'tcx,ty::ctxt<'tcx>>);
|
||||
struct GlobalChecker {
|
||||
static_consumptions: NodeSet,
|
||||
const_borrows: NodeSet,
|
||||
|
@ -69,7 +72,8 @@ pub fn check_crate(tcx: &ty::ctxt) {
|
|||
static_local_borrows: NodeSet::new(),
|
||||
};
|
||||
{
|
||||
let visitor = euv::ExprUseVisitor::new(&mut checker, tcx);
|
||||
let param_env = ty::empty_parameter_environment();
|
||||
let visitor = euv::ExprUseVisitor::new(&mut checker, tcx, param_env);
|
||||
visit::walk_crate(&mut GlobalVisitor(visitor), tcx.map.krate());
|
||||
}
|
||||
visit::walk_crate(&mut CheckStaticVisitor {
|
||||
|
@ -242,7 +246,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 't, 'v> Visitor<'v> for GlobalVisitor<'a, 'b, 't> {
|
||||
impl<'a,'b,'t,'v> Visitor<'v> for GlobalVisitor<'a,'b,'t> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
match item.node {
|
||||
ast::ItemConst(_, ref e) |
|
||||
|
|
|
@ -68,6 +68,8 @@ pub enum constness {
|
|||
non_const
|
||||
}
|
||||
|
||||
impl Copy for constness {}
|
||||
|
||||
type constness_cache = DefIdMap<constness>;
|
||||
|
||||
pub fn join(a: constness, b: constness) -> constness {
|
||||
|
|
|
@ -28,7 +28,12 @@ use syntax::print::{pp, pprust};
|
|||
use util::nodemap::NodeMap;
|
||||
|
||||
#[deriving(Show)]
|
||||
pub enum EntryOrExit { Entry, Exit }
|
||||
pub enum EntryOrExit {
|
||||
Entry,
|
||||
Exit,
|
||||
}
|
||||
|
||||
impl Copy for EntryOrExit {}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct DataFlowContext<'a, 'tcx: 'a, O> {
|
||||
|
|
|
@ -52,6 +52,8 @@ pub enum Def {
|
|||
DefMethod(ast::DefId /* method */, Option<ast::DefId> /* trait */, MethodProvenance),
|
||||
}
|
||||
|
||||
impl Copy for Def {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
|
||||
pub enum MethodProvenance {
|
||||
FromTrait(ast::DefId),
|
||||
|
@ -67,6 +69,8 @@ impl MethodProvenance {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for MethodProvenance {}
|
||||
|
||||
impl Def {
|
||||
pub fn def_id(&self) -> ast::DefId {
|
||||
match *self {
|
||||
|
|
|
@ -30,6 +30,8 @@ enum UnsafeContext {
|
|||
UnsafeBlock(ast::NodeId),
|
||||
}
|
||||
|
||||
impl Copy for UnsafeContext {}
|
||||
|
||||
fn type_is_unsafe_function(ty: Ty) -> bool {
|
||||
match ty.sty {
|
||||
ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
|
||||
|
|
|
@ -23,12 +23,13 @@ use self::OverloadedCallType::*;
|
|||
use middle::{def, region, pat_util};
|
||||
use middle::mem_categorization as mc;
|
||||
use middle::mem_categorization::Typer;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::ty::{mod, ParameterEnvironment, Ty};
|
||||
use middle::ty::{MethodCall, MethodObject, MethodTraitObject};
|
||||
use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam};
|
||||
use middle::ty::{MethodStatic, MethodStaticUnboxedClosure};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::kinds;
|
||||
use syntax::ast;
|
||||
use syntax::ptr::P;
|
||||
use syntax::codemap::Span;
|
||||
|
@ -106,12 +107,16 @@ pub enum LoanCause {
|
|||
MatchDiscriminant
|
||||
}
|
||||
|
||||
impl kinds::Copy for LoanCause {}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
pub enum ConsumeMode {
|
||||
Copy, // reference to x where x has a type that copies
|
||||
Move(MoveReason), // reference to x where x has a type that moves
|
||||
}
|
||||
|
||||
impl kinds::Copy for ConsumeMode {}
|
||||
|
||||
#[deriving(PartialEq,Show)]
|
||||
pub enum MoveReason {
|
||||
DirectRefMove,
|
||||
|
@ -119,6 +124,8 @@ pub enum MoveReason {
|
|||
CaptureMove,
|
||||
}
|
||||
|
||||
impl kinds::Copy for MoveReason {}
|
||||
|
||||
#[deriving(PartialEq,Show)]
|
||||
pub enum MatchMode {
|
||||
NonBindingMatch,
|
||||
|
@ -127,11 +134,17 @@ pub enum MatchMode {
|
|||
MovingMatch,
|
||||
}
|
||||
|
||||
impl kinds::Copy for MatchMode {}
|
||||
|
||||
#[deriving(PartialEq,Show)]
|
||||
enum TrackMatchMode<T> {
|
||||
Unknown, Definite(MatchMode), Conflicting,
|
||||
Unknown,
|
||||
Definite(MatchMode),
|
||||
Conflicting,
|
||||
}
|
||||
|
||||
impl<T> kinds::Copy for TrackMatchMode<T> {}
|
||||
|
||||
impl<T> TrackMatchMode<T> {
|
||||
// Builds up the whole match mode for a pattern from its constituent
|
||||
// parts. The lattice looks like this:
|
||||
|
@ -199,12 +212,16 @@ pub enum MutateMode {
|
|||
WriteAndRead, // x += y
|
||||
}
|
||||
|
||||
impl kinds::Copy for MutateMode {}
|
||||
|
||||
enum OverloadedCallType {
|
||||
FnOverloadedCall,
|
||||
FnMutOverloadedCall,
|
||||
FnOnceOverloadedCall,
|
||||
}
|
||||
|
||||
impl kinds::Copy for OverloadedCallType {}
|
||||
|
||||
impl OverloadedCallType {
|
||||
fn from_trait_id(tcx: &ty::ctxt, trait_id: ast::DefId)
|
||||
-> OverloadedCallType {
|
||||
|
@ -293,6 +310,7 @@ pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> {
|
|||
typer: &'t TYPER,
|
||||
mc: mc::MemCategorizationContext<'t,TYPER>,
|
||||
delegate: &'d mut (Delegate<'tcx>+'d),
|
||||
param_env: ParameterEnvironment<'tcx>,
|
||||
}
|
||||
|
||||
// If the TYPER results in an error, it's because the type check
|
||||
|
@ -313,11 +331,15 @@ macro_rules! return_if_err(
|
|||
|
||||
impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
pub fn new(delegate: &'d mut Delegate<'tcx>,
|
||||
typer: &'t TYPER)
|
||||
typer: &'t TYPER,
|
||||
param_env: ParameterEnvironment<'tcx>)
|
||||
-> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
||||
ExprUseVisitor { typer: typer,
|
||||
mc: mc::MemCategorizationContext::new(typer),
|
||||
delegate: delegate }
|
||||
ExprUseVisitor {
|
||||
typer: typer,
|
||||
mc: mc::MemCategorizationContext::new(typer),
|
||||
delegate: delegate,
|
||||
param_env: param_env,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn(&mut self,
|
||||
|
@ -352,7 +374,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
consume_id: ast::NodeId,
|
||||
consume_span: Span,
|
||||
cmt: mc::cmt<'tcx>) {
|
||||
let mode = copy_or_move(self.tcx(), cmt.ty, DirectRefMove);
|
||||
let mode = copy_or_move(self.tcx(),
|
||||
cmt.ty,
|
||||
&self.param_env,
|
||||
DirectRefMove);
|
||||
self.delegate.consume(consume_id, consume_span, cmt, mode);
|
||||
}
|
||||
|
||||
|
@ -954,7 +979,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
ast::PatIdent(ast::BindByRef(_), _, _) =>
|
||||
mode.lub(BorrowingMatch),
|
||||
ast::PatIdent(ast::BindByValue(_), _, _) => {
|
||||
match copy_or_move(tcx, cmt_pat.ty, PatBindingMove) {
|
||||
match copy_or_move(tcx,
|
||||
cmt_pat.ty,
|
||||
&self.param_env,
|
||||
PatBindingMove) {
|
||||
Copy => mode.lub(CopyingMatch),
|
||||
Move(_) => mode.lub(MovingMatch),
|
||||
}
|
||||
|
@ -984,7 +1012,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
let tcx = typer.tcx();
|
||||
let def_map = &self.typer.tcx().def_map;
|
||||
let delegate = &mut self.delegate;
|
||||
|
||||
let param_env = &mut self.param_env;
|
||||
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
|
||||
if pat_util::pat_is_binding(def_map, pat) {
|
||||
let tcx = typer.tcx();
|
||||
|
@ -1018,7 +1046,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
r, bk, RefBinding);
|
||||
}
|
||||
ast::PatIdent(ast::BindByValue(_), _, _) => {
|
||||
let mode = copy_or_move(typer.tcx(), cmt_pat.ty, PatBindingMove);
|
||||
let mode = copy_or_move(typer.tcx(),
|
||||
cmt_pat.ty,
|
||||
param_env,
|
||||
PatBindingMove);
|
||||
debug!("walk_pat binding consuming pat");
|
||||
delegate.consume_pat(pat, cmt_pat, mode);
|
||||
}
|
||||
|
@ -1211,7 +1242,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
let cmt_var = return_if_err!(self.cat_captured_var(closure_expr.id,
|
||||
closure_expr.span,
|
||||
freevar.def));
|
||||
let mode = copy_or_move(self.tcx(), cmt_var.ty, CaptureMove);
|
||||
let mode = copy_or_move(self.tcx(),
|
||||
cmt_var.ty,
|
||||
&self.param_env,
|
||||
CaptureMove);
|
||||
self.delegate.consume(closure_expr.id, freevar.span, cmt_var, mode);
|
||||
}
|
||||
}
|
||||
|
@ -1229,8 +1263,15 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
|
|||
}
|
||||
}
|
||||
|
||||
fn copy_or_move<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>,
|
||||
move_reason: MoveReason) -> ConsumeMode {
|
||||
if ty::type_moves_by_default(tcx, ty) { Move(move_reason) } else { Copy }
|
||||
fn copy_or_move<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
param_env: &ParameterEnvironment<'tcx>,
|
||||
move_reason: MoveReason)
|
||||
-> ConsumeMode {
|
||||
if ty::type_moves_by_default(tcx, ty, param_env) {
|
||||
Move(move_reason)
|
||||
} else {
|
||||
Copy
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ pub enum SimplifiedType {
|
|||
ParameterSimplifiedType,
|
||||
}
|
||||
|
||||
impl Copy for SimplifiedType {}
|
||||
|
||||
/// Tries to simplify a type by dropping type parameters, deref'ing away any reference types, etc.
|
||||
/// The idea is to get something simple that we can use to quickly decide if two types could unify
|
||||
/// during method lookup.
|
||||
|
|
|
@ -65,11 +65,15 @@ pub struct NodeIndex(pub uint);
|
|||
#[allow(non_upper_case_globals)]
|
||||
pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX);
|
||||
|
||||
impl Copy for NodeIndex {}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
pub struct EdgeIndex(pub uint);
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX);
|
||||
|
||||
impl Copy for EdgeIndex {}
|
||||
|
||||
// Use a private field here to guarantee no more instances are created:
|
||||
#[deriving(Show)]
|
||||
pub struct Direction { repr: uint }
|
||||
|
@ -78,6 +82,8 @@ pub const Outgoing: Direction = Direction { repr: 0 };
|
|||
#[allow(non_upper_case_globals)]
|
||||
pub const Incoming: Direction = Direction { repr: 1 };
|
||||
|
||||
impl Copy for Direction {}
|
||||
|
||||
impl NodeIndex {
|
||||
fn get(&self) -> uint { let NodeIndex(v) = *self; v }
|
||||
/// Returns unique id (unique with respect to the graph holding associated node).
|
||||
|
|
|
@ -132,6 +132,8 @@ pub enum TypeOrigin {
|
|||
IfExpressionWithNoElse(Span)
|
||||
}
|
||||
|
||||
impl Copy for TypeOrigin {}
|
||||
|
||||
/// See `error_reporting.rs` for more details
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum ValuePairs<'tcx> {
|
||||
|
@ -237,6 +239,8 @@ pub enum LateBoundRegionConversionTime {
|
|||
HigherRankedType,
|
||||
}
|
||||
|
||||
impl Copy for LateBoundRegionConversionTime {}
|
||||
|
||||
/// Reasons to create a region inference variable
|
||||
///
|
||||
/// See `error_reporting.rs` for more details
|
||||
|
@ -280,6 +284,8 @@ pub enum fixup_err {
|
|||
unresolved_ty(TyVid)
|
||||
}
|
||||
|
||||
impl Copy for fixup_err {}
|
||||
|
||||
pub fn fixup_err_to_string(f: fixup_err) -> String {
|
||||
match f {
|
||||
unresolved_int_ty(_) => {
|
||||
|
|
|
@ -51,6 +51,8 @@ pub enum Constraint {
|
|||
ConstrainVarSubReg(RegionVid, Region),
|
||||
}
|
||||
|
||||
impl Copy for Constraint {}
|
||||
|
||||
// Something we have to verify after region inference is done, but
|
||||
// which does not directly influence the inference process
|
||||
pub enum Verify<'tcx> {
|
||||
|
@ -72,6 +74,8 @@ pub struct TwoRegions {
|
|||
b: Region,
|
||||
}
|
||||
|
||||
impl Copy for TwoRegions {}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
pub enum UndoLogEntry {
|
||||
OpenSnapshot,
|
||||
|
@ -84,11 +88,15 @@ pub enum UndoLogEntry {
|
|||
AddCombination(CombineMapType, TwoRegions)
|
||||
}
|
||||
|
||||
impl Copy for UndoLogEntry {}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
pub enum CombineMapType {
|
||||
Lub, Glb
|
||||
}
|
||||
|
||||
impl Copy for CombineMapType {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum RegionResolutionError<'tcx> {
|
||||
/// `ConcreteFailure(o, a, b)`:
|
||||
|
@ -220,11 +228,15 @@ pub struct RegionSnapshot {
|
|||
length: uint
|
||||
}
|
||||
|
||||
impl Copy for RegionSnapshot {}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub struct RegionMark {
|
||||
length: uint
|
||||
}
|
||||
|
||||
impl Copy for RegionMark {}
|
||||
|
||||
impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
pub fn new(tcx: &'a ty::ctxt<'tcx>) -> RegionVarBindings<'a, 'tcx> {
|
||||
RegionVarBindings {
|
||||
|
@ -926,8 +938,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
|||
#[deriving(PartialEq, Show)]
|
||||
enum Classification { Expanding, Contracting }
|
||||
|
||||
impl Copy for Classification {}
|
||||
|
||||
pub enum VarValue { NoValue, Value(Region), ErrorValue }
|
||||
|
||||
impl Copy for VarValue {}
|
||||
|
||||
struct VarData {
|
||||
classification: Classification,
|
||||
value: VarValue,
|
||||
|
|
|
@ -49,6 +49,8 @@ pub enum RelationDir {
|
|||
SubtypeOf, SupertypeOf, EqTo
|
||||
}
|
||||
|
||||
impl Copy for RelationDir {}
|
||||
|
||||
impl RelationDir {
|
||||
fn opposite(self) -> RelationDir {
|
||||
match self {
|
||||
|
|
|
@ -92,6 +92,8 @@ pub struct Node<K,V> {
|
|||
|
||||
pub struct Delegate;
|
||||
|
||||
impl Copy for Delegate {}
|
||||
|
||||
// We can't use V:LatticeValue, much as I would like to,
|
||||
// because frequently the pattern is that V=Option<U> for some
|
||||
// other type parameter U, and we have no way to say
|
||||
|
|
|
@ -50,6 +50,8 @@ pub enum LangItem {
|
|||
$($variant),*
|
||||
}
|
||||
|
||||
impl Copy for LangItem {}
|
||||
|
||||
pub struct LanguageItems {
|
||||
pub items: Vec<Option<ast::DefId>>,
|
||||
pub missing: Vec<LangItem>,
|
||||
|
|
|
@ -137,9 +137,14 @@ enum LoopKind<'a> {
|
|||
|
||||
#[deriving(PartialEq)]
|
||||
struct Variable(uint);
|
||||
|
||||
impl Copy for Variable {}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
struct LiveNode(uint);
|
||||
|
||||
impl Copy for LiveNode {}
|
||||
|
||||
impl Variable {
|
||||
fn get(&self) -> uint { let Variable(v) = *self; v }
|
||||
}
|
||||
|
@ -162,6 +167,8 @@ enum LiveNodeKind {
|
|||
ExitNode
|
||||
}
|
||||
|
||||
impl Copy for LiveNodeKind {}
|
||||
|
||||
fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String {
|
||||
let cm = cx.sess.codemap();
|
||||
match lnk {
|
||||
|
@ -246,6 +253,8 @@ struct LocalInfo {
|
|||
ident: ast::Ident
|
||||
}
|
||||
|
||||
impl Copy for LocalInfo {}
|
||||
|
||||
#[deriving(Show)]
|
||||
enum VarKind {
|
||||
Arg(NodeId, ast::Ident),
|
||||
|
@ -254,6 +263,8 @@ enum VarKind {
|
|||
CleanExit
|
||||
}
|
||||
|
||||
impl Copy for VarKind {}
|
||||
|
||||
struct IrMaps<'a, 'tcx: 'a> {
|
||||
tcx: &'a ty::ctxt<'tcx>,
|
||||
|
||||
|
@ -532,6 +543,8 @@ struct Users {
|
|||
used: bool
|
||||
}
|
||||
|
||||
impl Copy for Users {}
|
||||
|
||||
fn invalid_users() -> Users {
|
||||
Users {
|
||||
reader: invalid_node(),
|
||||
|
@ -547,6 +560,8 @@ struct Specials {
|
|||
clean_exit_var: Variable
|
||||
}
|
||||
|
||||
impl Copy for Specials {}
|
||||
|
||||
static ACC_READ: uint = 1u;
|
||||
static ACC_WRITE: uint = 2u;
|
||||
static ACC_USE: uint = 4u;
|
||||
|
|
|
@ -110,6 +110,8 @@ pub struct Upvar {
|
|||
pub is_unboxed: bool
|
||||
}
|
||||
|
||||
impl Copy for Upvar {}
|
||||
|
||||
// different kinds of pointers:
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum PointerKind {
|
||||
|
@ -119,6 +121,8 @@ pub enum PointerKind {
|
|||
UnsafePtr(ast::Mutability)
|
||||
}
|
||||
|
||||
impl Copy for PointerKind {}
|
||||
|
||||
// We use the term "interior" to mean "something reachable from the
|
||||
// base without a pointer dereference", e.g. a field
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
|
@ -127,18 +131,24 @@ pub enum InteriorKind {
|
|||
InteriorElement(ElementKind),
|
||||
}
|
||||
|
||||
impl Copy for InteriorKind {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum FieldName {
|
||||
NamedField(ast::Name),
|
||||
PositionalField(uint)
|
||||
}
|
||||
|
||||
impl Copy for FieldName {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum ElementKind {
|
||||
VecElement,
|
||||
OtherElement,
|
||||
}
|
||||
|
||||
impl Copy for ElementKind {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub enum MutabilityCategory {
|
||||
McImmutable, // Immutable.
|
||||
|
@ -146,6 +156,8 @@ pub enum MutabilityCategory {
|
|||
McInherited, // Inherited from the fact that owner is mutable.
|
||||
}
|
||||
|
||||
impl Copy for MutabilityCategory {}
|
||||
|
||||
// A note about the provenance of a `cmt`. This is used for
|
||||
// special-case handling of upvars such as mutability inference.
|
||||
// Upvar categorization can generate a variable number of nested
|
||||
|
@ -158,6 +170,8 @@ pub enum Note {
|
|||
NoteNone // Nothing special
|
||||
}
|
||||
|
||||
impl Copy for Note {}
|
||||
|
||||
// `cmt`: "Category, Mutability, and Type".
|
||||
//
|
||||
// a complete categorization of a value indicating where it originated
|
||||
|
@ -191,6 +205,8 @@ pub enum deref_kind {
|
|||
deref_interior(InteriorKind),
|
||||
}
|
||||
|
||||
impl Copy for deref_kind {}
|
||||
|
||||
// Categorizes a derefable type. Note that we include vectors and strings as
|
||||
// derefable (we model an index as the combination of a deref and then a
|
||||
// pointer adjustment).
|
||||
|
@ -261,6 +277,8 @@ pub struct MemCategorizationContext<'t,TYPER:'t> {
|
|||
typer: &'t TYPER
|
||||
}
|
||||
|
||||
impl<'t,TYPER:'t> Copy for MemCategorizationContext<'t,TYPER> {}
|
||||
|
||||
pub type McResult<T> = Result<T, ()>;
|
||||
|
||||
/// The `Typer` trait provides the interface for the mem-categorization
|
||||
|
@ -1384,6 +1402,8 @@ pub enum InteriorSafety {
|
|||
InteriorSafe
|
||||
}
|
||||
|
||||
impl Copy for InteriorSafety {}
|
||||
|
||||
pub enum AliasableReason {
|
||||
AliasableBorrowed,
|
||||
AliasableClosure(ast::NodeId), // Aliasable due to capture Fn closure env
|
||||
|
@ -1392,6 +1412,8 @@ pub enum AliasableReason {
|
|||
AliasableStaticMut(InteriorSafety),
|
||||
}
|
||||
|
||||
impl Copy for AliasableReason {}
|
||||
|
||||
impl<'tcx> cmt_<'tcx> {
|
||||
pub fn guarantor(&self) -> cmt<'tcx> {
|
||||
//! Returns `self` after stripping away any owned pointer derefs or
|
||||
|
|
|
@ -41,6 +41,8 @@ pub enum CodeExtent {
|
|||
Misc(ast::NodeId)
|
||||
}
|
||||
|
||||
impl Copy for CodeExtent {}
|
||||
|
||||
impl CodeExtent {
|
||||
/// Creates a scope that represents the dynamic extent associated
|
||||
/// with `node_id`.
|
||||
|
@ -120,6 +122,8 @@ pub struct Context {
|
|||
parent: Option<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl Copy for Context {}
|
||||
|
||||
struct RegionResolutionVisitor<'a> {
|
||||
sess: &'a Session,
|
||||
|
||||
|
|
|
@ -94,6 +94,8 @@ struct binding_info {
|
|||
binding_mode: BindingMode,
|
||||
}
|
||||
|
||||
impl Copy for binding_info {}
|
||||
|
||||
// Map from the name in a pattern to its binding mode.
|
||||
type BindingMap = HashMap<Name,binding_info>;
|
||||
|
||||
|
@ -130,12 +132,16 @@ pub enum LastPrivate {
|
|||
type_used: ImportUse},
|
||||
}
|
||||
|
||||
impl Copy for LastPrivate {}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub enum PrivateDep {
|
||||
AllPublic,
|
||||
DependsOn(DefId),
|
||||
}
|
||||
|
||||
impl Copy for PrivateDep {}
|
||||
|
||||
// How an import is used.
|
||||
#[deriving(PartialEq, Show)]
|
||||
pub enum ImportUse {
|
||||
|
@ -143,6 +149,8 @@ pub enum ImportUse {
|
|||
Used, // The import is used.
|
||||
}
|
||||
|
||||
impl Copy for ImportUse {}
|
||||
|
||||
impl LastPrivate {
|
||||
fn or(self, other: LastPrivate) -> LastPrivate {
|
||||
match (self, other) {
|
||||
|
@ -159,12 +167,16 @@ enum PatternBindingMode {
|
|||
ArgumentIrrefutableMode,
|
||||
}
|
||||
|
||||
impl Copy for PatternBindingMode {}
|
||||
|
||||
#[deriving(PartialEq, Eq, Hash, Show)]
|
||||
enum Namespace {
|
||||
TypeNS,
|
||||
ValueNS
|
||||
}
|
||||
|
||||
impl Copy for Namespace {}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
enum NamespaceError {
|
||||
NoError,
|
||||
|
@ -173,6 +185,8 @@ enum NamespaceError {
|
|||
ValueError
|
||||
}
|
||||
|
||||
impl Copy for NamespaceError {}
|
||||
|
||||
/// A NamespaceResult represents the result of resolving an import in
|
||||
/// a particular namespace. The result is either definitely-resolved,
|
||||
/// definitely- unresolved, or unknown.
|
||||
|
@ -238,6 +252,8 @@ enum ImportDirectiveSubclass {
|
|||
GlobImport
|
||||
}
|
||||
|
||||
impl Copy for ImportDirectiveSubclass {}
|
||||
|
||||
/// The context that we thread through while building the reduced graph.
|
||||
#[deriving(Clone)]
|
||||
enum ReducedGraphParent {
|
||||
|
@ -294,6 +310,8 @@ enum TypeParameters<'a> {
|
|||
RibKind)
|
||||
}
|
||||
|
||||
impl<'a> Copy for TypeParameters<'a> {}
|
||||
|
||||
// The rib kind controls the translation of local
|
||||
// definitions (`DefLocal`) to upvars (`DefUpvar`).
|
||||
|
||||
|
@ -319,17 +337,23 @@ enum RibKind {
|
|||
ConstantItemRibKind
|
||||
}
|
||||
|
||||
impl Copy for RibKind {}
|
||||
|
||||
// Methods can be required or provided. RequiredMethod methods only occur in traits.
|
||||
enum MethodSort {
|
||||
RequiredMethod,
|
||||
ProvidedMethod(NodeId)
|
||||
}
|
||||
|
||||
impl Copy for MethodSort {}
|
||||
|
||||
enum UseLexicalScopeFlag {
|
||||
DontUseLexicalScope,
|
||||
UseLexicalScope
|
||||
}
|
||||
|
||||
impl Copy for UseLexicalScopeFlag {}
|
||||
|
||||
enum ModulePrefixResult {
|
||||
NoPrefixFound,
|
||||
PrefixFound(Rc<Module>, uint)
|
||||
|
@ -342,6 +366,8 @@ pub enum TraitItemKind {
|
|||
TypeTraitItemKind,
|
||||
}
|
||||
|
||||
impl Copy for TraitItemKind {}
|
||||
|
||||
impl TraitItemKind {
|
||||
pub fn from_explicit_self_category(explicit_self_category:
|
||||
ExplicitSelfCategory)
|
||||
|
@ -364,12 +390,16 @@ enum NameSearchType {
|
|||
PathSearch,
|
||||
}
|
||||
|
||||
impl Copy for NameSearchType {}
|
||||
|
||||
enum BareIdentifierPatternResolution {
|
||||
FoundStructOrEnumVariant(Def, LastPrivate),
|
||||
FoundConst(Def, LastPrivate),
|
||||
BareIdentifierPatternUnresolved
|
||||
}
|
||||
|
||||
impl Copy for BareIdentifierPatternResolution {}
|
||||
|
||||
// Specifies how duplicates should be handled when adding a child item if
|
||||
// another item exists with the same name in some namespace.
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -381,6 +411,8 @@ enum DuplicateCheckingMode {
|
|||
OverwriteDuplicates
|
||||
}
|
||||
|
||||
impl Copy for DuplicateCheckingMode {}
|
||||
|
||||
/// One local scope.
|
||||
struct Rib {
|
||||
bindings: HashMap<Name, DefLike>,
|
||||
|
@ -518,6 +550,8 @@ enum ModuleKind {
|
|||
AnonymousModuleKind,
|
||||
}
|
||||
|
||||
impl Copy for ModuleKind {}
|
||||
|
||||
/// One node in the tree of modules.
|
||||
struct Module {
|
||||
parent_link: ParentLink,
|
||||
|
@ -599,6 +633,8 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for DefModifiers {}
|
||||
|
||||
// Records a possibly-private type definition.
|
||||
#[deriving(Clone)]
|
||||
struct TypeNsDef {
|
||||
|
@ -616,6 +652,8 @@ struct ValueNsDef {
|
|||
value_span: Option<Span>,
|
||||
}
|
||||
|
||||
impl Copy for ValueNsDef {}
|
||||
|
||||
// Records the definitions (at most one for each namespace) that a name is
|
||||
// bound to.
|
||||
struct NameBindings {
|
||||
|
@ -632,6 +670,8 @@ enum TraitReferenceType {
|
|||
TraitQPath, // <T as SomeTrait>::
|
||||
}
|
||||
|
||||
impl Copy for TraitReferenceType {}
|
||||
|
||||
impl NameBindings {
|
||||
fn new() -> NameBindings {
|
||||
NameBindings {
|
||||
|
|
|
@ -46,6 +46,8 @@ pub enum DefRegion {
|
|||
/* lifetime decl */ ast::NodeId),
|
||||
}
|
||||
|
||||
impl Copy for DefRegion {}
|
||||
|
||||
// maps the id of each lifetime reference to the lifetime decl
|
||||
// that it corresponds to
|
||||
pub type NamedRegionMap = NodeMap<DefRegion>;
|
||||
|
|
|
@ -190,6 +190,8 @@ pub enum ParamSpace {
|
|||
FnSpace, // Type parameters attached to a method or fn
|
||||
}
|
||||
|
||||
impl Copy for ParamSpace {}
|
||||
|
||||
impl ParamSpace {
|
||||
pub fn all() -> [ParamSpace, ..4] {
|
||||
[TypeSpace, SelfSpace, AssocSpace, FnSpace]
|
||||
|
|
|
@ -60,6 +60,8 @@ pub struct ObligationCause<'tcx> {
|
|||
pub code: ObligationCauseCode<'tcx>
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for ObligationCause<'tcx> {}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub enum ObligationCauseCode<'tcx> {
|
||||
/// Not well classified or should be obvious from span.
|
||||
|
@ -95,6 +97,8 @@ pub enum ObligationCauseCode<'tcx> {
|
|||
|
||||
pub type Obligations<'tcx> = subst::VecPerParamSpace<Obligation<'tcx>>;
|
||||
|
||||
impl<'tcx> Copy for ObligationCauseCode<'tcx> {}
|
||||
|
||||
pub type Selection<'tcx> = Vtable<'tcx, Obligation<'tcx>>;
|
||||
|
||||
#[deriving(Clone,Show)]
|
||||
|
@ -338,7 +342,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
|||
VtableFnPointer(ref sig) => VtableFnPointer((*sig).clone()),
|
||||
VtableUnboxedClosure(d, ref s) => VtableUnboxedClosure(d, s.clone()),
|
||||
VtableParam(ref p) => VtableParam((*p).clone()),
|
||||
VtableBuiltin(ref i) => VtableBuiltin(i.map_nested(op)),
|
||||
VtableBuiltin(ref b) => VtableBuiltin(b.map_nested(op)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -348,7 +352,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
|
|||
VtableFnPointer(sig) => VtableFnPointer(sig),
|
||||
VtableUnboxedClosure(d, s) => VtableUnboxedClosure(d, s),
|
||||
VtableParam(p) => VtableParam(p),
|
||||
VtableBuiltin(i) => VtableBuiltin(i.map_move_nested(op)),
|
||||
VtableBuiltin(no) => VtableBuiltin(no.map_move_nested(op)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ struct ObligationStack<'prev, 'tcx: 'prev> {
|
|||
previous: Option<&'prev ObligationStack<'prev, 'tcx>>
|
||||
}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct SelectionCache<'tcx> {
|
||||
hashmap: RefCell<HashMap<Rc<ty::TraitRef<'tcx>>,
|
||||
SelectionResult<'tcx, Candidate<'tcx>>>>,
|
||||
|
@ -102,6 +103,8 @@ pub enum MethodMatchedData {
|
|||
CoerciveMethodMatch(/* impl we matched */ ast::DefId)
|
||||
}
|
||||
|
||||
impl Copy for MethodMatchedData {}
|
||||
|
||||
/// The selection process begins by considering all impls, where
|
||||
/// clauses, and so forth that might resolve an obligation. Sometimes
|
||||
/// we'll be able to say definitively that (e.g.) an impl does not
|
||||
|
@ -918,20 +921,38 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// and applicable impls. There is a certain set of precedence rules here.
|
||||
|
||||
match self.tcx().lang_items.to_builtin_kind(obligation.trait_ref.def_id) {
|
||||
Some(bound) => {
|
||||
try!(self.assemble_builtin_bound_candidates(bound, stack, &mut candidates));
|
||||
Some(ty::BoundCopy) => {
|
||||
debug!("obligation self ty is {}",
|
||||
obligation.self_ty().repr(self.tcx()));
|
||||
|
||||
// If the user has asked for the older, compatibility
|
||||
// behavior, ignore user-defined impls here. This will
|
||||
// go away by the time 1.0 is released.
|
||||
if !self.tcx().sess.features.borrow().opt_out_copy {
|
||||
try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
|
||||
}
|
||||
|
||||
try!(self.assemble_builtin_bound_candidates(ty::BoundCopy,
|
||||
stack,
|
||||
&mut candidates));
|
||||
}
|
||||
|
||||
None => {
|
||||
// For the time being, we ignore user-defined impls for builtin-bounds.
|
||||
// For the time being, we ignore user-defined impls for builtin-bounds, other than
|
||||
// `Copy`.
|
||||
// (And unboxed candidates only apply to the Fn/FnMut/etc traits.)
|
||||
try!(self.assemble_unboxed_closure_candidates(obligation, &mut candidates));
|
||||
try!(self.assemble_fn_pointer_candidates(obligation, &mut candidates));
|
||||
try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
|
||||
}
|
||||
|
||||
Some(bound) => {
|
||||
try!(self.assemble_builtin_bound_candidates(bound, stack, &mut candidates));
|
||||
}
|
||||
}
|
||||
|
||||
try!(self.assemble_candidates_from_caller_bounds(obligation, &mut candidates));
|
||||
debug!("candidate list size: {}", candidates.vec.len());
|
||||
Ok(candidates)
|
||||
}
|
||||
|
||||
|
@ -1519,12 +1540,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
}
|
||||
|
||||
ty::BoundCopy => {
|
||||
if
|
||||
Some(def_id) == tcx.lang_items.no_copy_bound() ||
|
||||
Some(def_id) == tcx.lang_items.managed_bound() ||
|
||||
ty::has_dtor(tcx, def_id)
|
||||
{
|
||||
return Err(Unimplemented);
|
||||
// This is an Opt-In Built-In Trait. So, unless
|
||||
// the user is asking for the old behavior, we
|
||||
// don't supply any form of builtin impl.
|
||||
if !this.tcx().sess.features.borrow().opt_out_copy {
|
||||
return Ok(ParameterBuiltin)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ pub use self::IntVarValue::*;
|
|||
pub use self::ExprAdjustment::*;
|
||||
pub use self::vtable_origin::*;
|
||||
pub use self::MethodOrigin::*;
|
||||
pub use self::CopyImplementationError::*;
|
||||
|
||||
use back::svh::Svh;
|
||||
use session::Session;
|
||||
|
@ -52,8 +53,10 @@ use middle::mem_categorization as mc;
|
|||
use middle::region;
|
||||
use middle::resolve;
|
||||
use middle::resolve_lifetime;
|
||||
use middle::infer;
|
||||
use middle::stability;
|
||||
use middle::subst::{mod, Subst, Substs, VecPerParamSpace};
|
||||
use middle::traits::ObligationCause;
|
||||
use middle::traits;
|
||||
use middle::ty;
|
||||
use middle::ty_fold::{mod, TypeFoldable, TypeFolder, HigherRankedFoldable};
|
||||
|
@ -72,7 +75,7 @@ use std::hash::{Hash, sip, Writer};
|
|||
use std::mem;
|
||||
use std::ops;
|
||||
use std::rc::Rc;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use std::collections::hash_map::{HashMap, Occupied, Vacant};
|
||||
use arena::TypedArena;
|
||||
use syntax::abi;
|
||||
use syntax::ast::{CrateNum, DefId, FnStyle, Ident, ItemTrait, LOCAL_CRATE};
|
||||
|
@ -81,7 +84,7 @@ use syntax::ast::{Onceness, StmtExpr, StmtSemi, StructField, UnnamedField};
|
|||
use syntax::ast::{Visibility};
|
||||
use syntax::ast_util::{mod, is_local, lit_is_str, local_def, PostExpansionMethod};
|
||||
use syntax::attr::{mod, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::parse::token::{mod, InternedString};
|
||||
use syntax::{ast, ast_map};
|
||||
use std::collections::enum_set::{EnumSet, CLike};
|
||||
|
@ -109,12 +112,16 @@ pub struct field<'tcx> {
|
|||
pub mt: mt<'tcx>
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for field<'tcx> {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum ImplOrTraitItemContainer {
|
||||
TraitContainer(ast::DefId),
|
||||
ImplContainer(ast::DefId),
|
||||
}
|
||||
|
||||
impl Copy for ImplOrTraitItemContainer {}
|
||||
|
||||
impl ImplOrTraitItemContainer {
|
||||
pub fn id(&self) -> ast::DefId {
|
||||
match *self {
|
||||
|
@ -175,6 +182,8 @@ pub enum ImplOrTraitItemId {
|
|||
TypeTraitItemId(ast::DefId),
|
||||
}
|
||||
|
||||
impl Copy for ImplOrTraitItemId {}
|
||||
|
||||
impl ImplOrTraitItemId {
|
||||
pub fn def_id(&self) -> ast::DefId {
|
||||
match *self {
|
||||
|
@ -236,12 +245,16 @@ pub struct AssociatedType {
|
|||
pub container: ImplOrTraitItemContainer,
|
||||
}
|
||||
|
||||
impl Copy for AssociatedType {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
|
||||
pub struct mt<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
pub mutbl: ast::Mutability,
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for mt<'tcx> {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Encodable, Decodable, Show)]
|
||||
pub enum TraitStore {
|
||||
/// Box<Trait>
|
||||
|
@ -250,6 +263,8 @@ pub enum TraitStore {
|
|||
RegionTraitStore(Region, ast::Mutability),
|
||||
}
|
||||
|
||||
impl Copy for TraitStore {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub struct field_ty {
|
||||
pub name: Name,
|
||||
|
@ -258,6 +273,8 @@ pub struct field_ty {
|
|||
pub origin: ast::DefId, // The DefId of the struct in which the field is declared.
|
||||
}
|
||||
|
||||
impl Copy for field_ty {}
|
||||
|
||||
// Contains information needed to resolve types and (in the future) look up
|
||||
// the types of AST nodes.
|
||||
#[deriving(PartialEq, Eq, Hash)]
|
||||
|
@ -267,11 +284,15 @@ pub struct creader_cache_key {
|
|||
pub len: uint
|
||||
}
|
||||
|
||||
impl Copy for creader_cache_key {}
|
||||
|
||||
pub enum ast_ty_to_ty_cache_entry<'tcx> {
|
||||
atttce_unresolved, /* not resolved yet */
|
||||
atttce_resolved(Ty<'tcx>) /* resolved to a type, irrespective of region */
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for ast_ty_to_ty_cache_entry<'tcx> {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Decodable, Encodable)]
|
||||
pub struct ItemVariances {
|
||||
pub types: VecPerParamSpace<Variance>,
|
||||
|
@ -286,6 +307,8 @@ pub enum Variance {
|
|||
Bivariant, // T<A> <: T<B> -- e.g., unused type parameter
|
||||
}
|
||||
|
||||
impl Copy for Variance {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum AutoAdjustment<'tcx> {
|
||||
AdjustAddEnv(ty::TraitStore),
|
||||
|
@ -431,6 +454,8 @@ pub struct param_index {
|
|||
pub index: uint
|
||||
}
|
||||
|
||||
impl Copy for param_index {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum MethodOrigin<'tcx> {
|
||||
// fully statically resolved method
|
||||
|
@ -485,6 +510,8 @@ pub struct MethodCallee<'tcx> {
|
|||
pub substs: subst::Substs<'tcx>
|
||||
}
|
||||
|
||||
impl Copy for MethodCall {}
|
||||
|
||||
/// With method calls, we store some extra information in
|
||||
/// side tables (i.e method_map). We use
|
||||
/// MethodCall as a key to index into these tables instead of
|
||||
|
@ -510,6 +537,8 @@ pub enum ExprAdjustment {
|
|||
AutoObject
|
||||
}
|
||||
|
||||
impl Copy for ExprAdjustment {}
|
||||
|
||||
impl MethodCall {
|
||||
pub fn expr(id: ast::NodeId) -> MethodCall {
|
||||
MethodCall {
|
||||
|
@ -594,6 +623,8 @@ pub struct TransmuteRestriction<'tcx> {
|
|||
pub id: ast::NodeId,
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for TransmuteRestriction<'tcx> {}
|
||||
|
||||
/// The data structure to keep track of all the information that typechecker
|
||||
/// generates so that so that it can be reused and doesn't have to be redone
|
||||
/// later on.
|
||||
|
@ -746,6 +777,9 @@ pub struct ctxt<'tcx> {
|
|||
|
||||
/// Caches the representation hints for struct definitions.
|
||||
pub repr_hint_cache: RefCell<DefIdMap<Rc<Vec<attr::ReprAttr>>>>,
|
||||
|
||||
/// Caches whether types move by default.
|
||||
pub type_moves_by_default_cache: RefCell<HashMap<Ty<'tcx>,bool>>,
|
||||
}
|
||||
|
||||
// Flags that we track on types. These flags are propagated upwards
|
||||
|
@ -766,6 +800,8 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for TypeFlags {}
|
||||
|
||||
#[deriving(Show)]
|
||||
pub struct TyS<'tcx> {
|
||||
pub sty: sty<'tcx>,
|
||||
|
@ -807,6 +843,7 @@ impl<'tcx> PartialEq for InternedTy<'tcx> {
|
|||
self.ty.sty == other.ty.sty
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Eq for InternedTy<'tcx> {}
|
||||
|
||||
impl<'tcx, S: Writer> Hash<S> for InternedTy<'tcx> {
|
||||
|
@ -900,6 +937,8 @@ impl<'tcx> FnOutput<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for FnOutput<'tcx> {}
|
||||
|
||||
/// Signature of a function type, which I have arbitrarily
|
||||
/// decided to use to refer to the input/output types.
|
||||
///
|
||||
|
@ -924,6 +963,8 @@ pub struct ParamTy {
|
|||
pub def_id: DefId
|
||||
}
|
||||
|
||||
impl Copy for ParamTy {}
|
||||
|
||||
/// A [De Bruijn index][dbi] is a standard means of representing
|
||||
/// regions (and perhaps later types) in a higher-ranked setting. In
|
||||
/// particular, imagine a type like this:
|
||||
|
@ -1018,6 +1059,8 @@ pub struct UpvarId {
|
|||
pub closure_expr_id: ast::NodeId,
|
||||
}
|
||||
|
||||
impl Copy for UpvarId {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash, Show, Encodable, Decodable)]
|
||||
pub enum BorrowKind {
|
||||
/// Data must be immutable and is aliasable.
|
||||
|
@ -1064,6 +1107,8 @@ pub enum BorrowKind {
|
|||
MutBorrow
|
||||
}
|
||||
|
||||
impl Copy for BorrowKind {}
|
||||
|
||||
/// Information describing the borrowing of an upvar. This is computed
|
||||
/// during `typeck`, specifically by `regionck`. The general idea is
|
||||
/// that the compiler analyses treat closures like:
|
||||
|
@ -1119,6 +1164,8 @@ pub struct UpvarBorrow {
|
|||
|
||||
pub type UpvarBorrowMap = FnvHashMap<UpvarId, UpvarBorrow>;
|
||||
|
||||
impl Copy for UpvarBorrow {}
|
||||
|
||||
impl Region {
|
||||
pub fn is_bound(&self) -> bool {
|
||||
match *self {
|
||||
|
@ -1136,6 +1183,8 @@ impl Region {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for Region {}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
|
||||
/// A "free" region `fr` can be interpreted as "some region
|
||||
/// at least as big as the scope `fr.scope`".
|
||||
|
@ -1144,6 +1193,8 @@ pub struct FreeRegion {
|
|||
pub bound_region: BoundRegion
|
||||
}
|
||||
|
||||
impl Copy for FreeRegion {}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Encodable, Decodable, Show)]
|
||||
pub enum BoundRegion {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
|
@ -1163,6 +1214,8 @@ pub enum BoundRegion {
|
|||
BrEnv
|
||||
}
|
||||
|
||||
impl Copy for BoundRegion {}
|
||||
|
||||
#[inline]
|
||||
pub fn mk_prim_t<'tcx>(primitive: &'tcx TyS<'static>) -> Ty<'tcx> {
|
||||
// FIXME(#17596) Ty<'tcx> is incorrectly invariant w.r.t 'tcx.
|
||||
|
@ -1302,6 +1355,8 @@ pub enum IntVarValue {
|
|||
UintType(ast::UintTy),
|
||||
}
|
||||
|
||||
impl Copy for IntVarValue {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum terr_vstore_kind {
|
||||
terr_vec,
|
||||
|
@ -1310,12 +1365,16 @@ pub enum terr_vstore_kind {
|
|||
terr_trait
|
||||
}
|
||||
|
||||
impl Copy for terr_vstore_kind {}
|
||||
|
||||
#[deriving(Clone, Show)]
|
||||
pub struct expected_found<T> {
|
||||
pub expected: T,
|
||||
pub found: T
|
||||
}
|
||||
|
||||
impl<T:Copy> Copy for expected_found<T> {}
|
||||
|
||||
// Data structures used in type unification
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum type_err<'tcx> {
|
||||
|
@ -1350,6 +1409,8 @@ pub enum type_err<'tcx> {
|
|||
terr_convergence_mismatch(expected_found<bool>)
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for type_err<'tcx> {}
|
||||
|
||||
/// Bounds suitable for a named type parameter like `A` in `fn foo<A>`
|
||||
/// as well as the existential type parameter in an object type.
|
||||
#[deriving(PartialEq, Eq, Hash, Clone, Show)]
|
||||
|
@ -1370,6 +1431,8 @@ pub struct ExistentialBounds {
|
|||
pub builtin_bounds: BuiltinBounds
|
||||
}
|
||||
|
||||
impl Copy for ExistentialBounds {}
|
||||
|
||||
pub type BuiltinBounds = EnumSet<BuiltinBound>;
|
||||
|
||||
#[deriving(Clone, Encodable, PartialEq, Eq, Decodable, Hash, Show)]
|
||||
|
@ -1381,6 +1444,8 @@ pub enum BuiltinBound {
|
|||
BoundSync,
|
||||
}
|
||||
|
||||
impl Copy for BuiltinBound {}
|
||||
|
||||
pub fn empty_builtin_bounds() -> BuiltinBounds {
|
||||
EnumSet::new()
|
||||
}
|
||||
|
@ -1413,21 +1478,29 @@ pub struct TyVid {
|
|||
pub index: uint
|
||||
}
|
||||
|
||||
impl Copy for TyVid {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct IntVid {
|
||||
pub index: uint
|
||||
}
|
||||
|
||||
impl Copy for IntVid {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FloatVid {
|
||||
pub index: uint
|
||||
}
|
||||
|
||||
impl Copy for FloatVid {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
|
||||
pub struct RegionVid {
|
||||
pub index: uint
|
||||
}
|
||||
|
||||
impl Copy for RegionVid {}
|
||||
|
||||
#[deriving(Clone, PartialEq, Eq, Hash)]
|
||||
pub enum InferTy {
|
||||
TyVar(TyVid),
|
||||
|
@ -1441,12 +1514,16 @@ pub enum InferTy {
|
|||
SkolemizedIntTy(uint),
|
||||
}
|
||||
|
||||
impl Copy for InferTy {}
|
||||
|
||||
#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
|
||||
pub enum InferRegion {
|
||||
ReVar(RegionVid),
|
||||
ReSkolemized(uint, BoundRegion)
|
||||
}
|
||||
|
||||
impl Copy for InferRegion {}
|
||||
|
||||
impl cmp::PartialEq for InferRegion {
|
||||
fn eq(&self, other: &InferRegion) -> bool {
|
||||
match ((*self), *other) {
|
||||
|
@ -1642,6 +1719,7 @@ impl<'tcx> TraitRef<'tcx> {
|
|||
/// bound lifetime parameters are replaced with free ones, but in the
|
||||
/// future I hope to refine the representation of types so as to make
|
||||
/// more distinctions clearer.
|
||||
#[deriving(Clone)]
|
||||
pub struct ParameterEnvironment<'tcx> {
|
||||
/// A substitution that can be applied to move from
|
||||
/// the "outer" view of a type or method to the "inner" view.
|
||||
|
@ -1690,14 +1768,14 @@ impl<'tcx> ParameterEnvironment<'tcx> {
|
|||
}
|
||||
TypeTraitItem(_) => {
|
||||
cx.sess
|
||||
.bug("ParameterEnvironment::from_item(): \
|
||||
.bug("ParameterEnvironment::for_item(): \
|
||||
can't create a parameter environment \
|
||||
for type trait items")
|
||||
}
|
||||
}
|
||||
}
|
||||
ast::TypeImplItem(_) => {
|
||||
cx.sess.bug("ParameterEnvironment::from_item(): \
|
||||
cx.sess.bug("ParameterEnvironment::for_item(): \
|
||||
can't create a parameter environment \
|
||||
for type impl items")
|
||||
}
|
||||
|
@ -1707,7 +1785,7 @@ impl<'tcx> ParameterEnvironment<'tcx> {
|
|||
match *trait_method {
|
||||
ast::RequiredMethod(ref required) => {
|
||||
cx.sess.span_bug(required.span,
|
||||
"ParameterEnvironment::from_item():
|
||||
"ParameterEnvironment::for_item():
|
||||
can't create a parameter \
|
||||
environment for required trait \
|
||||
methods")
|
||||
|
@ -1725,7 +1803,7 @@ impl<'tcx> ParameterEnvironment<'tcx> {
|
|||
}
|
||||
TypeTraitItem(_) => {
|
||||
cx.sess
|
||||
.bug("ParameterEnvironment::from_item(): \
|
||||
.bug("ParameterEnvironment::for_item(): \
|
||||
can't create a parameter environment \
|
||||
for type trait items")
|
||||
}
|
||||
|
@ -1768,6 +1846,10 @@ impl<'tcx> ParameterEnvironment<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Some(ast_map::NodeExpr(..)) => {
|
||||
// This is a convenience to allow closures to work.
|
||||
ParameterEnvironment::for_item(cx, cx.map.get_parent(id))
|
||||
}
|
||||
_ => {
|
||||
cx.sess.bug(format!("ParameterEnvironment::from_item(): \
|
||||
`{}` is not an item",
|
||||
|
@ -1825,6 +1907,8 @@ pub enum UnboxedClosureKind {
|
|||
FnOnceUnboxedClosureKind,
|
||||
}
|
||||
|
||||
impl Copy for UnboxedClosureKind {}
|
||||
|
||||
impl UnboxedClosureKind {
|
||||
pub fn trait_did(&self, cx: &ctxt) -> ast::DefId {
|
||||
let result = match *self {
|
||||
|
@ -1909,6 +1993,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
|
|||
associated_types: RefCell::new(DefIdMap::new()),
|
||||
selection_cache: traits::SelectionCache::new(),
|
||||
repr_hint_cache: RefCell::new(DefIdMap::new()),
|
||||
type_moves_by_default_cache: RefCell::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2604,6 +2689,8 @@ pub struct TypeContents {
|
|||
pub bits: u64
|
||||
}
|
||||
|
||||
impl Copy for TypeContents {}
|
||||
|
||||
macro_rules! def_type_content_sets(
|
||||
(mod $mname:ident { $($name:ident = $bits:expr),+ }) => {
|
||||
#[allow(non_snake_case)]
|
||||
|
@ -2630,7 +2717,6 @@ def_type_content_sets!(
|
|||
OwnsOwned = 0b0000_0000__0000_0001__0000,
|
||||
OwnsDtor = 0b0000_0000__0000_0010__0000,
|
||||
OwnsManaged /* see [1] below */ = 0b0000_0000__0000_0100__0000,
|
||||
OwnsAffine = 0b0000_0000__0000_1000__0000,
|
||||
OwnsAll = 0b0000_0000__1111_1111__0000,
|
||||
|
||||
// Things that are reachable by the value in any way (fourth nibble):
|
||||
|
@ -2640,24 +2726,12 @@ def_type_content_sets!(
|
|||
ReachesFfiUnsafe = 0b0010_0000__0000_0000__0000,
|
||||
ReachesAll = 0b0011_1111__0000_0000__0000,
|
||||
|
||||
// Things that cause values to *move* rather than *copy*. This
|
||||
// is almost the same as the `Copy` trait, but for managed
|
||||
// data -- atm, we consider managed data to copy, not move,
|
||||
// but it does not impl Copy as a pure memcpy is not good
|
||||
// enough. Yuck.
|
||||
Moves = 0b0000_0000__0000_1011__0000,
|
||||
|
||||
// Things that mean drop glue is necessary
|
||||
NeedsDrop = 0b0000_0000__0000_0111__0000,
|
||||
|
||||
// Things that prevent values from being considered sized
|
||||
Nonsized = 0b0000_0000__0000_0000__0001,
|
||||
|
||||
// Things that make values considered not POD (would be same
|
||||
// as `Moves`, but for the fact that managed data `@` is
|
||||
// not considered POD)
|
||||
Noncopy = 0b0000_0000__0000_1111__0000,
|
||||
|
||||
// Bits to set when a managed value is encountered
|
||||
//
|
||||
// [1] Do not set the bits TC::OwnsManaged or
|
||||
|
@ -2699,10 +2773,6 @@ impl TypeContents {
|
|||
self.intersects(TC::InteriorUnsized)
|
||||
}
|
||||
|
||||
pub fn moves_by_default(&self, _: &ctxt) -> bool {
|
||||
self.intersects(TC::Moves)
|
||||
}
|
||||
|
||||
pub fn needs_drop(&self, _: &ctxt) -> bool {
|
||||
self.intersects(TC::NeedsDrop)
|
||||
}
|
||||
|
@ -2987,15 +3057,10 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
mc | tc_ty(cx, mt.ty, cache)
|
||||
}
|
||||
|
||||
fn apply_lang_items(cx: &ctxt,
|
||||
did: ast::DefId,
|
||||
tc: TypeContents)
|
||||
-> TypeContents
|
||||
{
|
||||
fn apply_lang_items(cx: &ctxt, did: ast::DefId, tc: TypeContents)
|
||||
-> TypeContents {
|
||||
if Some(did) == cx.lang_items.managed_bound() {
|
||||
tc | TC::Managed
|
||||
} else if Some(did) == cx.lang_items.no_copy_bound() {
|
||||
tc | TC::OwnsAffine
|
||||
} else if Some(did) == cx.lang_items.unsafe_type() {
|
||||
tc | TC::InteriorUnsafe
|
||||
} else {
|
||||
|
@ -3008,7 +3073,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
mutbl: ast::Mutability)
|
||||
-> TypeContents {
|
||||
let b = match mutbl {
|
||||
ast::MutMutable => TC::ReachesMutable | TC::OwnsAffine,
|
||||
ast::MutMutable => TC::ReachesMutable,
|
||||
ast::MutImmutable => TC::None,
|
||||
};
|
||||
b | (TC::ReachesBorrowed).when(region != ty::ReStatic)
|
||||
|
@ -3028,14 +3093,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
}
|
||||
};
|
||||
|
||||
// This also prohibits "@once fn" from being copied, which allows it to
|
||||
// be called. Neither way really makes much sense.
|
||||
let ot = match cty.onceness {
|
||||
ast::Once => TC::OwnsAffine,
|
||||
ast::Many => TC::None,
|
||||
};
|
||||
|
||||
st | ot
|
||||
st
|
||||
}
|
||||
|
||||
fn object_contents(cx: &ctxt,
|
||||
|
@ -3053,9 +3111,8 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
let mut tc = TC::All;
|
||||
each_inherited_builtin_bound(cx, bounds, traits, |bound| {
|
||||
tc = tc - match bound {
|
||||
BoundSync | BoundSend => TC::None,
|
||||
BoundSync | BoundSend | BoundCopy => TC::None,
|
||||
BoundSized => TC::Nonsized,
|
||||
BoundCopy => TC::Noncopy,
|
||||
};
|
||||
});
|
||||
return tc;
|
||||
|
@ -3081,8 +3138,38 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn type_moves_by_default<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
type_contents(cx, ty).moves_by_default(cx)
|
||||
pub fn type_moves_by_default<'tcx>(cx: &ctxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
param_env: &ParameterEnvironment<'tcx>)
|
||||
-> bool {
|
||||
if !type_has_params(ty) && !type_has_self(ty) {
|
||||
match cx.type_moves_by_default_cache.borrow().get(&ty) {
|
||||
None => {}
|
||||
Some(&result) => {
|
||||
debug!("determined whether {} moves by default (cached): {}",
|
||||
ty_to_string(cx, ty),
|
||||
result);
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let infcx = infer::new_infer_ctxt(cx);
|
||||
let mut fulfill_cx = traits::FulfillmentContext::new();
|
||||
let obligation = traits::obligation_for_builtin_bound(
|
||||
cx,
|
||||
ObligationCause::misc(DUMMY_SP),
|
||||
ty,
|
||||
ty::BoundCopy).unwrap();
|
||||
fulfill_cx.register_obligation(cx, obligation);
|
||||
let result = !fulfill_cx.select_all_or_error(&infcx,
|
||||
param_env,
|
||||
cx).is_ok();
|
||||
cx.type_moves_by_default_cache.borrow_mut().insert(ty, result);
|
||||
debug!("determined whether {} moves by default: {}",
|
||||
ty_to_string(cx, ty),
|
||||
result);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
|
@ -3214,6 +3301,8 @@ pub enum Representability {
|
|||
SelfRecursive,
|
||||
}
|
||||
|
||||
impl Copy for Representability {}
|
||||
|
||||
/// Check whether a type is representable. This means it cannot contain unboxed
|
||||
/// structural recursion. This check is needed for structs and enums.
|
||||
pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
||||
|
@ -3996,6 +4085,8 @@ pub enum ExprKind {
|
|||
RvalueStmtExpr
|
||||
}
|
||||
|
||||
impl Copy for ExprKind {}
|
||||
|
||||
pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
|
||||
if tcx.method_map.borrow().contains_key(&MethodCall::expr(expr.id)) {
|
||||
// Overloaded operations are generally calls, and hence they are
|
||||
|
@ -4555,6 +4646,8 @@ pub struct AssociatedTypeInfo {
|
|||
pub name: ast::Name,
|
||||
}
|
||||
|
||||
impl Copy for AssociatedTypeInfo {}
|
||||
|
||||
impl PartialOrd for AssociatedTypeInfo {
|
||||
fn partial_cmp(&self, other: &AssociatedTypeInfo) -> Option<Ordering> {
|
||||
Some(self.index.cmp(&other.index))
|
||||
|
@ -4738,6 +4831,8 @@ pub enum DtorKind {
|
|||
TraitDtor(DefId, bool)
|
||||
}
|
||||
|
||||
impl Copy for DtorKind {}
|
||||
|
||||
impl DtorKind {
|
||||
pub fn is_present(&self) -> bool {
|
||||
match *self {
|
||||
|
@ -5125,6 +5220,8 @@ pub struct UnboxedClosureUpvar<'tcx> {
|
|||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for UnboxedClosureUpvar<'tcx> {}
|
||||
|
||||
// Returns a list of `UnboxedClosureUpvar`s for each upvar.
|
||||
pub fn unboxed_closure_upvars<'tcx>(tcx: &ctxt<'tcx>, closure_id: ast::DefId, substs: &Substs<'tcx>)
|
||||
-> Vec<UnboxedClosureUpvar<'tcx>> {
|
||||
|
@ -5954,6 +6051,8 @@ pub enum ExplicitSelfCategory {
|
|||
ByBoxExplicitSelfCategory,
|
||||
}
|
||||
|
||||
impl Copy for ExplicitSelfCategory {}
|
||||
|
||||
/// Pushes all the lifetimes in the given type onto the given list. A
|
||||
/// "lifetime in a type" is a lifetime specified by a reference or a lifetime
|
||||
/// in a list of type substitutions. This does *not* traverse into nominal
|
||||
|
@ -6023,6 +6122,8 @@ pub struct Freevar {
|
|||
pub span: Span
|
||||
}
|
||||
|
||||
impl Copy for Freevar {}
|
||||
|
||||
pub type FreevarMap = NodeMap<Vec<Freevar>>;
|
||||
|
||||
pub type CaptureModeMap = NodeMap<ast::CaptureClause>;
|
||||
|
@ -6122,6 +6223,8 @@ impl DebruijnIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for DebruijnIndex {}
|
||||
|
||||
impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
match *self {
|
||||
|
@ -6229,3 +6332,43 @@ pub fn make_substs_for_receiver_types<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||
trait_ref.substs.clone().with_method(meth_tps, meth_regions)
|
||||
}
|
||||
|
||||
pub enum CopyImplementationError {
|
||||
FieldDoesNotImplementCopy(ast::Name),
|
||||
VariantDoesNotImplementCopy(ast::Name),
|
||||
TypeIsStructural,
|
||||
}
|
||||
|
||||
impl Copy for CopyImplementationError {}
|
||||
|
||||
pub fn can_type_implement_copy<'tcx>(tcx: &ctxt<'tcx>,
|
||||
self_type: Ty<'tcx>,
|
||||
param_env: &ParameterEnvironment<'tcx>)
|
||||
-> Result<(),CopyImplementationError> {
|
||||
match self_type.sty {
|
||||
ty::ty_struct(struct_did, ref substs) => {
|
||||
let fields = ty::struct_fields(tcx, struct_did, substs);
|
||||
for field in fields.iter() {
|
||||
if type_moves_by_default(tcx, field.mt.ty, param_env) {
|
||||
return Err(FieldDoesNotImplementCopy(field.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::ty_enum(enum_did, ref substs) => {
|
||||
let enum_variants = ty::enum_variants(tcx, enum_did);
|
||||
for variant in enum_variants.iter() {
|
||||
for variant_arg_type in variant.args.iter() {
|
||||
let substd_arg_type =
|
||||
variant_arg_type.subst(tcx, substs);
|
||||
if type_moves_by_default(tcx,
|
||||
substd_arg_type,
|
||||
param_env) {
|
||||
return Err(VariantDoesNotImplementCopy(variant.name))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => return Err(TypeIsStructural),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ pub enum OptLevel {
|
|||
Aggressive // -O3
|
||||
}
|
||||
|
||||
impl Copy for OptLevel {}
|
||||
|
||||
#[deriving(Clone, PartialEq)]
|
||||
pub enum DebugInfoLevel {
|
||||
NoDebugInfo,
|
||||
|
@ -62,6 +64,8 @@ pub enum DebugInfoLevel {
|
|||
FullDebugInfo,
|
||||
}
|
||||
|
||||
impl Copy for DebugInfoLevel {}
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)]
|
||||
pub enum OutputType {
|
||||
OutputTypeBitcode,
|
||||
|
@ -71,6 +75,8 @@ pub enum OutputType {
|
|||
OutputTypeExe,
|
||||
}
|
||||
|
||||
impl Copy for OutputType {}
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct Options {
|
||||
// The crate config requested for the session, which may be combined
|
||||
|
@ -87,7 +93,7 @@ pub struct Options {
|
|||
// parsed code. It remains mutable in case its replacements wants to use
|
||||
// this.
|
||||
pub addl_lib_search_paths: RefCell<Vec<Path>>,
|
||||
pub libs: Vec<(String, cstore::NativeLibaryKind)>,
|
||||
pub libs: Vec<(String, cstore::NativeLibraryKind)>,
|
||||
pub maybe_sysroot: Option<Path>,
|
||||
pub target_triple: String,
|
||||
// User-specified cfg meta items. The compiler itself will add additional
|
||||
|
@ -221,6 +227,8 @@ pub enum EntryFnType {
|
|||
EntryNone,
|
||||
}
|
||||
|
||||
impl Copy for EntryFnType {}
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, Clone, Ord, Eq, Hash)]
|
||||
pub enum CrateType {
|
||||
CrateTypeExecutable,
|
||||
|
@ -229,6 +237,8 @@ pub enum CrateType {
|
|||
CrateTypeStaticlib,
|
||||
}
|
||||
|
||||
impl Copy for CrateType {}
|
||||
|
||||
macro_rules! debugging_opts(
|
||||
([ $opt:ident ] $cnt:expr ) => (
|
||||
pub const $opt: u64 = 1 << $cnt;
|
||||
|
|
|
@ -25,6 +25,8 @@ use syntax::visit::Visitor;
|
|||
#[deriving(Clone,Show)]
|
||||
pub struct ErrorReported;
|
||||
|
||||
impl Copy for ErrorReported {}
|
||||
|
||||
pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T {
|
||||
thread_local!(static DEPTH: Cell<uint> = Cell::new(0));
|
||||
if !do_it { return f(u); }
|
||||
|
|
|
@ -71,6 +71,9 @@ pub mod DefIdSet {
|
|||
#[deriving(Clone, Default)]
|
||||
pub struct FnvHasher;
|
||||
|
||||
impl Copy for FnvHasher {}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub struct FnvState(u64);
|
||||
|
||||
impl Hasher<FnvState> for FnvHasher {
|
||||
|
|
|
@ -49,12 +49,16 @@ pub enum PpSourceMode {
|
|||
PpmExpandedHygiene,
|
||||
}
|
||||
|
||||
impl Copy for PpSourceMode {}
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
pub enum PpMode {
|
||||
PpmSource(PpSourceMode),
|
||||
PpmFlowGraph,
|
||||
}
|
||||
|
||||
impl Copy for PpMode {}
|
||||
|
||||
pub fn parse_pretty(sess: &Session, name: &str) -> (PpMode, Option<UserIdentifiedItem>) {
|
||||
let mut split = name.splitn(1, '=');
|
||||
let first = split.next().unwrap();
|
||||
|
|
|
@ -24,6 +24,8 @@ pub enum OptimizationDiagnosticKind {
|
|||
OptimizationFailure,
|
||||
}
|
||||
|
||||
impl Copy for OptimizationDiagnosticKind {}
|
||||
|
||||
impl OptimizationDiagnosticKind {
|
||||
pub fn describe(self) -> &'static str {
|
||||
match self {
|
||||
|
@ -43,6 +45,8 @@ pub struct OptimizationDiagnostic {
|
|||
pub message: TwineRef,
|
||||
}
|
||||
|
||||
impl Copy for OptimizationDiagnostic {}
|
||||
|
||||
impl OptimizationDiagnostic {
|
||||
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
|
||||
-> OptimizationDiagnostic {
|
||||
|
@ -72,6 +76,8 @@ pub enum Diagnostic {
|
|||
UnknownDiagnostic(DiagnosticInfoRef),
|
||||
}
|
||||
|
||||
impl Copy for Diagnostic {}
|
||||
|
||||
impl Diagnostic {
|
||||
pub unsafe fn unpack(di: DiagnosticInfoRef) -> Diagnostic {
|
||||
let kind = super::LLVMGetDiagInfoKind(di);
|
||||
|
|
|
@ -77,12 +77,16 @@ pub enum CallConv {
|
|||
X86_64_Win64 = 79,
|
||||
}
|
||||
|
||||
impl Copy for CallConv {}
|
||||
|
||||
pub enum Visibility {
|
||||
LLVMDefaultVisibility = 0,
|
||||
HiddenVisibility = 1,
|
||||
ProtectedVisibility = 2,
|
||||
}
|
||||
|
||||
impl Copy for Visibility {}
|
||||
|
||||
// This enum omits the obsolete (and no-op) linkage types DLLImportLinkage,
|
||||
// DLLExportLinkage, GhostLinkage and LinkOnceODRAutoHideLinkage.
|
||||
// LinkerPrivateLinkage and LinkerPrivateWeakLinkage are not included either;
|
||||
|
@ -101,6 +105,8 @@ pub enum Linkage {
|
|||
CommonLinkage = 14,
|
||||
}
|
||||
|
||||
impl Copy for Linkage {}
|
||||
|
||||
#[repr(C)]
|
||||
#[deriving(Show)]
|
||||
pub enum DiagnosticSeverity {
|
||||
|
@ -110,6 +116,8 @@ pub enum DiagnosticSeverity {
|
|||
Note,
|
||||
}
|
||||
|
||||
impl Copy for DiagnosticSeverity {}
|
||||
|
||||
bitflags! {
|
||||
flags Attribute : u32 {
|
||||
const ZExtAttribute = 1 << 0,
|
||||
|
@ -141,6 +149,8 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl Copy for Attribute {}
|
||||
|
||||
#[repr(u64)]
|
||||
pub enum OtherAttribute {
|
||||
// The following are not really exposed in
|
||||
|
@ -162,16 +172,22 @@ pub enum OtherAttribute {
|
|||
NonNullAttribute = 1 << 44,
|
||||
}
|
||||
|
||||
impl Copy for OtherAttribute {}
|
||||
|
||||
pub enum SpecialAttribute {
|
||||
DereferenceableAttribute(u64)
|
||||
}
|
||||
|
||||
impl Copy for SpecialAttribute {}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum AttributeSet {
|
||||
ReturnIndex = 0,
|
||||
FunctionIndex = !0
|
||||
}
|
||||
|
||||
impl Copy for AttributeSet {}
|
||||
|
||||
pub trait AttrHelper {
|
||||
fn apply_llfn(&self, idx: c_uint, llfn: ValueRef);
|
||||
fn apply_callsite(&self, idx: c_uint, callsite: ValueRef);
|
||||
|
@ -271,6 +287,8 @@ pub enum IntPredicate {
|
|||
IntSLE = 41,
|
||||
}
|
||||
|
||||
impl Copy for IntPredicate {}
|
||||
|
||||
// enum for the LLVM RealPredicate type
|
||||
pub enum RealPredicate {
|
||||
RealPredicateFalse = 0,
|
||||
|
@ -291,6 +309,8 @@ pub enum RealPredicate {
|
|||
RealPredicateTrue = 15,
|
||||
}
|
||||
|
||||
impl Copy for RealPredicate {}
|
||||
|
||||
// The LLVM TypeKind type - must stay in sync with the def of
|
||||
// LLVMTypeKind in llvm/include/llvm-c/Core.h
|
||||
#[deriving(PartialEq)]
|
||||
|
@ -314,6 +334,8 @@ pub enum TypeKind {
|
|||
X86_MMX = 15,
|
||||
}
|
||||
|
||||
impl Copy for TypeKind {}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum AtomicBinOp {
|
||||
AtomicXchg = 0,
|
||||
|
@ -329,6 +351,8 @@ pub enum AtomicBinOp {
|
|||
AtomicUMin = 10,
|
||||
}
|
||||
|
||||
impl Copy for AtomicBinOp {}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum AtomicOrdering {
|
||||
NotAtomic = 0,
|
||||
|
@ -341,6 +365,8 @@ pub enum AtomicOrdering {
|
|||
SequentiallyConsistent = 7
|
||||
}
|
||||
|
||||
impl Copy for AtomicOrdering {}
|
||||
|
||||
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
|
||||
#[repr(C)]
|
||||
pub enum FileType {
|
||||
|
@ -348,6 +374,8 @@ pub enum FileType {
|
|||
ObjectFileType = 1
|
||||
}
|
||||
|
||||
impl Copy for FileType {}
|
||||
|
||||
pub enum MetadataType {
|
||||
MD_dbg = 0,
|
||||
MD_tbaa = 1,
|
||||
|
@ -357,12 +385,16 @@ pub enum MetadataType {
|
|||
MD_tbaa_struct = 5
|
||||
}
|
||||
|
||||
impl Copy for MetadataType {}
|
||||
|
||||
// Inline Asm Dialect
|
||||
pub enum AsmDialect {
|
||||
AD_ATT = 0,
|
||||
AD_Intel = 1
|
||||
}
|
||||
|
||||
impl Copy for AsmDialect {}
|
||||
|
||||
#[deriving(PartialEq, Clone)]
|
||||
#[repr(C)]
|
||||
pub enum CodeGenOptLevel {
|
||||
|
@ -372,6 +404,8 @@ pub enum CodeGenOptLevel {
|
|||
CodeGenLevelAggressive = 3,
|
||||
}
|
||||
|
||||
impl Copy for CodeGenOptLevel {}
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
#[repr(C)]
|
||||
pub enum RelocMode {
|
||||
|
@ -381,6 +415,8 @@ pub enum RelocMode {
|
|||
RelocDynamicNoPic = 3,
|
||||
}
|
||||
|
||||
impl Copy for RelocMode {}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum CodeGenModel {
|
||||
CodeModelDefault = 0,
|
||||
|
@ -391,6 +427,8 @@ pub enum CodeGenModel {
|
|||
CodeModelLarge = 5,
|
||||
}
|
||||
|
||||
impl Copy for CodeGenModel {}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum DiagnosticKind {
|
||||
DK_InlineAsm = 0,
|
||||
|
@ -403,47 +441,70 @@ pub enum DiagnosticKind {
|
|||
DK_OptimizationFailure,
|
||||
}
|
||||
|
||||
impl Copy for DiagnosticKind {}
|
||||
|
||||
// Opaque pointer types
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Module_opaque {}
|
||||
pub type ModuleRef = *mut Module_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Context_opaque {}
|
||||
pub type ContextRef = *mut Context_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Type_opaque {}
|
||||
pub type TypeRef = *mut Type_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Value_opaque {}
|
||||
pub type ValueRef = *mut Value_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum BasicBlock_opaque {}
|
||||
pub type BasicBlockRef = *mut BasicBlock_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Builder_opaque {}
|
||||
pub type BuilderRef = *mut Builder_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum ExecutionEngine_opaque {}
|
||||
pub type ExecutionEngineRef = *mut ExecutionEngine_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum MemoryBuffer_opaque {}
|
||||
pub type MemoryBufferRef = *mut MemoryBuffer_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum PassManager_opaque {}
|
||||
pub type PassManagerRef = *mut PassManager_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum PassManagerBuilder_opaque {}
|
||||
pub type PassManagerBuilderRef = *mut PassManagerBuilder_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Use_opaque {}
|
||||
pub type UseRef = *mut Use_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum TargetData_opaque {}
|
||||
pub type TargetDataRef = *mut TargetData_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum ObjectFile_opaque {}
|
||||
pub type ObjectFileRef = *mut ObjectFile_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum SectionIterator_opaque {}
|
||||
pub type SectionIteratorRef = *mut SectionIterator_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Pass_opaque {}
|
||||
pub type PassRef = *mut Pass_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum TargetMachine_opaque {}
|
||||
pub type TargetMachineRef = *mut TargetMachine_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Archive_opaque {}
|
||||
pub type ArchiveRef = *mut Archive_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum Twine_opaque {}
|
||||
pub type TwineRef = *mut Twine_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DiagnosticInfo_opaque {}
|
||||
pub type DiagnosticInfoRef = *mut DiagnosticInfo_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DebugLoc_opaque {}
|
||||
pub type DebugLocRef = *mut DebugLoc_opaque;
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum SMDiagnostic_opaque {}
|
||||
pub type SMDiagnosticRef = *mut SMDiagnostic_opaque;
|
||||
|
||||
|
@ -454,6 +515,7 @@ pub mod debuginfo {
|
|||
pub use self::DIDescriptorFlags::*;
|
||||
use super::{ValueRef};
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum DIBuilder_opaque {}
|
||||
pub type DIBuilderRef = *mut DIBuilder_opaque;
|
||||
|
||||
|
@ -490,6 +552,8 @@ pub mod debuginfo {
|
|||
FlagLValueReference = 1 << 14,
|
||||
FlagRValueReference = 1 << 15
|
||||
}
|
||||
|
||||
impl Copy for DIDescriptorFlags {}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2123,6 +2187,7 @@ pub fn get_param(llfn: ValueRef, index: c_uint) -> ValueRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
pub enum RustString_opaque {}
|
||||
pub type RustStringRef = *mut RustString_opaque;
|
||||
type RustStringRepr = *mut RefCell<Vec<u8>>;
|
||||
|
|
|
@ -33,6 +33,17 @@ use std::sync::{Arc, Mutex};
|
|||
use std::task::TaskBuilder;
|
||||
use libc::{c_uint, c_int, c_void};
|
||||
|
||||
#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq)]
|
||||
pub enum OutputType {
|
||||
OutputTypeBitcode,
|
||||
OutputTypeAssembly,
|
||||
OutputTypeLlvmAssembly,
|
||||
OutputTypeObject,
|
||||
OutputTypeExe,
|
||||
}
|
||||
|
||||
impl Copy for OutputType {}
|
||||
|
||||
pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! {
|
||||
unsafe {
|
||||
let cstr = llvm::LLVMRustGetLastError();
|
||||
|
|
|
@ -249,7 +249,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
self.collecting = true;
|
||||
self.visit_pat(&*arg.pat);
|
||||
self.collecting = false;
|
||||
let span_utils = self.span;
|
||||
let span_utils = self.span.clone();
|
||||
for &(id, ref p, _, _) in self.collected_paths.iter() {
|
||||
let typ = ppaux::ty_to_string(&self.analysis.ty_cx,
|
||||
(*self.analysis.ty_cx.node_types.borrow())[id]);
|
||||
|
|
|
@ -87,6 +87,8 @@ pub enum Row {
|
|||
FnRef,
|
||||
}
|
||||
|
||||
impl Copy for Row {}
|
||||
|
||||
impl<'a> FmtStrs<'a> {
|
||||
pub fn new(rec: Box<Recorder>, span: SpanUtils<'a>, krate: String) -> FmtStrs<'a> {
|
||||
FmtStrs {
|
||||
|
@ -223,7 +225,10 @@ impl<'a> FmtStrs<'a> {
|
|||
|
||||
if self.recorder.dump_spans {
|
||||
if dump_spans {
|
||||
self.recorder.dump_span(self.span, label, span, Some(sub_span));
|
||||
self.recorder.dump_span(self.span.clone(),
|
||||
label,
|
||||
span,
|
||||
Some(sub_span));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ use syntax::parse::lexer::{Reader,StringReader};
|
|||
use syntax::parse::token;
|
||||
use syntax::parse::token::{keywords, Token};
|
||||
|
||||
#[deriving(Clone)]
|
||||
pub struct SpanUtils<'a> {
|
||||
pub sess: &'a Session,
|
||||
pub err_count: Cell<int>,
|
||||
|
|
|
@ -231,6 +231,8 @@ use syntax::ptr::P;
|
|||
#[deriving(Show)]
|
||||
struct ConstantExpr<'a>(&'a ast::Expr);
|
||||
|
||||
impl<'a> Copy for ConstantExpr<'a> {}
|
||||
|
||||
impl<'a> ConstantExpr<'a> {
|
||||
fn eq(self, other: ConstantExpr<'a>, tcx: &ty::ctxt) -> bool {
|
||||
let ConstantExpr(expr) = self;
|
||||
|
@ -308,6 +310,8 @@ pub enum BranchKind {
|
|||
CompareSliceLength
|
||||
}
|
||||
|
||||
impl Copy for BranchKind {}
|
||||
|
||||
pub enum OptResult<'blk, 'tcx: 'blk> {
|
||||
SingleResult(Result<'blk, 'tcx>),
|
||||
RangeResult(Result<'blk, 'tcx>, Result<'blk, 'tcx>),
|
||||
|
@ -321,6 +325,8 @@ pub enum TransBindingMode {
|
|||
TrByRef,
|
||||
}
|
||||
|
||||
impl Copy for TransBindingMode {}
|
||||
|
||||
/// Information about a pattern binding:
|
||||
/// - `llmatch` is a pointer to a stack slot. The stack slot contains a
|
||||
/// pointer into the value being matched. Hence, llmatch has type `T**`
|
||||
|
@ -337,6 +343,8 @@ pub struct BindingInfo<'tcx> {
|
|||
pub ty: Ty<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> Copy for BindingInfo<'tcx> {}
|
||||
|
||||
type BindingsMap<'tcx> = FnvHashMap<Ident, BindingInfo<'tcx>>;
|
||||
|
||||
struct ArmData<'p, 'blk, 'tcx: 'blk> {
|
||||
|
@ -543,7 +551,11 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
|
|||
check_match::Constructor::Variant(def_id)
|
||||
};
|
||||
|
||||
let mcx = check_match::MatchCheckCtxt { tcx: bcx.tcx() };
|
||||
let param_env = ty::empty_parameter_environment();
|
||||
let mcx = check_match::MatchCheckCtxt {
|
||||
tcx: bcx.tcx(),
|
||||
param_env: param_env,
|
||||
};
|
||||
enter_match(bcx, dm, m, col, val, |pats|
|
||||
check_match::specialize(&mcx, pats.as_slice(), &ctor, col, variant_size)
|
||||
)
|
||||
|
@ -1001,7 +1013,10 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
node_id_type(bcx, pat_id)
|
||||
};
|
||||
|
||||
let mcx = check_match::MatchCheckCtxt { tcx: bcx.tcx() };
|
||||
let mcx = check_match::MatchCheckCtxt {
|
||||
tcx: bcx.tcx(),
|
||||
param_env: ty::empty_parameter_environment(),
|
||||
};
|
||||
let adt_vals = if any_irrefutable_adt_pat(bcx.tcx(), m, col) {
|
||||
let repr = adt::represent_type(bcx.ccx(), left_ty);
|
||||
let arg_count = adt::num_args(&*repr, 0);
|
||||
|
@ -1254,7 +1269,8 @@ fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool
|
|||
reassigned: false
|
||||
};
|
||||
{
|
||||
let mut visitor = euv::ExprUseVisitor::new(&mut rc, bcx);
|
||||
let param_env = ty::empty_parameter_environment();
|
||||
let mut visitor = euv::ExprUseVisitor::new(&mut rc, bcx, param_env);
|
||||
visitor.walk_expr(body);
|
||||
}
|
||||
rc.reassigned
|
||||
|
@ -1312,12 +1328,15 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
|
|||
let variable_ty = node_id_type(bcx, p_id);
|
||||
let llvariable_ty = type_of::type_of(ccx, variable_ty);
|
||||
let tcx = bcx.tcx();
|
||||
let param_env = ty::empty_parameter_environment();
|
||||
|
||||
let llmatch;
|
||||
let trmode;
|
||||
match bm {
|
||||
ast::BindByValue(_)
|
||||
if !ty::type_moves_by_default(tcx, variable_ty) || reassigned => {
|
||||
if !ty::type_moves_by_default(tcx,
|
||||
variable_ty,
|
||||
¶m_env) || reassigned => {
|
||||
llmatch = alloca_no_lifetime(bcx,
|
||||
llvariable_ty.ptr_to(),
|
||||
"__llmatch");
|
||||
|
|
|
@ -287,8 +287,11 @@ pub enum PointerField {
|
|||
FatPointer(uint)
|
||||
}
|
||||
|
||||
impl Copy for PointerField {}
|
||||
|
||||
impl<'tcx> Case<'tcx> {
|
||||
fn is_zerolen<'a>(&self, cx: &CrateContext<'a, 'tcx>, scapegoat: Ty<'tcx>) -> bool {
|
||||
fn is_zerolen<'a>(&self, cx: &CrateContext<'a, 'tcx>, scapegoat: Ty<'tcx>)
|
||||
-> bool {
|
||||
mk_struct(cx, self.tys.as_slice(), false, scapegoat).size == 0
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ use libc::{c_uint, uint64_t};
|
|||
use std::c_str::ToCStr;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashSet;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use std::{i8, i16, i32, i64};
|
||||
use syntax::abi::{Rust, RustCall, RustIntrinsic, Abi};
|
||||
|
@ -562,6 +563,8 @@ pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) {
|
|||
// Used only for creating scalar comparison glue.
|
||||
pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
|
||||
|
||||
impl Copy for scalar_type {}
|
||||
|
||||
pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
lhs: ValueRef,
|
||||
rhs: ValueRef,
|
||||
|
@ -813,7 +816,10 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||
in iter_structural_ty")
|
||||
}
|
||||
}
|
||||
_ => cx.sess().unimpl("type in iter_structural_ty")
|
||||
_ => {
|
||||
cx.sess().unimpl(format!("type in iter_structural_ty: {}",
|
||||
ty_to_string(cx.tcx(), t)).as_slice())
|
||||
}
|
||||
}
|
||||
return cx;
|
||||
}
|
||||
|
@ -1778,6 +1784,14 @@ pub fn build_return_block<'blk, 'tcx>(fcx: &FunctionContext<'blk, 'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq, PartialEq)]
|
||||
pub enum IsUnboxedClosureFlag {
|
||||
NotUnboxedClosure,
|
||||
IsUnboxedClosure,
|
||||
}
|
||||
|
||||
impl Copy for IsUnboxedClosureFlag {}
|
||||
|
||||
// trans_closure: Builds an LLVM function out of a source function.
|
||||
// If the function closes over its environment a closure will be
|
||||
// returned.
|
||||
|
@ -2182,6 +2196,8 @@ pub enum ValueOrigin {
|
|||
InlinedCopy,
|
||||
}
|
||||
|
||||
impl Copy for ValueOrigin {}
|
||||
|
||||
/// Set the appropriate linkage for an LLVM `ValueRef` (function or global).
|
||||
/// If the `llval` is the direct translation of a specific Rust item, `id`
|
||||
/// should be set to the `NodeId` of that item. (This mapping should be
|
||||
|
@ -3036,7 +3052,11 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
|
|||
fn next(&mut self) -> Option<ValueRef> {
|
||||
let old = self.cur;
|
||||
if !old.is_null() {
|
||||
self.cur = unsafe { (self.step)(old) };
|
||||
self.cur = unsafe {
|
||||
let step: unsafe extern "C" fn(ValueRef) -> ValueRef =
|
||||
mem::transmute_copy(&self.step);
|
||||
step(old)
|
||||
};
|
||||
Some(old)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -15,6 +15,8 @@ use std::iter::{Filter, Map};
|
|||
|
||||
pub struct BasicBlock(pub BasicBlockRef);
|
||||
|
||||
impl Copy for BasicBlock {}
|
||||
|
||||
pub type Preds<'a> = Map<'a, Value, BasicBlock, Filter<'a, Value, Users>>;
|
||||
|
||||
/// Wrapper for LLVM BasicBlockRef
|
||||
|
|
|
@ -31,6 +31,8 @@ pub enum ArgKind {
|
|||
Ignore,
|
||||
}
|
||||
|
||||
impl Copy for ArgKind {}
|
||||
|
||||
/// Information about how a specific C type
|
||||
/// should be passed to or returned from a function
|
||||
///
|
||||
|
@ -48,6 +50,8 @@ pub struct ArgType {
|
|||
pub attr: option::Option<Attribute>
|
||||
}
|
||||
|
||||
impl Copy for ArgType {}
|
||||
|
||||
impl ArgType {
|
||||
pub fn direct(ty: Type, cast: option::Option<Type>,
|
||||
pad: option::Option<Type>,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue