File: dyn-2021-edition-error.stderr

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 934,168 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (56 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
error[E0782]: expected a type, found a trait
  --> $DIR/dyn-2021-edition-error.rs:3:17
   |
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
   |                 ^^^^^^^^^
   |
help: use a new generic type parameter, constrained by `SomeTrait`
   |
LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) {
LL + fn function<T: SomeTrait>(x: &T, y: Box<SomeTrait>) {
   |
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
   |
LL | fn function(x: &impl SomeTrait, y: Box<SomeTrait>) {
   |                 ++++
help: alternatively, use a trait object to accept any type that implements `SomeTrait`, accessing its methods at runtime using dynamic dispatch
   |
LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) {
   |                 +++

error[E0782]: expected a type, found a trait
  --> $DIR/dyn-2021-edition-error.rs:3:35
   |
LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) {
   |                                   ^^^^^^^^^
   |
help: you can add the `dyn` keyword if you want a trait object
   |
LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) {
   |                                   +++

error[E0782]: expected a type, found a trait
  --> $DIR/dyn-2021-edition-error.rs:12:24
   |
LL |     fn foo() -> *const SomeTrait;
   |                        ^^^^^^^^^
   |
help: you can add the `dyn` keyword if you want a trait object
   |
LL |     fn foo() -> *const dyn SomeTrait;
   |                        +++

error[E0782]: expected a type, found a trait
  --> $DIR/dyn-2021-edition-error.rs:6:14
   |
LL |     let _x: &SomeTrait = todo!();
   |              ^^^^^^^^^
   |
help: you can add the `dyn` keyword if you want a trait object
   |
LL |     let _x: &dyn SomeTrait = todo!();
   |              +++

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0782`.