Skip to content

Commit

Permalink
changes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Oct 30, 2014
1 parent 1d500cf commit c48a1ab
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 141 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/vtable.rs
Expand Up @@ -196,8 +196,8 @@ pub fn check_object_safety(tcx: &ty::ctxt, object_trait: &ty::TyTrait, span: Spa
let check_for_self_ty = |ty| {
if ty::type_has_self(ty) {
Some(format!(
"cannot call a method (`{}`) whose type (`{}`) contains \
a self-type through a trait object",
"cannot call a method (`{}`) whose type contains \
a self-type (`{}`) through a trait object",
method_name, ty_to_string(tcx, ty)))
} else {
None
Expand Down
5 changes: 4 additions & 1 deletion src/libstd/io/extensions.rs
Expand Up @@ -172,7 +172,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
mod test {
use prelude::*;
use io;
use io::{MemReader, MemWriter};
use io::{MemReader, MemWriter, BytesReader};

struct InitialZeroByteReader {
count: int,
Expand All @@ -189,6 +189,7 @@ mod test {
}
}
}
impl BytesReader for InitialZeroByteReader {}

struct EofReader;

Expand All @@ -197,6 +198,7 @@ mod test {
Err(io::standard_error(io::EndOfFile))
}
}
impl BytesReader for EofReader {}

struct ErroringReader;

Expand All @@ -205,6 +207,7 @@ mod test {
Err(io::standard_error(io::InvalidInput))
}
}
impl BytesReader for ErroringReader {}

struct PartialReader {
count: int,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/util.rs
Expand Up @@ -265,7 +265,7 @@ impl<T: Iterator<u8>> Reader for IterReader<T> {

#[cfg(test)]
mod test {
use io::{MemReader, MemWriter, BufReader};
use io::{MemReader, MemWriter, BufReader, AsRefReader};
use io;
use boxed::Box;
use super::*;
Expand Down
20 changes: 0 additions & 20 deletions src/test/compile-fail/selftype-traittype.rs

This file was deleted.

43 changes: 43 additions & 0 deletions src/test/compile-fail/trait-objects.rs
@@ -0,0 +1,43 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait Foo {
fn foo(self);
}

trait Bar {
fn bar(&self, x: &Self);
}

trait Baz {
fn baz<T>(&self, x: &T);
}

impl Foo for int {
fn foo(self) {}
}

impl Bar for int {
fn bar(&self, _x: &int) {}
}

impl Baz for int {
fn baz<T>(&self, _x: &T) {}
}

fn main() {
let _: &Foo = &42i; //~ ERROR cannot convert to a trait object
let _: &Bar = &42i; //~ ERROR cannot convert to a trait object
let _: &Baz = &42i; //~ ERROR cannot convert to a trait object

let _ = &42i as &Foo; //~ ERROR cannot convert to a trait object
let _ = &42i as &Bar; //~ ERROR cannot convert to a trait object
let _ = &42i as &Baz; //~ ERROR cannot convert to a trait object
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/trait-test-2.rs
Expand Up @@ -16,5 +16,5 @@ impl bar for uint { fn dup(&self) -> uint { *self } fn blah<X>(&self) {} }
fn main() {
10i.dup::<int>(); //~ ERROR does not take type parameters
10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters
(box 10i as Box<bar>).dup(); //~ ERROR contains a self-type
(box 10i as Box<bar>).dup(); //~ ERROR cannot convert to a trait object
}
77 changes: 0 additions & 77 deletions src/test/run-pass/by-value-self-objects.rs

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/run-pass/issue-11267.rs
Expand Up @@ -12,11 +12,14 @@

struct Empty;

impl Iterator<int> for Empty {
trait T<U> {
fn next(&mut self) -> Option<U>;
}
impl T<int> for Empty {
fn next(&mut self) -> Option<int> { None }
}

fn do_something_with(a : &mut Iterator<int>) {
fn do_something_with(a : &mut T<int>) {
println!("{}", a.next())
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/run-pass/issue-15763.rs
Expand Up @@ -60,16 +60,16 @@ fn dd() -> Result<int, int> {
}

trait A {
fn aaa(self) -> int {
fn aaa(&self) -> int {
3
}
fn bbb(self) -> int {
fn bbb(&self) -> int {
return 3;
}
fn ccc(self) -> Result<int, int> {
fn ccc(&self) -> Result<int, int> {
Ok(3)
}
fn ddd(self) -> Result<int, int> {
fn ddd(&self) -> Result<int, int> {
return Ok(3);
}
}
Expand Down
30 changes: 0 additions & 30 deletions src/test/run-pass/trait-cast-generic.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/test/run-pass/trait-default-method-xc.rs
Expand Up @@ -72,9 +72,6 @@ pub fn main() {
assert_eq!(g(0i, 3.14f64, 1i), (3.14f64, 1i));
assert_eq!(g(false, 3.14f64, 1i), (3.14, 1));

let obj = box 0i as Box<A>;
assert_eq!(obj.h(), 11);


// Trying out a real one
assert!(12i.test_neq(&10i));
Expand Down

0 comments on commit c48a1ab

Please sign in to comment.