Skip to content

Commit cab166e

Browse files
committed
---
yaml --- r: 62943 b: refs/heads/snap-stage3 c: 231aea6 h: refs/heads/master i: 62941: 555c17e 62939: 6d094ef 62935: 8bed276 62927: 32f2d23 62911: 4926ace v: v3
1 parent de54c93 commit cab166e

20 files changed

+101
-172
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ecd08b989ae006660929bce6b719d9f7bc34a7fe
4+
refs/heads/snap-stage3: 231aea6d6e464f2676eba4ce4c30f2126fe262b7
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/metadata/encoder.rs

Lines changed: 30 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -374,90 +374,50 @@ fn encode_path(ecx: @EncodeContext,
374374
fn encode_reexported_static_method(ecx: @EncodeContext,
375375
ebml_w: &mut writer::Encoder,
376376
exp: &middle::resolve::Export2,
377-
method_def_id: def_id,
378-
method_ident: ident) {
379-
debug!("(encode reexported static method) %s::%s",
380-
*exp.name, *ecx.tcx.sess.str_of(method_ident));
377+
m: @ty::Method) {
378+
debug!("(encode static trait method) reexport '%s::%s'",
379+
*exp.name, *ecx.tcx.sess.str_of(m.ident));
381380
ebml_w.start_tag(tag_items_data_item_reexport);
382381
ebml_w.start_tag(tag_items_data_item_reexport_def_id);
383-
ebml_w.wr_str(def_to_str(method_def_id));
382+
ebml_w.wr_str(def_to_str(m.def_id));
384383
ebml_w.end_tag();
385384
ebml_w.start_tag(tag_items_data_item_reexport_name);
386-
ebml_w.wr_str(*exp.name + "::" + *ecx.tcx.sess.str_of(method_ident));
385+
ebml_w.wr_str(*exp.name + "::" + *ecx.tcx.sess.str_of(m.ident));
387386
ebml_w.end_tag();
388387
ebml_w.end_tag();
389388
}
390389

391-
fn encode_reexported_static_base_methods(ecx: @EncodeContext,
392-
ebml_w: &mut writer::Encoder,
393-
exp: &middle::resolve::Export2)
394-
-> bool {
395-
match ecx.tcx.base_impls.find(&exp.def_id) {
396-
Some(implementations) => {
397-
for implementations.each |&base_impl| {
398-
for base_impl.methods.each |&m| {
399-
if m.explicit_self == ast::sty_static {
400-
encode_reexported_static_method(ecx, ebml_w, exp,
401-
m.did, m.ident);
402-
}
403-
}
404-
}
405-
406-
true
407-
}
408-
None => { false }
409-
}
410-
}
411-
412-
fn encode_reexported_static_trait_methods(ecx: @EncodeContext,
413-
ebml_w: &mut writer::Encoder,
414-
exp: &middle::resolve::Export2)
415-
-> bool {
416-
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
417-
Some(methods) => {
418-
for methods.each |&m| {
419-
if m.explicit_self == ast::sty_static {
420-
encode_reexported_static_method(ecx, ebml_w, exp,
421-
m.def_id, m.ident);
422-
}
423-
}
424-
425-
true
426-
}
427-
None => { false }
428-
}
429-
}
430-
431390
fn encode_reexported_static_methods(ecx: @EncodeContext,
432391
ebml_w: &mut writer::Encoder,
433392
mod_path: &[ast_map::path_elt],
434393
exp: &middle::resolve::Export2) {
435-
match ecx.tcx.items.find(&exp.def_id.node) {
436-
Some(&ast_map::node_item(item, path)) => {
437-
let original_name = ecx.tcx.sess.str_of(item.ident);
438-
439-
//
440-
// We don't need to reexport static methods on items
441-
// declared in the same module as our `pub use ...` since
442-
// that's done when we encode the item itself.
443-
//
444-
// The only exception is when the reexport *changes* the
445-
// name e.g. `pub use Foo = self::Bar` -- we have
446-
// encoded metadata for static methods relative to Bar,
447-
// but not yet for Foo.
448-
//
449-
if mod_path != *path || *exp.name != *original_name {
450-
if !encode_reexported_static_base_methods(ecx, ebml_w, exp) {
451-
if encode_reexported_static_trait_methods(ecx, ebml_w, exp) {
452-
debug!(fmt!("(encode reexported static methods) %s \
453-
[trait]",
454-
*original_name));
394+
match ecx.tcx.trait_methods_cache.find(&exp.def_id) {
395+
Some(methods) => {
396+
match ecx.tcx.items.find(&exp.def_id.node) {
397+
Some(&ast_map::node_item(item, path)) => {
398+
let original_name = ecx.tcx.sess.str_of(item.ident);
399+
400+
//
401+
// We don't need to reexport static methods on traits
402+
// declared in the same module as our `pub use ...` since
403+
// that's done when we encode the trait item.
404+
//
405+
// The only exception is when the reexport *changes* the
406+
// name e.g. `pub use Foo = self::Bar` -- we have
407+
// encoded metadata for static methods relative to Bar,
408+
// but not yet for Foo.
409+
//
410+
if mod_path != *path || *exp.name != *original_name {
411+
for methods.each |&m| {
412+
if m.explicit_self == ast::sty_static {
413+
encode_reexported_static_method(ecx,
414+
ebml_w,
415+
exp, m);
416+
}
417+
}
455418
}
456419
}
457-
else {
458-
debug!(fmt!("(encode reexported static methods) %s [base]",
459-
*original_name));
460-
}
420+
_ => {}
461421
}
462422
}
463423
_ => {}

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@ struct ctxt_ {
307307
// Maps a trait onto a mapping from self-ty to impl
308308
trait_impls: @mut HashMap<ast::def_id, @mut HashMap<t, @Impl>>,
309309

310-
// Maps a base type to its impl
311-
base_impls: @mut HashMap<ast::def_id, @mut ~[@Impl]>,
312-
313310
// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
314311
// present in this set can be warned about.
315312
used_unsafe: @mut HashSet<ast::node_id>,
@@ -975,7 +972,6 @@ pub fn mk_ctxt(s: session::Session,
975972
destructor_for_type: @mut HashMap::new(),
976973
destructors: @mut HashSet::new(),
977974
trait_impls: @mut HashMap::new(),
978-
base_impls: @mut HashMap::new(),
979975
used_unsafe: @mut HashSet::new(),
980976
used_mut_nodes: @mut HashSet::new(),
981977
}
@@ -3704,21 +3700,6 @@ pub fn trait_method(cx: ctxt, trait_did: ast::def_id, idx: uint) -> @Method {
37043700
ty::method(cx, method_def_id)
37053701
}
37063702

3707-
3708-
pub fn add_base_impl(cx: ctxt, base_def_id: def_id, implementation: @Impl) {
3709-
let implementations;
3710-
match cx.base_impls.find(&base_def_id) {
3711-
None => {
3712-
implementations = @mut ~[];
3713-
cx.base_impls.insert(base_def_id, implementations);
3714-
}
3715-
Some(&existing) => {
3716-
implementations = existing;
3717-
}
3718-
}
3719-
implementations.push(implementation);
3720-
}
3721-
37223703
pub fn trait_methods(cx: ctxt, trait_did: ast::def_id) -> @~[@Method] {
37233704
match cx.trait_methods_cache.find(&trait_did) {
37243705
Some(&methods) => methods,

branches/snap-stage3/src/librustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
455455
}
456456
_ => {
457457
tcx.sess.span_fatal(ast_ty.span,
458-
"found type name used as a variable");
458+
fmt!("found value name used as a type: %?", a_def));
459459
}
460460
}
461461
}

branches/snap-stage3/src/librustc/middle/typeck/coherence.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
146146
}
147147
_ => {
148148
fail!("get_base_type() returned a type that wasn't an \
149-
enum, struct, or trait");
149+
enum, class, or trait");
150150
}
151151
}
152152
}
@@ -313,7 +313,6 @@ impl CoherenceChecker {
313313
implementation = existing_implementation;
314314
}
315315
}
316-
317316
self.add_inherent_method(base_type_def_id,
318317
implementation);
319318
}
@@ -435,8 +434,6 @@ impl CoherenceChecker {
435434
}
436435

437436
implementation_list.push(implementation);
438-
439-
ty::add_base_impl(self.crate_context.tcx, base_def_id, implementation);
440437
}
441438

442439
pub fn add_trait_method(&self, trait_id: def_id, implementation: @Impl) {

branches/snap-stage3/src/libstd/comm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ mod pipesy {
376376
priv use core::kinds::Owned;
377377
use ptr::to_mut_unsafe_ptr;
378378

379-
pub fn init<T: Owned>() -> (server::Oneshot<T>, client::Oneshot<T>) {
379+
pub fn init<T: Owned>() -> (client::Oneshot<T>, server::Oneshot<T>) {
380380
pub use core::pipes::HasBuffer;
381381

382382
let buffer = ~::core::pipes::Buffer {
@@ -466,7 +466,7 @@ mod pipesy {
466466

467467
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
468468
pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) {
469-
let (port, chan) = oneshot::init();
469+
let (chan, port) = oneshot::init();
470470
(PortOne::new(port), ChanOne::new(chan))
471471
}
472472

@@ -550,7 +550,7 @@ mod pipesy {
550550
pub mod streamp {
551551
priv use core::kinds::Owned;
552552

553-
pub fn init<T: Owned>() -> (server::Open<T>, client::Open<T>) {
553+
pub fn init<T: Owned>() -> (client::Open<T>, server::Open<T>) {
554554
pub use core::pipes::HasBuffer;
555555
::core::pipes::entangle()
556556
}
@@ -567,7 +567,7 @@ mod pipesy {
567567
::core::option::Option<Open<T>> {
568568
{
569569
use super::data;
570-
let (s, c) = ::core::pipes::entangle();
570+
let (c, s) = ::core::pipes::entangle();
571571
let message = data(x_0, s);
572572
if ::core::pipes::send(pipe, message) {
573573
::core::pipes::rt::make_some(c)
@@ -579,7 +579,7 @@ mod pipesy {
579579
pub fn data<T: Owned>(pipe: Open<T>, x_0: T) -> Open<T> {
580580
{
581581
use super::data;
582-
let (s, c) = ::core::pipes::entangle();
582+
let (c, s) = ::core::pipes::entangle();
583583
let message = data(x_0, s);
584584
::core::pipes::send(pipe, message);
585585
c
@@ -615,7 +615,7 @@ mod pipesy {
615615
616616
*/
617617
pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
618-
let (s, c) = streamp::init();
618+
let (c, s) = streamp::init();
619619

620620
(Port {
621621
endp: Some(s)

branches/snap-stage3/src/libstd/pipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ pub fn packet<T>() -> *mut Packet<T> {
237237
pub fn entangle_buffer<T:Owned,Tstart:Owned>(
238238
mut buffer: ~Buffer<T>,
239239
init: &fn(*libc::c_void, x: &mut T) -> *mut Packet<Tstart>)
240-
-> (RecvPacketBuffered<Tstart, T>, SendPacketBuffered<Tstart, T>) {
240+
-> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>) {
241241
unsafe {
242242
let p = init(transmute_copy(&buffer), &mut buffer.data);
243243
forget(buffer);
244-
(RecvPacketBuffered(p), SendPacketBuffered(p))
244+
(SendPacketBuffered(p), RecvPacketBuffered(p))
245245
}
246246
}
247247

@@ -775,9 +775,9 @@ pub fn RecvPacketBuffered<T,Tbuffer>(p: *mut Packet<T>)
775775
}
776776
}
777777

778-
pub fn entangle<T>() -> (RecvPacket<T>, SendPacket<T>) {
778+
pub fn entangle<T>() -> (SendPacket<T>, RecvPacket<T>) {
779779
let p = packet();
780-
(RecvPacket(p), SendPacket(p))
780+
(SendPacket(p), RecvPacket(p))
781781
}
782782

783783
/** Receives a message from one of two endpoints.

branches/snap-stage3/src/libsyntax/ext/pipes/pipec.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ impl gen_send for message {
8989
}
9090
else {
9191
let pat = match (this.dir, next.dir) {
92-
(send, send) => "(s, c)",
93-
(send, recv) => "(c, s)",
94-
(recv, send) => "(c, s)",
95-
(recv, recv) => "(s, c)"
92+
(send, send) => "(c, s)",
93+
(send, recv) => "(s, c)",
94+
(recv, send) => "(s, c)",
95+
(recv, recv) => "(c, s)"
9696
};
9797

9898
body += fmt!("let %s = ::std::pipes::entangle();\n", pat);
@@ -317,13 +317,30 @@ impl gen_init for protocol {
317317
let start_state = self.states[0];
318318
319319
let body = if !self.is_bounded() {
320-
quote_expr!( ::std::pipes::entangle() )
320+
match start_state.dir {
321+
send => quote_expr!( ::std::pipes::entangle() ),
322+
recv => {
323+
quote_expr!({
324+
let (s, c) = ::std::pipes::entangle();
325+
(c, s)
326+
})
327+
}
328+
}
321329
}
322330
else {
323-
self.gen_init_bounded(ext_cx)
331+
let body = self.gen_init_bounded(ext_cx);
332+
match start_state.dir {
333+
send => body,
334+
recv => {
335+
quote_expr!({
336+
let (s, c) = $body;
337+
(c, s)
338+
})
339+
}
340+
}
324341
};
325342
326-
cx.parse_item(fmt!("pub fn init%s() -> (server::%s, client::%s)\
343+
cx.parse_item(fmt!("pub fn init%s() -> (client::%s, server::%s)\
327344
{ pub use std::pipes::HasBuffer; %s }",
328345
start_state.generics.to_source(cx),
329346
start_state.to_ty(cx).to_source(cx),

branches/snap-stage3/src/test/auxiliary/reexported_static_methods.rs renamed to branches/snap-stage3/src/test/auxiliary/mod_trait_with_static_methods_lib.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
pub use sub_foo::Foo;
1212
pub use Baz = self::Bar;
13-
pub use sub_foo::Boz;
14-
pub use sub_foo::Bort;
1513

1614
pub trait Bar {
1715
pub fn bar() -> Self;
@@ -30,24 +28,4 @@ pub mod sub_foo {
3028
pub fn foo() -> int { 42 }
3129
}
3230

33-
pub struct Boz {
34-
unused_str: ~str
35-
}
36-
37-
pub impl Boz {
38-
pub fn boz(i: int) -> bool {
39-
i > 0
40-
}
41-
}
42-
43-
pub enum Bort {
44-
Bort1,
45-
Bort2
46-
}
47-
48-
pub impl Bort {
49-
pub fn bort() -> ~str {
50-
~"bort()"
51-
}
52-
}
5331
}

branches/snap-stage3/src/test/bench/msgsend-ring-pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() {
7373
let num_tasks = uint::from_str(args[1]).get();
7474
let msg_per_task = uint::from_str(args[2]).get();
7575

76-
let (num_port, num_chan) = ring::init();
76+
let (num_chan, num_port) = ring::init();
7777
let mut num_chan = Cell(num_chan);
7878

7979
let start = time::precise_time_s();
@@ -83,7 +83,7 @@ fn main() {
8383

8484
for uint::range(1u, num_tasks) |i| {
8585
//error!("spawning %?", i);
86-
let (num_port, new_chan) = ring::init();
86+
let (new_chan, num_port) = ring::init();
8787
let num_chan2 = Cell(num_chan.take());
8888
let num_port = Cell(num_port);
8989
let new_future = do future::spawn || {

0 commit comments

Comments
 (0)