about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcore/core.rc1
-rw-r--r--src/librustc/middle/lint.rs29
-rw-r--r--src/libsyntax/print/pprust.rs29
-rw-r--r--src/test/compile-fail/issue-2063.rs2
-rw-r--r--src/test/compile-fail/issue-2718-a.rs2
-rw-r--r--src/test/run-pass/coherence-copy-bound.rs13
-rw-r--r--src/test/run-pass/operator-overloading-explicit-self.rs26
7 files changed, 36 insertions, 66 deletions
diff --git a/src/libcore/core.rc b/src/libcore/core.rc
index 4d686c8ab33..db1dc1e28aa 100644
--- a/src/libcore/core.rc
+++ b/src/libcore/core.rc
@@ -52,6 +52,7 @@ Implicitly, all crates behave as if they included the following prologue:
 #[deny(non_camel_case_types)];
 #[allow(deprecated_mutable_fields)];
 #[deny(deprecated_self)];
+#[allow(deprecated_drop)];
 
 // On Linux, link to the runtime with -lrt.
 #[cfg(target_os = "linux")]
diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs
index 5ff731a27f0..93f0557028e 100644
--- a/src/librustc/middle/lint.rs
+++ b/src/librustc/middle/lint.rs
@@ -77,6 +77,7 @@ pub enum lint {
     default_methods,
     deprecated_self,
     deprecated_mutable_fields,
+    deprecated_drop,
 
     managed_heap_memory,
     owned_heap_memory,
@@ -251,6 +252,13 @@ pub fn get_lint_dict() -> LintDict {
             default: deny
         }),
 
+        (@~"deprecated_drop",
+         @LintSpec {
+            lint: deprecated_drop,
+            desc: "deprecated \"drop\" notation for the destructor",
+            default: deny
+        }),
+
         /* FIXME(#3266)--make liveness warnings lintable
         (@~"unused_variable",
          @LintSpec {
@@ -483,6 +491,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
     check_item_default_methods(cx, i);
     check_item_deprecated_self(cx, i);
     check_item_deprecated_mutable_fields(cx, i);
+    check_item_deprecated_drop(cx, i);
 }
 
 // Take a visitor, and modify it so that it will not proceed past subitems.
@@ -720,6 +729,26 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
     }
 }
 
+fn check_item_deprecated_drop(cx: ty::ctxt, item: @ast::item) {
+    match item.node {
+        ast::item_struct(struct_def, _) => {
+            match struct_def.dtor {
+                None => {}
+                Some(ref dtor) => {
+                    cx.sess.span_lint(deprecated_drop,
+                                      item.id,
+                                      item.id,
+                                      dtor.span,
+                                      ~"`drop` notation for destructors is \
+                                        deprecated; implement the `Drop` \
+                                        trait instead");
+                }
+            }
+        }
+        _ => {}
+    }
+}
+
 fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
 
     fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index e7e2435587e..49899fdeec4 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -612,36 +612,11 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
 pub fn print_enum_def(s: @ps, enum_definition: ast::enum_def,
                       generics: &ast::Generics, ident: ast::ident,
                       span: codemap::span, visibility: ast::visibility) {
-    let mut newtype =
-        vec::len(enum_definition.variants) == 1u &&
-        ident == enum_definition.variants[0].node.name;
-    if newtype {
-        match enum_definition.variants[0].node.kind {
-            ast::tuple_variant_kind(ref args) if args.len() == 1 => {}
-            _ => newtype = false
-        }
-    }
-    if newtype {
-        ibox(s, indent_unit);
-        word_space(s, visibility_qualified(visibility, ~"enum"));
-    } else {
-        head(s, visibility_qualified(visibility, ~"enum"));
-    }
-
+    head(s, visibility_qualified(visibility, ~"enum"));
     print_ident(s, ident);
     print_generics(s, generics);
     space(s.s);
-    if newtype {
-        word_space(s, ~"=");
-        match /*bad*/ copy enum_definition.variants[0].node.kind {
-            ast::tuple_variant_kind(args) => print_type(s, args[0].ty),
-            _ => fail!(~"newtype syntax with struct?")
-        }
-        word(s.s, ~";");
-        end(s);
-    } else {
-        print_variants(s, enum_definition.variants, span);
-    }
+    print_variants(s, enum_definition.variants, span);
 }
 
 pub fn print_variants(s: @ps,
diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs
index 2f174671bd9..0ebf0218efe 100644
--- a/src/test/compile-fail/issue-2063.rs
+++ b/src/test/compile-fail/issue-2063.rs
@@ -1,3 +1,5 @@
+// xfail-test
+
 // 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.
diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs
index 318982c3b13..8afaf8995c2 100644
--- a/src/test/compile-fail/issue-2718-a.rs
+++ b/src/test/compile-fail/issue-2718-a.rs
@@ -1,3 +1,5 @@
+// xfail-test
+
 // 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.
diff --git a/src/test/run-pass/coherence-copy-bound.rs b/src/test/run-pass/coherence-copy-bound.rs
deleted file mode 100644
index 9921389da66..00000000000
--- a/src/test/run-pass/coherence-copy-bound.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-trait X {}
-
-impl<A:Copy> X for A {}
-
-struct S {
-    x: int,
-    drop {}
-}
-
-impl X for S {}
-
-pub fn main(){}
-
diff --git a/src/test/run-pass/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs
deleted file mode 100644
index 3d2fd649f15..00000000000
--- a/src/test/run-pass/operator-overloading-explicit-self.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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.
-
-struct S {
-    x: int
-}
-
-pub impl S {
-    pure fn add(&self, other: &S) -> S {
-        S { x: self.x + other.x }
-    }
-}
-
-pub fn main() {
-    let mut s = S { x: 1 };
-    s += S { x: 2 };
-    fail_unless!(s.x == 3);
-}
-