Skip to content

Commit 295d980

Browse files
committed
Auto merge of #50390 - hdhoang:46205_deny_by_default, r=nikomatsakis
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
2 parents 0da1a69 + cabbe50 commit 295d980

File tree

5 files changed

+42
-80
lines changed

5 files changed

+42
-80
lines changed

src/doc/rustc/src/lints/listing/deny-by-default.md

+41
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,44 @@ error: invalid `crate_type` value
239239
| ^^^^^^^^^^^^^^^^^^^^
240240
|
241241
```
242+
243+
## incoherent-fundamental-impls
244+
245+
This lint detects potentially-conflicting impls that were erroneously allowed. Some
246+
example code that triggers this lint:
247+
248+
```rust,ignore
249+
pub trait Trait1<X> {
250+
type Output;
251+
}
252+
253+
pub trait Trait2<X> {}
254+
255+
pub struct A;
256+
257+
impl<X, T> Trait1<X> for T where T: Trait2<X> {
258+
type Output = ();
259+
}
260+
261+
impl<X> Trait1<Box<X>> for A {
262+
type Output = i32;
263+
}
264+
```
265+
266+
This will produce:
267+
268+
```text
269+
error: conflicting implementations of trait `Trait1<std::boxed::Box<_>>` for type `A`: (E0119)
270+
--> src/main.rs:13:1
271+
|
272+
9 | impl<X, T> Trait1<X> for T where T: Trait2<X> {
273+
| --------------------------------------------- first implementation here
274+
...
275+
13 | impl<X> Trait1<Box<X>> for A {
276+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A`
277+
|
278+
= note: #[deny(incoherent_fundamental_impls)] on by default
279+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
280+
= note: for more information, see issue #46205 <https://github.com/rust-lang/rust/issues/46205>
281+
= note: downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A`
282+
```

src/doc/rustc/src/lints/listing/warn-by-default.md

-41
Original file line numberDiff line numberDiff line change
@@ -117,47 +117,6 @@ warning: found struct without foreign-function-safe representation annotation in
117117
|
118118
```
119119

120-
## incoherent-fundamental-impls
121-
122-
This lint detects potentially-conflicting impls that were erroneously allowed. Some
123-
example code that triggers this lint:
124-
125-
```rust
126-
pub trait Trait1<X> {
127-
type Output;
128-
}
129-
130-
pub trait Trait2<X> {}
131-
132-
pub struct A;
133-
134-
impl<X, T> Trait1<X> for T where T: Trait2<X> {
135-
type Output = ();
136-
}
137-
138-
impl<X> Trait1<Box<X>> for A {
139-
type Output = i32;
140-
}
141-
```
142-
143-
This will produce:
144-
145-
```text
146-
warning: conflicting implementations of trait `Trait1<std::boxed::Box<_>>` for type `A`: (E0119)
147-
--> src/main.rs:13:1
148-
|
149-
9 | impl<X, T> Trait1<X> for T where T: Trait2<X> {
150-
| --------------------------------------------- first implementation here
151-
...
152-
13 | impl<X> Trait1<Box<X>> for A {
153-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `A`
154-
|
155-
= note: #[warn(incoherent_fundamental_impls)] on by default
156-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
157-
= note: for more information, see issue #46205 <https://github.com/rust-lang/rust/issues/46205>
158-
= note: downstream crates may implement trait `Trait2<std::boxed::Box<_>>` for type `A`
159-
```
160-
161120
## late-bound-lifetime-arguments
162121

163122
This lint detects detects generic lifetime arguments in path segments with

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ declare_lint! {
208208

209209
declare_lint! {
210210
pub INCOHERENT_FUNDAMENTAL_IMPLS,
211-
Warn,
211+
Deny,
212212
"potentially-conflicting impls were erroneously allowed"
213213
}
214214

src/test/compile-fail/issue-43355.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(incoherent_fundamental_impls)]
12-
1311
pub trait Trait1<X> {
1412
type Output;
1513
}

src/test/run-pass/issue-43355.rs

-36
This file was deleted.

0 commit comments

Comments
 (0)