Skip to content

Commit c411f13

Browse files
committed
Auto merge of #26431 - GuillaumeGomez:patch-2, r=Manishearth
Part of #24407. cc @michaelsproul
2 parents d5fdb55 + 3c98781 commit c411f13

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,22 @@ fn main() {
380380
```
381381
"##,
382382

383+
E0044: r##"
384+
You can't use type parameters on foreign items. Example of erroneous code:
385+
386+
```
387+
extern { fn some_func<T>(x: T); }
388+
```
389+
390+
To fix this, replace the type parameter with the specializations that you
391+
need:
392+
393+
```
394+
extern { fn some_func_i32(x: i32); }
395+
extern { fn some_func_i64(x: i64); }
396+
```
397+
"##,
398+
383399
E0045: r##"
384400
Rust only supports variadic parameters for interoperability with C code in its
385401
FFI. As such, variadic parameters can only be used with functions which are
@@ -733,6 +749,44 @@ fn some_func(x: &mut i32) {
733749
```
734750
"##,
735751

752+
E0071: r##"
753+
You tried to use a structure initialization with a non-structure type.
754+
Example of erroneous code:
755+
756+
```
757+
enum Foo { FirstValue };
758+
759+
let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
760+
// isn't a structure!
761+
// or even simpler, if the structure wasn't defined at all:
762+
let u = RandomName { random_field: 0i32 }; // error: RandomName
763+
// isn't a structure!
764+
```
765+
766+
To fix this, please check:
767+
* Did you spell it right?
768+
* Did you accidentaly used an enum as a struct?
769+
* Did you accidentaly make an enum when you intended to use a struct?
770+
771+
Here is the previous code with all missing information:
772+
773+
```
774+
struct Inner {
775+
value: i32
776+
}
777+
778+
enum Foo {
779+
FirstValue(Inner)
780+
}
781+
782+
fn main() {
783+
let u = Foo::FirstValue(Inner { value: 0i32 });
784+
785+
let t = Inner { value: 0i32 };
786+
}
787+
```
788+
"##,
789+
736790
E0072: r##"
737791
When defining a recursive struct or enum, any use of the type being defined
738792
from inside the definition must occur behind a pointer (like `Box` or `&`).
@@ -1488,9 +1542,7 @@ For more information see the [opt-in builtin traits RFC](https://github.com/rust
14881542
}
14891543

14901544
register_diagnostics! {
1491-
E0044, // foreign items may not have type parameters
14921545
E0068,
1493-
E0071,
14941546
E0074,
14951547
E0075,
14961548
E0076,

0 commit comments

Comments
 (0)