-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make TypeContents consider the type
T
to be reachable via *T
poin…
…ters Fixes #9509
- Loading branch information
1 parent
3d1f3f4
commit 71acc54
Showing
4 changed files
with
128 additions
and
12 deletions.
There are no files selected for viewing
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
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
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,56 @@ | ||
// Copyright 2012 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. | ||
|
||
// Test which of the builtin types are considered freezeable. | ||
|
||
fn assert_freeze<T:Freeze>() { } | ||
trait Dummy { } | ||
|
||
fn test<'a,T,U:Freeze>(_: &'a int) { | ||
// lifetime pointers are ok... | ||
assert_freeze::<&'static int>(); | ||
assert_freeze::<&'a int>(); | ||
assert_freeze::<&'a str>(); | ||
assert_freeze::<&'a [int]>(); | ||
|
||
// ...unless they are mutable | ||
assert_freeze::<&'static mut int>(); //~ ERROR does not fulfill `Freeze` | ||
assert_freeze::<&'a mut int>(); //~ ERROR does not fulfill `Freeze` | ||
|
||
// ~ pointers are ok | ||
assert_freeze::<~int>(); | ||
assert_freeze::<~str>(); | ||
assert_freeze::<~[int]>(); | ||
|
||
// but not if they own a bad thing | ||
assert_freeze::<~&'a mut int>(); //~ ERROR does not fulfill `Freeze` | ||
|
||
// careful with object types, who knows what they close over... | ||
assert_freeze::<&'a Dummy>(); //~ ERROR does not fulfill `Freeze` | ||
assert_freeze::<~Dummy>(); //~ ERROR does not fulfill `Freeze` | ||
|
||
// ...unless they are properly bounded | ||
assert_freeze::<&'a Dummy:Freeze>(); | ||
assert_freeze::<&'static Dummy:Freeze>(); | ||
assert_freeze::<~Dummy:Freeze>(); | ||
|
||
// ...but even then the pointer overrides | ||
assert_freeze::<&'a mut Dummy:Freeze>(); //~ ERROR does not fulfill `Freeze` | ||
|
||
// closures are like an `&mut` object | ||
assert_freeze::<&fn()>(); //~ ERROR does not fulfill `Freeze` | ||
|
||
// unsafe ptrs are ok unless they point at unfreezeable things | ||
assert_freeze::<*int>(); | ||
assert_freeze::<*&'a mut int>(); //~ ERROR does not fulfill `Freeze` | ||
} | ||
|
||
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,59 @@ | ||
// Copyright 2012 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. | ||
|
||
// Test which of the builtin types are considered sendable. | ||
|
||
fn assert_send<T:Send>() { } | ||
trait Dummy { } | ||
|
||
fn test<'a,T,U:Send>(_: &'a int) { | ||
// lifetime pointers with 'static lifetime are ok | ||
assert_send::<&'static int>(); | ||
assert_send::<&'static str>(); | ||
assert_send::<&'static [int]>(); | ||
|
||
// whether or not they are mutable | ||
assert_send::<&'static mut int>(); | ||
|
||
// otherwise lifetime pointers are not ok | ||
assert_send::<&'a int>(); //~ ERROR does not fulfill `Send` | ||
assert_send::<&'a str>(); //~ ERROR does not fulfill `Send` | ||
assert_send::<&'a [int]>(); //~ ERROR does not fulfill `Send` | ||
|
||
// ~ pointers are ok | ||
assert_send::<~int>(); | ||
assert_send::<~str>(); | ||
assert_send::<~[int]>(); | ||
|
||
// but not if they own a bad thing | ||
assert_send::<~&'a int>(); //~ ERROR does not fulfill `Send` | ||
|
||
// careful with object types, who knows what they close over... | ||
assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send` | ||
assert_send::<&'a Dummy>(); //~ ERROR does not fulfill `Send` | ||
assert_send::<&'a Dummy:Send>(); //~ ERROR does not fulfill `Send` | ||
assert_send::<~Dummy:>(); //~ ERROR does not fulfill `Send` | ||
|
||
// ...unless they are properly bounded | ||
assert_send::<&'static Dummy:Send>(); | ||
assert_send::<~Dummy:Send>(); | ||
|
||
// but closure and object types can have lifetime bounds which make | ||
// them not ok (FIXME #5121) | ||
// assert_send::<~fn:'a()>(); // ERROR does not fulfill `Send` | ||
// assert_send::<~Dummy:'a>(); // ERROR does not fulfill `Send` | ||
|
||
// unsafe ptrs are ok unless they point at unsendable things | ||
assert_send::<*int>(); | ||
assert_send::<*&'a int>(); //~ ERROR does not fulfill `Send` | ||
} | ||
|
||
fn main() { | ||
} |
71acc54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pcwalton
at nikomatsakis@71acc54
71acc54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging nikomatsakis/rust/issue-10157-TypeContents-refactor = 71acc54 into auto
71acc54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nikomatsakis/rust/issue-10157-TypeContents-refactor = 71acc54 merged ok, testing candidate = fdc830d
71acc54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2350
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/196
success: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/196
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2354
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1459
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2368
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2369
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/1536
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2354
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/1458
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1460
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/2132
71acc54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = fdc830d