fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
4.4 KiB83 linesraw
1error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
2  --> $DIR/feature-gate-object_safe_for_dispatch.rs:18:39
3   |
4LL | fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) {
5   |                                       ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
6   |
7note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8  --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
9   |
10LL | trait NonObjectSafe1: Sized {}
11   |       --------------  ^^^^^ ...because it requires `Self: Sized`
12   |       |
13   |       this trait cannot be made into an object...
14
15error[E0038]: the trait `NonObjectSafe2` cannot be made into an object
16  --> $DIR/feature-gate-object_safe_for_dispatch.rs:22:45
17   |
18LL | fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 {
19   |                                             ^^^^^^^^^^^^^^^^^^ `NonObjectSafe2` cannot be made into an object
20   |
21note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
22  --> $DIR/feature-gate-object_safe_for_dispatch.rs:7:8
23   |
24LL | trait NonObjectSafe2 {
25   |       -------------- this trait cannot be made into an object...
26LL |     fn static_fn() {}
27   |        ^^^^^^^^^ ...because associated function `static_fn` has no `self` parameter
28help: consider turning `static_fn` into a method by giving it a `&self` argument
29   |
30LL |     fn static_fn(&self) {}
31   |                  +++++
32help: alternatively, consider constraining `static_fn` so it does not apply to trait objects
33   |
34LL |     fn static_fn() where Self: Sized {}
35   |                    +++++++++++++++++
36
37error[E0038]: the trait `NonObjectSafe3` cannot be made into an object
38  --> $DIR/feature-gate-object_safe_for_dispatch.rs:27:39
39   |
40LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
41   |                                       ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object
42   |
43note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
44  --> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8
45   |
46LL | trait NonObjectSafe3 {
47   |       -------------- this trait cannot be made into an object...
48LL |     fn foo<T>(&self);
49   |        ^^^ ...because method `foo` has generic type parameters
50   = help: consider moving `foo` to another trait
51
52error[E0038]: the trait `NonObjectSafe4` cannot be made into an object
53  --> $DIR/feature-gate-object_safe_for_dispatch.rs:31:47
54   |
55LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
56   |                                               ^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object
57   |
58note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
59  --> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22
60   |
61LL | trait NonObjectSafe4 {
62   |       -------------- this trait cannot be made into an object...
63LL |     fn foo(&self, s: &Self);
64   |                      ^^^^^ ...because method `foo` references the `Self` type in this parameter
65   = help: consider moving `foo` to another trait
66
67error[E0038]: the trait `NonObjectSafe1` cannot be made into an object
68  --> $DIR/feature-gate-object_safe_for_dispatch.rs:38:16
69   |
70LL | impl Trait for dyn NonObjectSafe1 {}
71   |                ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object
72   |
73note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
74  --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23
75   |
76LL | trait NonObjectSafe1: Sized {}
77   |       --------------  ^^^^^ ...because it requires `Self: Sized`
78   |       |
79   |       this trait cannot be made into an object...
80
81error: aborting due to 5 previous errors
82
83For more information about this error, try `rustc --explain E0038`.