From 2885b9e35adfdcfaf25663eb12bdb8c5ee1bfd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Wed, 2 May 2018 14:32:32 +0700 Subject: [PATCH 1/4] lint: deny incoherent_fundamental_impls by default Warn the ecosystem of the pending intent-to-disallow in #49799. --- src/librustc/lint/builtin.rs | 2 +- src/test/compile-fail/issue-43355.rs | 2 -- src/test/run-pass/issue-43355.rs | 36 ---------------------------- 3 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 src/test/run-pass/issue-43355.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 109edffcde38a..2bc31b00eb73b 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -208,7 +208,7 @@ declare_lint! { declare_lint! { pub INCOHERENT_FUNDAMENTAL_IMPLS, - Warn, + Deny, "potentially-conflicting impls were erroneously allowed" } diff --git a/src/test/compile-fail/issue-43355.rs b/src/test/compile-fail/issue-43355.rs index 4db5c84df9a63..d793a78799a70 100644 --- a/src/test/compile-fail/issue-43355.rs +++ b/src/test/compile-fail/issue-43355.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(incoherent_fundamental_impls)] - pub trait Trait1 { type Output; } diff --git a/src/test/run-pass/issue-43355.rs b/src/test/run-pass/issue-43355.rs deleted file mode 100644 index 19431a6a42923..0000000000000 --- a/src/test/run-pass/issue-43355.rs +++ /dev/null @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that the code for issue #43355 can run without an ICE, please remove -// this test when it becomes an hard error. - -pub trait Trait1 { - type Output; -} -pub trait Trait2 {} - -impl Trait1 for T where T: Trait2 { - type Output = (); -} -impl Trait1> for A { - type Output = i32; -} - -pub struct A; - -fn f>>() { - println!("k: {}", ::std::mem::size_of::<>>::Output>()); -} - -pub fn g>>() { - f::(); -} - -fn main() {} From 2fce5b34f60891e40638bb9e1932cfb0a88f6ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Thu, 3 May 2018 07:52:36 +0700 Subject: [PATCH 2/4] doc: move incoherent_fundamental_impls to deny-by-default listing --- .../src/lints/listing/deny-by-default.md | 41 +++++++++++++++++++ .../src/lints/listing/warn-by-default.md | 41 ------------------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index e7ec6af8be1e3..eea1edb91acea 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -239,3 +239,44 @@ error: invalid `crate_type` value | ^^^^^^^^^^^^^^^^^^^^ | ``` + +## incoherent-fundamental-impls + +This lint detects potentially-conflicting impls that were erroneously allowed. Some +example code that triggers this lint: + +```rust +pub trait Trait1 { + type Output; +} + +pub trait Trait2 {} + +pub struct A; + +impl Trait1 for T where T: Trait2 { + type Output = (); +} + +impl Trait1> for A { + type Output = i32; +} +``` + +This will produce: + +```text +warning: conflicting implementations of trait `Trait1>` for type `A`: (E0119) + --> src/main.rs:13:1 + | +9 | impl Trait1 for T where T: Trait2 { + | --------------------------------------------- first implementation here +... +13 | impl Trait1> for A { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A` + | + = note: #[deny(incoherent_fundamental_impls)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #46205 + = note: downstream crates may implement trait `Trait2>` for type `A` +``` diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md index 1171f75caa1fd..b49708ff6adcd 100644 --- a/src/doc/rustc/src/lints/listing/warn-by-default.md +++ b/src/doc/rustc/src/lints/listing/warn-by-default.md @@ -117,47 +117,6 @@ warning: found struct without foreign-function-safe representation annotation in | ``` -## incoherent-fundamental-impls - -This lint detects potentially-conflicting impls that were erroneously allowed. Some -example code that triggers this lint: - -```rust -pub trait Trait1 { - type Output; -} - -pub trait Trait2 {} - -pub struct A; - -impl Trait1 for T where T: Trait2 { - type Output = (); -} - -impl Trait1> for A { - type Output = i32; -} -``` - -This will produce: - -```text -warning: conflicting implementations of trait `Trait1>` for type `A`: (E0119) - --> src/main.rs:13:1 - | -9 | impl Trait1 for T where T: Trait2 { - | --------------------------------------------- first implementation here -... -13 | impl Trait1> for A { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A` - | - = note: #[warn(incoherent_fundamental_impls)] on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #46205 - = note: downstream crates may implement trait `Trait2>` for type `A` -``` - ## late-bound-lifetime-arguments This lint detects detects generic lifetime arguments in path segments with From 8e4072cb4b38fe99455b2e799e440cf4f0a3fabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Thu, 3 May 2018 08:16:34 +0700 Subject: [PATCH 3/4] fix error text --- src/doc/rustc/src/lints/listing/deny-by-default.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index eea1edb91acea..4844141d47456 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -266,7 +266,7 @@ impl Trait1> for A { This will produce: ```text -warning: conflicting implementations of trait `Trait1>` for type `A`: (E0119) +error: conflicting implementations of trait `Trait1>` for type `A`: (E0119) --> src/main.rs:13:1 | 9 | impl Trait1 for T where T: Trait2 { From cabbe50c550a7eaba9a6877458f4598d2e63a3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Thu, 3 May 2018 08:17:21 +0700 Subject: [PATCH 4/4] ignore erroneous example --- src/doc/rustc/src/lints/listing/deny-by-default.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/lints/listing/deny-by-default.md b/src/doc/rustc/src/lints/listing/deny-by-default.md index 4844141d47456..ef76295f04d58 100644 --- a/src/doc/rustc/src/lints/listing/deny-by-default.md +++ b/src/doc/rustc/src/lints/listing/deny-by-default.md @@ -245,7 +245,7 @@ error: invalid `crate_type` value This lint detects potentially-conflicting impls that were erroneously allowed. Some example code that triggers this lint: -```rust +```rust,ignore pub trait Trait1 { type Output; }