Skip to content

Commit

Permalink
Auto merge of #50390 - hdhoang:46205_deny_by_default, r=nikomatsakis
Browse files Browse the repository at this point in the history
lint: deny incoherent_fundamental_impls by default

Warn the ecosystem of the pending intent-to-disallow in #49799.

There are 4 ICEs on my machine, look unrelated (having happened before in #49146 (comment))

```rust
thread 'main' panicked at 'assertion failed: position <= slice.len()', libserialize/leb128.rs:97:1
```

```
    [run-pass] run-pass/allocator/xcrate-use2.rs
    [run-pass] run-pass/issue-12133-3.rs
    [run-pass] run-pass/issue-32518.rs
    [run-pass] run-pass/trait-default-method-xc-2.rs
```

r? @nikomatsakis
  • Loading branch information
bors committed May 8, 2018
2 parents 0da1a69 + cabbe50 commit 295d980
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 80 deletions.
41 changes: 41 additions & 0 deletions src/doc/rustc/src/lints/listing/deny-by-default.md
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
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
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
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.

0 comments on commit 295d980

Please sign in to comment.