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