forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes rust-lang#2074. Closes rust-lang#5008. Closes rust-lang#7519. Closes rust-lang#7673. Closes rust-lang#7770. Closes rust-lang#8171.
- Loading branch information
Showing
5 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/test/run-pass/issue-5008-borrowed-traitobject-method-call.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 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. | ||
|
||
/* | ||
#5008 cast to &Trait causes code to segfault on method call | ||
It fixes itself if the &Trait is changed to @Trait. | ||
*/ | ||
|
||
trait Debuggable { | ||
fn debug_name(&self) -> ~str; | ||
} | ||
|
||
#[deriving(Clone)] | ||
struct Thing { | ||
name: ~str, | ||
} | ||
|
||
impl Thing { | ||
fn new() -> Thing { Thing { name: ~"dummy" } } | ||
} | ||
|
||
impl Debuggable for Thing { | ||
fn debug_name(&self) -> ~str { self.name.clone() } | ||
} | ||
|
||
fn print_name(x: &Debuggable) | ||
{ | ||
println(fmt!("debug_name = %s", x.debug_name())); | ||
} | ||
|
||
fn main() { | ||
let thing = Thing::new(); | ||
print_name(&thing as &Debuggable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2013 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. | ||
|
||
/* | ||
#7519 ICE pattern matching unit in function argument | ||
*/ | ||
|
||
fn foo(():()) { } | ||
|
||
fn main() { | ||
foo(()); | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2013 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. | ||
|
||
// xfail-pretty #9253 pretty printer doesn't preserve the bounds on trait objects | ||
|
||
/* | ||
#7673 Polymorphically creating traits barely works | ||
*/ | ||
|
||
fn main() {} | ||
|
||
trait A {} | ||
impl<T: 'static> A for T {} | ||
|
||
fn owned1<T: 'static>(a: T) { ~a as ~A:; } /* note `:` */ | ||
fn owned2<T: 'static>(a: ~T) { a as ~A:; } | ||
fn owned3<T: 'static>(a: ~T) { ~a as ~A:; } | ||
|
||
fn managed1<T: 'static>(a: T) { @a as @A; } | ||
fn managed2<T: 'static>(a: @T) { a as @A; } | ||
fn managed3<T: 'static>(a: @T) { @a as @A; } |
25 changes: 25 additions & 0 deletions
25
src/test/run-pass/issue-8171-default-method-self-inherit-builtin-trait.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2013 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. | ||
|
||
/* | ||
#8171 Self is not recognised as implementing kinds in default method implementations | ||
*/ | ||
|
||
fn require_send<T: Send>(_: T){} | ||
|
||
trait TragicallySelfIsNotSend: Send { | ||
fn x(self) { | ||
require_send(self); | ||
} | ||
} | ||
|
||
fn main(){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2013 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. | ||
|
||
/* | ||
#7770 ICE with sibling methods containing same-name-enum containing | ||
same-name-member | ||
If you have two methods in an impl block, each containing an enum | ||
(with the same name), each containing at least one value with the same | ||
name, rustc gives the same LLVM symbol for the two of them and fails, | ||
as it does not include the method name in the symbol name. | ||
*/ | ||
|
||
pub struct Foo; | ||
impl Foo { | ||
pub fn foo() { | ||
enum Panic { Common }; | ||
} | ||
pub fn bar() { | ||
enum Panic { Common }; | ||
} | ||
} | ||
|
||
/* | ||
#2074 duplicate symbols with enum in boxed closure | ||
*/ | ||
|
||
fn foo() { | ||
let one: @fn() -> uint = || { | ||
enum r { a } | ||
a as uint | ||
}; | ||
let two: @fn() -> uint = || { | ||
enum r { a } | ||
a as uint | ||
}; | ||
one(); two(); | ||
} | ||
|
||
fn main() {} |