Skip to content

Commit f3f23bf

Browse files
committed
Auto merge of #28086 - AlisdairO:diagnostics281, r=arielb1
As title :-) Part of #24407. r? @Manishearth
2 parents 9982314 + 9ed30c6 commit f3f23bf

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/librustc/diagnostics.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,26 @@ fn main() {
14871487
```
14881488
"##,
14891489

1490+
E0281: r##"
1491+
You tried to supply a type which doesn't implement some trait in a location
1492+
which expected that trait. This error typically occurs when working with
1493+
`Fn`-based types. Erroneous code example:
1494+
1495+
```
1496+
fn foo<F: Fn()>(x: F) { }
1497+
1498+
fn main() {
1499+
// type mismatch: the type ... implements the trait `core::ops::Fn<(_,)>`,
1500+
// but the trait `core::ops::Fn<()>` is required (expected (), found tuple
1501+
// [E0281]
1502+
foo(|y| { });
1503+
}
1504+
```
1505+
1506+
The issue in this case is that `foo` is defined as accepting a `Fn` with no
1507+
arguments, but the closure we attempted to pass to it requires one argument.
1508+
"##,
1509+
14901510
E0282: r##"
14911511
This error indicates that type inference did not result in one unique possible
14921512
type, and extra information is required. In most cases this can be provided
@@ -1867,7 +1887,6 @@ register_diagnostics! {
18671887
E0278, // requirement is not satisfied
18681888
E0279, // requirement is not satisfied
18691889
E0280, // requirement is not satisfied
1870-
E0281, // type implements trait but other trait is required
18711890
E0283, // cannot resolve type
18721891
E0284, // cannot resolve type
18731892
E0285, // overflow evaluation builtin bounds

0 commit comments

Comments
 (0)