mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
fix rpass/cfail tests
This commit is contained in:
parent
6fc92578fe
commit
9aadbadb93
@ -8,13 +8,17 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct MyVec<T> {
|
||||
data: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T> Index<uint, T> for MyVec<T> {
|
||||
impl<T> Index<uint> for MyVec<T> {
|
||||
type Output = T;
|
||||
|
||||
fn index(&self, &i: &uint) -> &T {
|
||||
&self.data[i]
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Test that we still see borrowck errors of various kinds when using
|
||||
// indexing and autoderef in combination.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
@ -18,7 +20,9 @@ struct Foo {
|
||||
y: int,
|
||||
}
|
||||
|
||||
impl Index<String,int> for Foo {
|
||||
impl Index<String> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index<'a>(&'a self, z: &String) -> &'a int {
|
||||
if z.as_slice() == "x" {
|
||||
&self.x
|
||||
@ -28,7 +32,9 @@ impl Index<String,int> for Foo {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<String,int> for Foo {
|
||||
impl IndexMut<String> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut int {
|
||||
if z.as_slice() == "x" {
|
||||
&mut self.x
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
@ -15,7 +17,9 @@ struct Foo {
|
||||
y: int,
|
||||
}
|
||||
|
||||
impl Index<String,int> for Foo {
|
||||
impl Index<String> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index<'a>(&'a self, z: &String) -> &'a int {
|
||||
if z.as_slice() == "x" {
|
||||
&self.x
|
||||
@ -25,7 +29,9 @@ impl Index<String,int> for Foo {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<String,int> for Foo {
|
||||
impl IndexMut<String> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut int {
|
||||
if z.as_slice() == "x" {
|
||||
&mut self.x
|
||||
@ -39,7 +45,9 @@ struct Bar {
|
||||
x: int,
|
||||
}
|
||||
|
||||
impl Index<int,int> for Bar {
|
||||
impl Index<int> for Bar {
|
||||
type Output = int;
|
||||
|
||||
fn index<'a>(&'a self, z: &int) -> &'a int {
|
||||
&self.x
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Test that overloaded index expressions with DST result types
|
||||
// can't be used as rvalues
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::Index;
|
||||
use std::fmt::Show;
|
||||
|
||||
@ -18,7 +20,9 @@ struct S;
|
||||
|
||||
impl Copy for S {}
|
||||
|
||||
impl Index<uint, str> for S {
|
||||
impl Index<uint> for S {
|
||||
type Output = str;
|
||||
|
||||
fn index<'a>(&'a self, _: &uint) -> &'a str {
|
||||
"hello"
|
||||
}
|
||||
@ -28,7 +32,9 @@ struct T;
|
||||
|
||||
impl Copy for T {}
|
||||
|
||||
impl Index<uint, Show + 'static> for T {
|
||||
impl Index<uint> for T {
|
||||
type Output = Show + 'static;
|
||||
|
||||
fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
|
||||
static x: uint = 42;
|
||||
&x
|
||||
|
@ -11,12 +11,16 @@
|
||||
// Test that overloaded index expressions with DST result types
|
||||
// work and don't ICE.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::Index;
|
||||
use std::fmt::Show;
|
||||
|
||||
struct S;
|
||||
|
||||
impl Index<uint, str> for S {
|
||||
impl Index<uint> for S {
|
||||
type Output = str;
|
||||
|
||||
fn index<'a>(&'a self, _: &uint) -> &'a str {
|
||||
"hello"
|
||||
}
|
||||
@ -24,7 +28,9 @@ impl Index<uint, str> for S {
|
||||
|
||||
struct T;
|
||||
|
||||
impl Index<uint, Show + 'static> for T {
|
||||
impl Index<uint> for T {
|
||||
type Output = Show + 'static;
|
||||
|
||||
fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
|
||||
static x: uint = 42;
|
||||
&x
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
// If `Index` used an associated type for its output, this test would
|
||||
// work more smoothly.
|
||||
#![feature(old_orphan_check)]
|
||||
|
||||
#![feature(associated_types, old_orphan_check)]
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
@ -25,13 +26,17 @@ impl<T> Mat<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Index<(uint, uint), T> for Mat<T> {
|
||||
impl<T> Index<(uint, uint)> for Mat<T> {
|
||||
type Output = T;
|
||||
|
||||
fn index<'a>(&'a self, &(row, col): &(uint, uint)) -> &'a T {
|
||||
&self.data[row * self.cols + col]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Index<(uint, uint), T> for &'a Mat<T> {
|
||||
impl<'a, T> Index<(uint, uint)> for &'a Mat<T> {
|
||||
type Output = T;
|
||||
|
||||
fn index<'b>(&'b self, index: &(uint, uint)) -> &'b T {
|
||||
(*self).index(index)
|
||||
}
|
||||
@ -39,7 +44,9 @@ impl<'a, T> Index<(uint, uint), T> for &'a Mat<T> {
|
||||
|
||||
struct Row<M> { mat: M, row: uint, }
|
||||
|
||||
impl<T, M: Index<(uint, uint), T>> Index<uint, T> for Row<M> {
|
||||
impl<T, M: Index<(uint, uint), Output=T>> Index<uint> for Row<M> {
|
||||
type Output = T;
|
||||
|
||||
fn index<'a>(&'a self, col: &uint) -> &'a T {
|
||||
&self.mat[(self.row, *col)]
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ impl ops::Not for Point {
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Index<bool,int> for Point {
|
||||
impl ops::Index<bool> for Point {
|
||||
type Output = int;
|
||||
|
||||
fn index(&self, x: &bool) -> &int {
|
||||
if *x {
|
||||
&self.x
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Test overloading of the `[]` operator. In particular test that it
|
||||
// takes its argument *by reference*.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct AssociationList<K,V> {
|
||||
@ -28,7 +30,9 @@ impl<K,V> AssociationList<K,V> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K,V> for AssociationList<K,V> {
|
||||
impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K> for AssociationList<K,V> {
|
||||
type Output = V;
|
||||
|
||||
fn index<'a>(&'a self, index: &K) -> &'a V {
|
||||
for pair in self.pairs.iter() {
|
||||
if pair.key == *index {
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
// Test overloaded indexing combined with autoderef.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
@ -17,7 +19,9 @@ struct Foo {
|
||||
y: int,
|
||||
}
|
||||
|
||||
impl Index<int,int> for Foo {
|
||||
impl Index<int> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index(&self, z: &int) -> &int {
|
||||
if *z == 0 {
|
||||
&self.x
|
||||
@ -27,7 +31,9 @@ impl Index<int,int> for Foo {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<int,int> for Foo {
|
||||
impl IndexMut<int> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index_mut(&mut self, z: &int) -> &mut int {
|
||||
if *z == 0 {
|
||||
&mut self.x
|
||||
|
@ -11,6 +11,8 @@
|
||||
// Test using overloaded indexing when the "map" is stored in a
|
||||
// field. This caused problems at some point.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::Index;
|
||||
|
||||
struct Foo {
|
||||
@ -22,7 +24,9 @@ struct Bar {
|
||||
foo: Foo
|
||||
}
|
||||
|
||||
impl Index<int,int> for Foo {
|
||||
impl Index<int> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index(&self, z: &int) -> &int {
|
||||
if *z == 0 {
|
||||
&self.x
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
use std::ops::{Index, IndexMut};
|
||||
|
||||
struct Foo {
|
||||
@ -15,7 +17,9 @@ struct Foo {
|
||||
y: int,
|
||||
}
|
||||
|
||||
impl Index<int,int> for Foo {
|
||||
impl Index<int> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index(&self, z: &int) -> &int {
|
||||
if *z == 0 {
|
||||
&self.x
|
||||
@ -25,7 +29,9 @@ impl Index<int,int> for Foo {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<int,int> for Foo {
|
||||
impl IndexMut<int> for Foo {
|
||||
type Output = int;
|
||||
|
||||
fn index_mut(&mut self, z: &int) -> &mut int {
|
||||
if *z == 0 {
|
||||
&mut self.x
|
||||
|
Loading…
Reference in New Issue
Block a user