Skip to content

Commit 6764711

Browse files
committed
---
yaml --- r: 73662 b: refs/heads/dist-snap c: ddbd1aa h: refs/heads/master v: v3
1 parent 8f671f0 commit 6764711

File tree

7 files changed

+64
-124
lines changed

7 files changed

+64
-124
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 24e85ac82d000a71276eb4cf2090bd176a3638bf
10+
refs/heads/dist-snap: ddbd1aa883b0325f09492113a483c9c888e7576a
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/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/dist-snap/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/dist-snap/src/test/auxiliary/reexported_static_methods.rs renamed to branches/dist-snap/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/dist-snap/src/test/run-pass/reexported-static-methods-cross-crate.rs renamed to branches/dist-snap/src/test/run-pass/trait_with_static_methods_cross_crate.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@
99
// except according to those terms.
1010

1111
// xfail-fast
12-
// aux-build:reexported_static_methods.rs
13-
extern mod reexported_static_methods;
12+
// aux-build:mod_trait_with_static_methods_lib.rs
13+
extern mod mod_trait_with_static_methods_lib;
1414

15-
use reexported_static_methods::Foo;
16-
use reexported_static_methods::Baz;
17-
use reexported_static_methods::Boz;
18-
use reexported_static_methods::Bort;
15+
use mod_trait_with_static_methods_lib::Foo;
16+
use mod_trait_with_static_methods_lib::Baz;
1917

2018
pub fn main() {
2119
assert_eq!(42, Foo::foo());
2220
assert_eq!(84, Baz::bar());
23-
assert!(Boz::boz(1));
24-
assert_eq!(~"bort()", Bort::bort());
2521
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Make sure the destructor is run for unit-like structs.
12+
13+
use std::task;
14+
15+
struct Foo;
16+
17+
impl Drop for Foo {
18+
fn finalize(&self) {
19+
fail!("This failure should happen.");
20+
}
21+
}
22+
23+
fn main() {
24+
let x = do task::try {
25+
let _b = Foo;
26+
};
27+
assert_eq!(x, Err(()));
28+
}

0 commit comments

Comments
 (0)