]> git.lizzy.rs Git - rust.git/commitdiff
auto trait future compatibility lint
authorleonardo.yvens <leoyvens@gmail.com>
Sat, 14 Oct 2017 21:23:50 +0000 (18:23 -0300)
committerleonardo.yvens <leoyvens@gmail.com>
Fri, 3 Nov 2017 18:13:21 +0000 (16:13 -0200)
31 files changed:
src/libcore/marker.rs
src/librustc_lint/builtin.rs
src/librustc_lint/lib.rs
src/libstd/panic.rs
src/rtstartup/rsbegin.rs
src/rtstartup/rsend.rs
src/test/compile-fail/auto-impl-future-compat.rs [new file with mode: 0644]
src/test/compile-fail/coherence-default-trait-impl.rs
src/test/compile-fail/feature-gate-optin-builtin-traits.rs
src/test/compile-fail/issue-23080-2.rs
src/test/compile-fail/issue-23080.rs
src/test/compile-fail/phantom-oibit.rs
src/test/compile-fail/privacy-sanity.rs
src/test/compile-fail/specialization/defaultimpl/specialization-no-default-trait-implementations.rs
src/test/compile-fail/specialization/specialization-polarity.rs
src/test/compile-fail/syntaxt-default-trait-impls.rs
src/test/compile-fail/traits-inductive-overflow-supertrait-oibit.rs
src/test/compile-fail/typeck-auto-trait-no-supertraits-2.rs
src/test/compile-fail/typeck-auto-trait-no-supertraits.rs
src/test/compile-fail/typeck-auto-trait-no-typeparams.rs
src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs
src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs
src/test/compile-fail/typeck-default-trait-impl-negation.rs
src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs
src/test/run-make/simd-ffi/simd.rs
src/test/run-make/target-specs/foo.rs
src/test/run-pass/auto-traits.rs
src/test/run-pass/issue-29516.rs
src/test/rustdoc/auxiliary/rustdoc-default-impl.rs
src/test/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs
src/test/rustdoc/impl-parts.rs

index f56a9a40332987c804e829fa35d362416c241a53..e47b99ed552d3be974624a6b3a56d367dfe84834 100644 (file)
@@ -46,6 +46,8 @@ pub unsafe trait Send {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 unsafe impl Send for .. { }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -349,6 +351,8 @@ pub unsafe trait Sync {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 unsafe impl Sync for .. { }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -562,6 +566,8 @@ unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {}
 #[lang = "freeze"]
 unsafe trait Freeze {}
 
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 unsafe impl Freeze for .. {}
 
 impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
index 994e85d1d368ecdb4b5dacaa5a06e43d408ad2a9..cd18ca10af04d75ca66eb1facab4b00db9d1eeeb 100644 (file)
 // hardwired lints from librustc
 pub use lint::builtin::*;
 
+declare_lint! {
+    pub AUTO_IMPL,
+    Deny,
+    "The form `impl Foo for .. {}` will be removed, please use `auto trait Foo {}`"
+}
+
+#[derive(Copy, Clone)]
+pub struct AutoImpl;
+
+impl LintPass for AutoImpl {
+    fn get_lints(&self) -> LintArray {
+        lint_array!(AUTO_IMPL)
+    }
+}
+
+impl EarlyLintPass for AutoImpl {
+    fn check_item(&mut self, cx: &EarlyContext, item: &ast::Item) {
+        let msg = "The form `impl Foo for .. {}` will be removed, please use `auto trait Foo {}`";
+        match item.node {
+            ast::ItemKind::AutoImpl(..) => cx.span_lint(AUTO_IMPL, item.span, msg),
+            _ => ()
+        }
+     }
+}
+
 declare_lint! {
     WHILE_TRUE,
     Warn,
index 42fcf377d65396a29034d8f557b4ff6f22d4fcdc..d59d09a8a0670e3b0724ea8f000dd5da94a46a01 100644 (file)
@@ -109,6 +109,7 @@ macro_rules! add_lint_group {
                        AnonymousParameters,
                        IllegalFloatLiteralPattern,
                        UnusedDocComment,
+                       AutoImpl,
                        );
 
     add_early_builtin_with_new!(sess,
@@ -181,6 +182,10 @@ macro_rules! add_lint_group {
     // - Eventually, remove lint
     store.register_future_incompatible(sess,
                                        vec![
+        FutureIncompatibleInfo {
+            id: LintId::of(AUTO_IMPL),
+            reference: "issue #13231 <https://github.com/rust-lang/rust/issues/13231>",
+        },
         FutureIncompatibleInfo {
             id: LintId::of(PRIVATE_IN_PUBLIC),
             reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
index 97b09b7e2ad996b28c244adabffe7ed0d80b2063..385076e50ddeafc0e2341508472fadf589d2c91d 100644 (file)
@@ -188,6 +188,8 @@ pub struct AssertUnwindSafe<T>(
 // * Types like Mutex/RwLock which are explicilty poisoned are unwind safe
 // * Our custom AssertUnwindSafe wrapper is indeed unwind safe
 #[stable(feature = "catch_unwind", since = "1.9.0")]
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 impl UnwindSafe for .. {}
 #[stable(feature = "catch_unwind", since = "1.9.0")]
 impl<'a, T: ?Sized> !UnwindSafe for &'a mut T {}
@@ -221,6 +223,8 @@ impl<T: RefUnwindSafe + ?Sized> UnwindSafe for Arc<T> {}
 // only thing which doesn't implement it (which then transitively applies to
 // everything else).
 #[stable(feature = "catch_unwind", since = "1.9.0")]
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 impl RefUnwindSafe for .. {}
 #[stable(feature = "catch_unwind", since = "1.9.0")]
 impl<T: ?Sized> !RefUnwindSafe for UnsafeCell<T> {}
index 8733c7436d5bd9658280ab37bfa313d479759a5d..d33b52486296f8b3c7fe27e68ec99b9baeb97ab9 100644 (file)
@@ -14,7 +14,7 @@
 // When an executable or dylib image is linked, all user code and libraries are
 // "sandwiched" between these two object files, so code or data from rsbegin.o
 // become first in the respective sections of the image, whereas code and data
-// from rsend.o become the last ones.  This effect can be used to place symbols
+// from rsend.o become the last ones. This effect can be used to place symbols
 // at the beginning or at the end of a section, as well as to insert any required
 // headers or footers.
 //
 trait Sized {}
 #[lang = "sync"]
 trait Sync {}
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 impl Sync for .. {}
 #[lang = "copy"]
 trait Copy {}
 #[lang = "freeze"]
 trait Freeze {}
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 impl Freeze for .. {}
 
 #[lang = "drop_in_place"]
index a6aed3540ddbb8b9d092f137a23322d7a9b49201..410366d0d7ff50f87039c0df29593afe67bff5da 100644 (file)
@@ -23,6 +23,8 @@ impl<T> Sync for T {}
 trait Copy {}
 #[lang = "freeze"]
 trait Freeze {}
+#[allow(unknown_lints)]
+#[allow(auto_impl)]
 impl Freeze for .. {}
 
 #[lang = "drop_in_place"]
diff --git a/src/test/compile-fail/auto-impl-future-compat.rs b/src/test/compile-fail/auto-impl-future-compat.rs
new file mode 100644 (file)
index 0000000..295564c
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2017 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.
+
+trait Foo {}
+impl Foo for .. {}
index ac792d9c233d054b10fa600fdb1ef4e23e16ae78..9c26b8b05f259ce1e8c3aa03b62bce48a1a06ff5 100644 (file)
 
 trait MyTrait { fn foo() {} }
 
+#[allow(auto_impl)]
 impl MyTrait for .. {}
 //~^ ERROR redundant auto implementations of trait `MyTrait`
 
+#[allow(auto_impl)]
 impl MyTrait for .. {}
 
 trait MySafeTrait {}
 
+#[allow(auto_impl)]
 unsafe impl MySafeTrait for .. {}
 //~^ ERROR implementing the trait `MySafeTrait` is not unsafe
 
 unsafe trait MyUnsafeTrait {}
 
+#[allow(auto_impl)]
 impl MyUnsafeTrait for .. {}
 //~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration
 
index 6f57266b3e10233eae9094e3dd241c65bf499b6f..4c5502cec18a851ff4c7d25cb6e07c17dab1f9ea 100644 (file)
@@ -20,6 +20,7 @@ fn dummy(&self) {}
 auto trait AutoDummyTrait {}
 //~^ ERROR auto traits are experimental and possibly buggy
 
+#[allow(auto_impl)]
 impl DummyTrait for .. {}
 //~^ ERROR auto trait implementations are experimental and possibly buggy
 
index 9d20c17674bc374100192f24f3bc31b9750254c2..bf44cd53f67dc45bda84c3d1bbd7c25692315da3 100644 (file)
@@ -17,6 +17,7 @@ unsafe trait Trait {
     type Output;
 }
 
+#[allow(auto_impl)]
 unsafe impl Trait for .. {}
 
 fn call_method<T: Trait>(x: T) {}
index 2e8cba87be5151cc251e32cdf07a2cd2d76aea57..1fb63391d5608df43db2846b69917f97cbccff97 100644 (file)
@@ -19,6 +19,7 @@ fn method(&self) {
     }
 }
 
+#[allow(auto_impl)]
 unsafe impl Trait for .. {}
 
 fn call_method<T: Trait>(x: T) {
index c84927ea266394e41e25e4a14415857a10dff276..1c1cb396a54f200e8a50eaa296dd3c30efd6c4c9 100644 (file)
@@ -18,6 +18,7 @@
 
 unsafe trait Zen {}
 
+#[allow(auto_impl)]
 unsafe impl Zen for .. {}
 
 unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {}
index 933ec3837dfc712a2ab2b0dd3abce3aa95438e8e..34082adb8f9a563a82c674d5fbb723f0e849a676 100644 (file)
@@ -21,6 +21,7 @@ pub struct S {
 }
 struct Ts(pub u8);
 
+#[allow(auto_impl)]
 pub impl MarkerTr for .. {} //~ ERROR unnecessary visibility qualifier
 pub impl Tr for S {  //~ ERROR unnecessary visibility qualifier
     pub fn f() {} //~ ERROR unnecessary visibility qualifier
@@ -49,6 +50,7 @@ pub struct S {
     }
     struct Ts(pub u8);
 
+    #[allow(auto_impl)]
     pub impl MarkerTr for .. {} //~ ERROR unnecessary visibility qualifier
     pub impl Tr for S {  //~ ERROR unnecessary visibility qualifier
         pub fn f() {} //~ ERROR unnecessary visibility qualifier
@@ -80,6 +82,7 @@ pub struct S {
     }
     struct Ts(pub u8);
 
+    #[allow(auto_impl)]
     pub impl MarkerTr for .. {} //~ ERROR unnecessary visibility qualifier
     pub impl Tr for S {  //~ ERROR unnecessary visibility qualifier
         pub fn f() {} //~ ERROR unnecessary visibility qualifier
index fdc39d319c81e10da84fd89879a0c80f17c2a979..cad43ffeacec9afd002cf17275513a612faa147b 100644 (file)
@@ -13,6 +13,7 @@
 
 trait Foo {}
 
+#[allow(auto_impl)]
 default impl Foo for .. {}
 //~^ ERROR `default impl` is not allowed for auto trait implementations
 
index 27a3e31491b823307c28469f58929e2a9cbf9987..c97cb3f6bb70b6c47a6d019ae2e21255a7f8137f 100644 (file)
@@ -15,6 +15,7 @@
 
 trait Foo {}
 
+#[allow(auto_impl)]
 impl Foo for .. {}
 
 impl<T> Foo for T {}
@@ -22,6 +23,7 @@ impl !Foo for u8 {} //~ ERROR E0119
 
 trait Bar {}
 
+#[allow(auto_impl)]
 impl Bar for .. {}
 
 impl<T> !Bar for T {}
index d4a016dfe5b947574bae414052bc4e9130f64db4..45303cbf70025c2e283dbd422631888da47479ff 100644 (file)
@@ -12,6 +12,7 @@
 
 trait MyAutoImpl {}
 
+#[allow(auto_impl)]
 impl<T> MyAutoImpl for .. {}
 //~^ ERROR auto trait implementations are not allowed to have generics
 
index fe0e583b20a3896684bd3010b89e545303d954ca..6c7928f13f8941f3052c74189e808490d1ca110b 100644 (file)
@@ -15,6 +15,7 @@
 #![feature(optin_builtin_traits)]
 
 trait Magic: Copy {} //~ ERROR E0568
+#[allow(auto_impl)]
 impl Magic for .. {}
 
 fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
index f6678ac7c2d8ced8825ee3ee74fb4673c667bc11..173582ed22fdc2523f74fbef0296694abf7c5c2b 100644 (file)
@@ -11,6 +11,7 @@
 #![feature(optin_builtin_traits)]
 
 trait Magic : Sized where Option<Self> : Magic {} //~ ERROR E0568
+#[allow(auto_impl)]
 impl Magic for .. {}
 impl<T:Magic> Magic for T {}
 
index 9497dfb39d7d0b9e792da770afed4de733ef4711..6802f72504b7d65adc1457fc8112254c89948f37 100644 (file)
@@ -35,6 +35,7 @@
 #![feature(optin_builtin_traits)]
 
 trait Magic: Copy {} //~ ERROR E0568
+#[allow(auto_impl)]
 impl Magic for .. {}
 impl<T:Magic> Magic for T {}
 
index 5a852c54869a56145ea3bd7d642674c7a0046289..3c409d1b371eb3ee90eb916adcb660fb1854698b 100644 (file)
@@ -11,4 +11,5 @@
 #![feature(optin_builtin_traits)]
 
 trait Magic<T> {} //~ ERROR E0567
+#[allow(auto_impl)]
 impl Magic<isize> for .. {}
index 8a46d6c76c30fad5dd6a9a20c8c87c4b893ff544..a837d8c9ca74eccf2d989c134f7a5d7ce8a155dd 100644 (file)
@@ -12,6 +12,7 @@
 
 trait MyTrait {}
 
+#[allow(auto_impl)]
 impl MyTrait for .. {}
 
 struct MyS;
index 3d7746b369cc0a65315df93151bf3a63da5f2956..bed184eb4ccca9e70f57e35bae9ccd28692ada6a 100644 (file)
@@ -12,6 +12,7 @@
 
 trait MyTrait {}
 
+#[allow(auto_impl)]
 impl MyTrait for .. {}
 impl<T> !MyTrait for *mut T {}
 
index 8c2658b89a506f0cb3f49269544ff27c067c1349..f3a6d8a342e221c7153bc70f7255270f406de7a1 100644 (file)
 
 trait MyTrait {}
 
+#[allow(auto_impl)]
 impl MyTrait for .. {}
 
 unsafe trait MyUnsafeTrait {}
 
+#[allow(auto_impl)]
 unsafe impl MyUnsafeTrait for .. {}
 
 struct ThisImplsTrait;
index 4d71517e06058fde9f39628a694afe1cd5dc99d7..da3e926d6fc1fdd2375c1795c3cc178047d255df 100644 (file)
@@ -10,6 +10,7 @@
 
 #![feature(optin_builtin_traits)]
 
+#[allow(auto_impl)]
 impl Copy for .. {} //~ ERROR E0318
      //~^ NOTE `Copy` trait not defined in this crate
 fn main() {}
index 8ab8f4715755ddbef149777ab726c29d023afe0f..185476fb704f7fe4176766abe11d54c7c3e2025d 100644 (file)
@@ -81,4 +81,5 @@ pub mod marker {
 
 #[lang = "freeze"]
 trait Freeze {}
+#[allow(auto_impl)]
 impl Freeze for .. {}
index af24c3b460b2e844d43123eb9aaf9f6725967996..a0feb72702834e74eed0166eaeab601f322cbfd3 100644 (file)
@@ -19,6 +19,7 @@ trait Sized { }
 
 #[lang = "freeze"]
 trait Freeze {}
+#[allow(auto_impl)]
 impl Freeze for .. {}
 
 #[lang="start"]
index 94fa104e5b2bee924be576b4fcc01851e8548713..752f5a11375adc68bc48a85fb368963f6c758496 100644 (file)
@@ -12,6 +12,7 @@
 
 auto trait Auto {}
 // Redundant but accepted until we remove it.
+#[allow(auto_impl)]
 impl Auto for .. {}
 
 unsafe auto trait AutoUnsafe {}
index b586abc29e243a2f3a8fa5382aba03b13c1af75c..5fa0a002a10db9071c31f3f4418bda4ffccbc959 100644 (file)
@@ -11,6 +11,7 @@
 #![feature(optin_builtin_traits)]
 
 trait NotSame {}
+#[allow(auto_impl)]
 impl NotSame for .. {}
 impl<A> !NotSame for (A, A) {}
 
index 52bd386ba595bb9ae064a21e61805613e8675bf6..4fd55bd482cd998029fb89eb2dcd477d999414c3 100644 (file)
@@ -16,6 +16,7 @@ pub mod bar {
 
     pub trait Bar {}
 
+    #[allow(auto_impl)]
     impl Bar for .. {}
 
     pub trait Foo {
index 6e8f80c8f5f9f1a2af5211223891e191dce930c4..d886778278dfd3dd86a35bc16c5096961eaca876 100644 (file)
@@ -12,4 +12,5 @@
 
 pub trait AnOibit {}
 
+#[allow(auto_impl)]
 impl AnOibit for .. {}
index 48ef4b6be66dea34e4d204f8ce7eba6bce392b74..f74f66ce7290551849082781c0f7184313d6e956 100644 (file)
@@ -12,6 +12,7 @@
 
 pub trait AnOibit {}
 
+#[allow(auto_impl)]
 impl AnOibit for .. {}
 
 pub struct Foo<T> { field: T }