librustc: Remove all uses of static from functions. rs=destatic

This commit is contained in:
Patrick Walton 2013-03-21 19:07:54 -07:00
parent 1616ffd0c2
commit 4634f7edae
79 changed files with 281 additions and 286 deletions

View file

@ -13,7 +13,7 @@ pub struct Foo {
}
pub impl Foo {
static fn new() -> Foo {
fn new() -> Foo {
Foo { x: 3 }
}
}

View file

@ -14,17 +14,17 @@
#[crate_type = "lib"];
pub trait read {
static fn readMaybe(s: ~str) -> Option<Self>;
fn readMaybe(s: ~str) -> Option<Self>;
}
impl read for int {
static fn readMaybe(s: ~str) -> Option<int> {
fn readMaybe(s: ~str) -> Option<int> {
int::from_str(s)
}
}
impl read for bool {
static fn readMaybe(s: ~str) -> Option<bool> {
fn readMaybe(s: ~str) -> Option<bool> {
match s {
~"true" => Some(true),
~"false" => Some(false),

View file

@ -11,14 +11,14 @@
pub mod num {
pub trait Num2 {
static pure fn from_int2(n: int) -> Self;
static fn from_int2(n: int) -> Self;
}
}
pub mod float {
impl ::num::Num2 for float {
#[inline]
static pure fn from_int2(n: int) -> float { return n as float; }
static fn from_int2(n: int) -> float { return n as float; }
}
}

View file

@ -1,11 +1,11 @@
pub mod num {
pub trait Num2 {
static pure fn from_int2(n: int) -> Self;
pure fn from_int2(n: int) -> Self;
}
}
pub mod float {
impl ::num::Num2 for float {
static pure fn from_int2(n: int) -> float { return n as float; }
pure fn from_int2(n: int) -> float { return n as float; }
}
}

View file

@ -40,11 +40,11 @@ struct Sudoku {
}
pub impl Sudoku {
static pub fn new(g: grid) -> Sudoku {
pub fn new(g: grid) -> Sudoku {
return Sudoku { grid: g }
}
static pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku {
pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku {
let mut g = do vec::from_fn(9u) |i| {
do vec::from_fn(9u) |j| { vec[i][j] }
};
@ -62,7 +62,7 @@ pub impl Sudoku {
return true;
}
static pub fn read(reader: @io::Reader) -> Sudoku {
pub fn read(reader: @io::Reader) -> Sudoku {
fail_unless!(reader.read_line() == ~"9,9"); /* assert first line is exactly "9,9" */
let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] });
@ -156,7 +156,7 @@ struct Colors(u16);
const heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */
impl Colors {
static fn new(start_color: u8) -> Colors {
fn new(start_color: u8) -> Colors {
// Sets bits 9..start_color
let tails = !0u16 << start_color;
return Colors(heads & tails);

View file

@ -14,7 +14,7 @@ struct Obj {
}
pub impl Obj {
static pure fn boom() -> bool {
pure fn boom() -> bool {
return 1+1 == 2
}
pure fn chirp() {

View file

@ -17,7 +17,7 @@ trait BikeMethods {
}
impl BikeMethods for Bike {
static fn woops(&const self) -> ~str { ~"foo" }
fn woops(&const self) -> ~str { ~"foo" }
//~^ ERROR method `woops` is declared as static in its impl, but not in its trait
}

View file

@ -16,7 +16,7 @@ struct Point {
}
impl ToStr for Point { //~ ERROR implements a method not defined in the trait
static fn new(x: float, y: float) -> Point {
fn new(x: float, y: float) -> Point {
Point { x: x, y: y }
}

View file

@ -1,7 +1,7 @@
mod a {
pub struct S;
impl S {
static fn new() -> S { S }
fn new() -> S { S }
}
}

View file

@ -10,7 +10,7 @@
trait foo {
static fn bar();
fn bar();
}
impl foo for int {

View file

@ -13,7 +13,7 @@ struct Foo {
}
pub impl Foo {
static fn new() -> Foo {
fn new() -> Foo {
Foo { x: 3 }
}
}

View file

@ -115,7 +115,7 @@ pub impl<T> cat<T> {
}
}
static pure fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
pure fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
cat{meows: in_x, how_hungry: in_y, name: in_name }
}
}

View file

@ -130,9 +130,9 @@ mod test_methods {
impl Fooable for Foo {
#[cfg(bogus)]
static fn what(&self) { }
fn what(&self) { }
static fn what(&self) { }
fn what(&self) { }
#[cfg(bogus)]
fn the(&self) { }
@ -142,9 +142,9 @@ mod test_methods {
trait Fooable {
#[cfg(bogus)]
static fn what(&self);
fn what(&self);
static fn what(&self);
fn what(&self);
#[cfg(bogus)]
fn the(&self);

View file

@ -13,11 +13,11 @@ trait Deserializer {
}
trait Deserializable<D:Deserializer> {
static fn deserialize(&self, d: &D) -> Self;
fn deserialize(d: &D) -> Self;
}
impl<D:Deserializer> Deserializable<D> for int {
static fn deserialize(&self, d: &D) -> int {
fn deserialize(d: &D) -> int {
return d.read_int();
}
}

View file

@ -14,7 +14,7 @@
// A trait for objects that can be used to do an if-then-else
// (No actual need for this to be static, but it is a simple test.)
trait bool_like {
static fn select<A>(b: Self, +x1: A, +x2: A) -> A;
fn select<A>(b: Self, +x1: A, +x2: A) -> A;
}
fn andand<T:bool_like + Copy>(x1: T, x2: T) -> T {
@ -22,35 +22,35 @@ fn andand<T:bool_like + Copy>(x1: T, x2: T) -> T {
}
impl bool_like for bool {
static fn select<A>(&&b: bool, +x1: A, +x2: A) -> A {
fn select<A>(&&b: bool, +x1: A, +x2: A) -> A {
if b { x1 } else { x2 }
}
}
impl bool_like for int {
static fn select<A>(&&b: int, +x1: A, +x2: A) -> A {
fn select<A>(&&b: int, +x1: A, +x2: A) -> A {
if b != 0 { x1 } else { x2 }
}
}
// A trait for sequences that can be constructed imperatively.
trait buildable<A> {
static pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> Self;
pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> Self;
}
impl<A> buildable<A> for @[A] {
#[inline(always)]
static pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> @[A] {
pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> @[A] {
at_vec::build_sized(size, builder)
}
}
impl<A> buildable<A> for ~[A] {
#[inline(always)]
static pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> ~[A] {
pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> ~[A] {
vec::build_sized(size, builder)
}
}

View file

@ -10,17 +10,17 @@
mod a {
pub trait Foo {
static pub fn foo() -> Self;
pub fn foo() -> Self;
}
impl Foo for int {
static pub fn foo() -> int {
pub fn foo() -> int {
3
}
}
impl Foo for uint {
static pub fn foo() -> uint {
pub fn foo() -> uint {
5u
}
}

View file

@ -1,9 +1,9 @@
pub trait Number: NumConv {
static pure fn from<T:Number>(n: T) -> Self;
pure fn from<T:Number>(n: T) -> Self;
}
impl Number for float {
static pure fn from<T:Number>(n: T) -> float { n.to_float() }
pure fn from<T:Number>(n: T) -> float { n.to_float() }
}
pub trait NumConv {

View file

@ -15,7 +15,7 @@
use core::num::NumCast::from;
trait Num {
static fn from_int(i: int) -> Self;
fn from_int(i: int) -> Self;
fn gt(&self, other: &Self) -> bool;
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
trait MyNum {
static fn from_int(int) -> Self;
fn from_int(int) -> Self;
}
pub trait NumExt: MyNum { }
@ -17,7 +17,7 @@ pub trait NumExt: MyNum { }
struct S { v: int }
impl MyNum for S {
static fn from_int(i: int) -> S {
fn from_int(i: int) -> S {
S {
v: i
}

View file

@ -11,7 +11,7 @@
trait MyEq { }
trait MyNum {
static fn from_int(int) -> Self;
fn from_int(int) -> Self;
}
pub trait NumExt: MyEq + MyNum { }
@ -21,7 +21,7 @@ struct S { v: int }
impl MyEq for S { }
impl MyNum for S {
static fn from_int(i: int) -> S {
fn from_int(i: int) -> S {
S {
v: i
}

View file

@ -12,7 +12,7 @@
mod base {
pub trait HasNew<T> {
static pure fn new() -> T;
pure fn new() -> T;
}
pub struct Foo {
@ -20,7 +20,7 @@ mod base {
}
impl ::base::HasNew<Foo> for Foo {
static pure fn new() -> Foo {
pure fn new() -> Foo {
unsafe { io::println("Foo"); }
Foo { dummy: () }
}
@ -31,7 +31,7 @@ mod base {
}
impl ::base::HasNew<Bar> for Bar {
static pure fn new() -> Bar {
pure fn new() -> Bar {
unsafe { io::println("Bar"); }
Bar { dummy: () }
}

View file

@ -12,13 +12,13 @@
// methods!
trait Equal {
static fn isEq(a: Self, b: Self) -> bool;
fn isEq(a: Self, b: Self) -> bool;
}
enum Color { cyan, magenta, yellow, black }
impl Equal for Color {
static fn isEq(a: Color, b: Color) -> bool {
fn isEq(a: Color, b: Color) -> bool {
match (a, b) {
(cyan, cyan) => { true }
(magenta, magenta) => { true }
@ -35,7 +35,7 @@ enum ColorTree {
}
impl Equal for ColorTree {
static fn isEq(a: ColorTree, b: ColorTree) -> bool {
fn isEq(a: ColorTree, b: ColorTree) -> bool {
match (a, b) {
(leaf(x), leaf(y)) => { Equal::isEq(x, y) }
(branch(l1, r1), branch(l2, r2)) => {