Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: deny incoherent_fundamental_impls by default #50390

Merged
merged 4 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/doc/rustc/src/lints/listing/deny-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,ignore
pub trait Trait1<X> {
type Output;
}

pub trait Trait2<X> {}

pub struct A;

impl<X, T> Trait1<X> for T where T: Trait2<X> {
type Output = ();
}

impl<X> Trait1<Box<X>> for A {
type Output = i32;
}
```

This will produce:

```text
error: conflicting implementations of trait `Trait1<std::boxed::Box<_>>` for type `A`: (E0119)
--> src/main.rs:13:1
|
9 | impl<X, T> Trait1<X> for T where T: Trait2<X> {
| --------------------------------------------- first implementation here
...
13 | impl<X> Trait1<Box<X>> 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 <https://github.com/rust-lang/rust/issues/46205>
= note: downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A`
```
41 changes: 0 additions & 41 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<X> {
type Output;
}

pub trait Trait2<X> {}

pub struct A;

impl<X, T> Trait1<X> for T where T: Trait2<X> {
type Output = ();
}

impl<X> Trait1<Box<X>> for A {
type Output = i32;
}
```

This will produce:

```text
warning: conflicting implementations of trait `Trait1<std::boxed::Box<_>>` for type `A`: (E0119)
--> src/main.rs:13:1
|
9 | impl<X, T> Trait1<X> for T where T: Trait2<X> {
| --------------------------------------------- first implementation here
...
13 | impl<X> Trait1<Box<X>> 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 <https://github.com/rust-lang/rust/issues/46205>
= note: downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A`
```

## late-bound-lifetime-arguments

This lint detects detects generic lifetime arguments in path segments with
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ declare_lint! {

declare_lint! {
pub INCOHERENT_FUNDAMENTAL_IMPLS,
Warn,
Deny,
"potentially-conflicting impls were erroneously allowed"
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/issue-43355.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<X> {
type Output;
}
Expand Down
36 changes: 0 additions & 36 deletions src/test/run-pass/issue-43355.rs

This file was deleted.