Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
351d532
interpret: call caller_location logic the same way codegen does, and …
RalfJung Oct 28, 2023
04fa124
share the track_caller handling within a mir::Body
RalfJung Oct 28, 2023
552abdc
Rename a few remaining references to abort terminator
tmiasko Oct 29, 2023
82b447a
Add support for mipsel-unknown-netbsd, 32-bit LE mips.
he32 Oct 29, 2023
5e6c313
mipsel_unknown_netbsd.rs: fix indentation.
he32 Oct 29, 2023
28e60de
Remove `memoffset` dependency from `rustc_query_impl`.
nnethercote Oct 23, 2023
8ff624a
Clean up `rustc_*/Cargo.toml`.
nnethercote Oct 20, 2023
8c04999
On object safety error, mention new enum as alternative
estebank Oct 24, 2023
678e01a
Delay parsing of `--cfg` and `--check-cfg` options.
nnethercote Oct 30, 2023
bfcff79
Reduce exposure of cfg parsers.
nnethercote Oct 30, 2023
8e4ac98
Change cfg parsers to produce symbols instead of strings.
nnethercote Oct 30, 2023
5c6a12c
Make `Cfg` and `CheckCfg` non-generic.
nnethercote Oct 30, 2023
371f972
Improve readability of `parse_check_cfg`.
nnethercote Oct 30, 2023
85e56e8
Remove out-of-date comment.
nnethercote Oct 30, 2023
a60d643
Wrap some overlong comments.
nnethercote Oct 30, 2023
95b0088
Remove `check_output`.
nnethercote Oct 30, 2023
4b14048
improve and fix x install
onur-ozkan Oct 30, 2023
be8fd8b
Streamline `collect_crate_types`.
nnethercote Oct 30, 2023
90862f6
Remove an unnecessary `drop`.
nnethercote Oct 30, 2023
0c381ec
Streamline some `use` items.
nnethercote Oct 30, 2023
745c600
Talk about `gen fn` in diagnostics about `gen fn`
oli-obk Oct 30, 2023
bc926f7
Add a custom panic message for resuming `gen` blocks after they panicked
oli-obk Oct 30, 2023
a2486db
Fix missing leading space in suggestion
gurry Oct 30, 2023
82f34fd
Fix #117284, Fix unused variables lint issue for args in macro
chenyukang Oct 30, 2023
8508e65
Fix bad-c-variadic error being emitted multiple times
nicholasbishop Oct 29, 2023
f91b5ce
Explicitly reject const C-variadic functions
nicholasbishop Oct 29, 2023
58a80c8
rustdoc: elide cross-crate default generic arguments
fmease Jun 9, 2023
ac9c5bd
Only run panic tests on targets that can unwind
oli-obk Oct 30, 2023
adce189
Rollup merge of #112463 - fmease:rustdoc-elide-x-crate-def-gen-args, …
GuillaumeGomez Oct 30, 2023
e37cabe
Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiser
GuillaumeGomez Oct 30, 2023
c7e6301
Rollup merge of #117132 - estebank:issue-80194, r=petrochenkov
GuillaumeGomez Oct 30, 2023
ead3561
Rollup merge of #117317 - RalfJung:track-caller, r=oli-obk
GuillaumeGomez Oct 30, 2023
7d129fd
Rollup merge of #117356 - he32:netbsd-mipsel, r=oli-obk
GuillaumeGomez Oct 30, 2023
adc6f2e
Rollup merge of #117357 - tmiasko:terminate, r=wesleywiser
GuillaumeGomez Oct 30, 2023
52a5271
Rollup merge of #117370 - nicholasbishop:bishop-better-c-variadic-err…
GuillaumeGomez Oct 30, 2023
4c84a8a
Rollup merge of #117376 - nnethercote:rustc_interface-more, r=oli-obk
GuillaumeGomez Oct 30, 2023
5d6645d
Rollup merge of #117383 - onur-ozkan:fix-x-install, r=albertlarsan68
GuillaumeGomez Oct 30, 2023
284e95f
Rollup merge of #117389 - oli-obk:gen_fn, r=compiler-errors
GuillaumeGomez Oct 30, 2023
a4df941
Rollup merge of #117390 - chenyukang:yukang-fix-117284-unused-macro, …
GuillaumeGomez Oct 30, 2023
bf6f582
Rollup merge of #117395 - gurry:117380-wrong-parent-sugg, r=Nilstrieb
GuillaumeGomez Oct 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
On object safety error, mention new enum as alternative
When we encounter a `dyn Trait` that isn't object safe, look for its
implementors. If there's one, mention using it directly If there are
less than 9, mention the possibility of creating a new enum and using
that instead.

Account for object unsafe `impl Trait on dyn Trait {}`.  Make a
distinction between public and sealed traits.

Fix #80194.
  • Loading branch information
estebank committed Oct 29, 2023
commit 8c04999226e4be90c46c370580c9e8cd7f0ccb05
64 changes: 63 additions & 1 deletion compiler/rustc_infer/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::ty::TyCtxt;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::Span;
use std::fmt;
use std::iter;
Expand Down Expand Up @@ -108,5 +109,66 @@ pub fn report_object_safety_error<'tcx>(
violation.solution(&mut err);
}
}

let impls_of = tcx.trait_impls_of(trait_def_id);
let impls = if impls_of.blanket_impls().is_empty() {
impls_of
.non_blanket_impls()
.values()
.flatten()
.filter(|def_id| {
!matches!(tcx.type_of(*def_id).instantiate_identity().kind(), ty::Dynamic(..))
})
.collect::<Vec<_>>()
} else {
vec![]
};
let externally_visible = if !impls.is_empty()
&& let Some(def_id) = trait_def_id.as_local()
&& tcx.effective_visibilities(()).is_exported(def_id)
{
true
} else {
false
};
match &impls[..] {
[] => {}
_ if impls.len() > 9 => {}
[only] if externally_visible => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` is seen to implement the trait in this crate, consider using it \
directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
[only] => {
err.help(with_no_trimmed_paths!(format!(
"only type `{}` implements the trait, consider using it directly instead",
tcx.type_of(*only).instantiate_identity(),
)));
}
impls => {
let types = impls
.iter()
.map(|t| {
with_no_trimmed_paths!(format!(" {}", tcx.type_of(*t).instantiate_identity(),))
})
.collect::<Vec<_>>();
err.help(format!(
"the following types implement the trait, consider defining an enum where each \
variant holds one of these types, implementing `{}` for this new enum and using \
it instead:\n{}",
trait_str,
types.join("\n"),
));
}
}
if externally_visible {
err.note(format!(
"`{trait_str}` can be implemented in other crates; if you want to support your users \
passing their own types here, you can't refer to a specific type",
));
}

err
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LL | fn test(&self) -> [u8; bar::<Self>()];
| ...because method `test` references the `Self` type in its `where` clause
= help: consider moving `test` to another trait
= help: consider moving `test` to another trait
= help: only type `()` implements the trait, consider using it directly instead

error: aborting due to previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | fn ptr(self: Ptr<Self>);
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
= help: only type `i32` implements the trait, consider using it directly instead

error[E0038]: the trait `Trait` cannot be made into an object
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5
Expand All @@ -31,6 +32,7 @@ LL | trait Trait {
| ----- this trait cannot be made into an object...
LL | fn ptr(self: Ptr<Self>);
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
= help: only type `i32` implements the trait, consider using it directly instead
= note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>`

error: aborting due to 2 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ LL | trait Foo {
LL | type A<'a> where Self: 'a;
| ^ ...because it contains the generic associated type `A`
= help: consider moving `A` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead:
Fooy
Fooer<T>

error: aborting due to previous error

Expand Down
4 changes: 4 additions & 0 deletions tests/ui/generic-associated-types/issue-76535.base.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ LL | pub trait SuperTrait {
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type

error[E0038]: the trait `SuperTrait` cannot be made into an object
--> $DIR/issue-76535.rs:39:57
Expand All @@ -43,6 +45,8 @@ LL | pub trait SuperTrait {
LL | type SubType<'a>: SubTrait where Self: 'a;
| ^^^^^^^ ...because it contains the generic associated type `SubType`
= help: consider moving `SubType` to another trait
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
= note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
= note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`

error: aborting due to 3 previous errors
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/generic-associated-types/issue-79422.base.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ LL | trait MapLike<K, V> {
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source

error[E0038]: the trait `MapLike` cannot be made into an object
--> $DIR/issue-79422.rs:44:13
Expand All @@ -43,6 +46,9 @@ LL | trait MapLike<K, V> {
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
= help: consider moving `VRefCont` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead:
std::collections::BTreeMap<K, V>
Source
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`

error: aborting due to 3 previous errors
Expand Down
1 change: 1 addition & 0 deletions tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all
|
LL | fn bar(self) -> impl Deref<Target = impl Sized>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type
= help: only type `rpitit::Foreign` implements the trait, consider using it directly instead

error: aborting due to previous error

Expand Down
4 changes: 4 additions & 0 deletions tests/ui/impl-trait/in-trait/object-safety.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LL | trait Foo {
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety.rs:17:15
Expand All @@ -27,6 +28,7 @@ LL | trait Foo {
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety.rs:17:13
Expand All @@ -42,6 +44,7 @@ LL | trait Foo {
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/object-safety.rs:14:13
Expand All @@ -57,6 +60,7 @@ LL | trait Foo {
LL | fn baz(&self) -> impl Debug;
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
= help: consider moving `baz` to another trait
= help: only type `u32` implements the trait, consider using it directly instead
= note: required for the cast from `Box<u32>` to `Box<dyn Foo>`

error: aborting due to 4 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ LL | trait NotObjectSafe {
| ------------- this trait cannot be made into an object...
LL | fn foo() -> Self;
| ^^^ ...because associated function `foo` has no `self` parameter
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead:
A
B
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) -> Self;
Expand All @@ -33,6 +36,9 @@ LL | trait NotObjectSafe {
| ------------- this trait cannot be made into an object...
LL | fn foo() -> Self;
| ^^^ ...because associated function `foo` has no `self` parameter
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead:
A
B
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) -> Self;
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/issues/issue-19380.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Qiz {
| --- this trait cannot be made into an object...
LL | fn qiz();
| ^^^ ...because associated function `qiz` has no `self` parameter
= help: only type `Foo` implements the trait, consider using it directly instead
help: consider turning `qiz` into a method by giving it a `&self` argument
|
LL | fn qiz(&self);
Expand All @@ -33,6 +34,7 @@ LL | trait Qiz {
| --- this trait cannot be made into an object...
LL | fn qiz();
| ^^^ ...because associated function `qiz` has no `self` parameter
= help: only type `Foo` implements the trait, consider using it directly instead
= note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)`
help: consider turning `qiz` into a method by giving it a `&self` argument
|
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/object-safety/issue-19538.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ LL | fn foo<T>(&self, val: T);
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead

error[E0038]: the trait `Bar` cannot be made into an object
--> $DIR/issue-19538.rs:17:30
Expand All @@ -29,6 +30,7 @@ LL | fn foo<T>(&self, val: T);
LL | trait Bar: Foo { }
| --- this trait cannot be made into an object...
= help: consider moving `foo` to another trait
= help: only type `Thing` implements the trait, consider using it directly instead
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`

error: aborting due to 2 previous errors
Expand Down
1 change: 1 addition & 0 deletions tests/ui/object-safety/object-safety-issue-22040.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Expr: Debug + PartialEq {
| ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `SExpr<'x>` implements the trait, consider using it directly instead

error: aborting due to previous error

Expand Down
1 change: 1 addition & 0 deletions tests/ui/object-safety/object-safety-no-static.curr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo() {}
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `Bar` implements the trait, consider using it directly instead
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
help: consider turning `foo` into a method by giving it a `&self` argument
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
= help: only type `usize` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/arbitrary-self-types-not-object-safe.rs:33:13
Expand All @@ -31,6 +32,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
= help: only type `usize` implements the trait, consider using it directly instead
= note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>`

error: aborting due to 2 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LL | trait Foo {
| --- this trait cannot be made into an object...
LL | fn foo(self: &Rc<Self>) -> usize;
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
= help: only type `usize` implements the trait, consider using it directly instead
= note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>`

error: aborting due to previous error
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/traits/issue-38604.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Foo where u32: Q<Self> {
| --- ^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `()` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/issue-38604.rs:15:9
Expand All @@ -25,6 +26,7 @@ LL | trait Foo where u32: Q<Self> {
| --- ^^^^^^^ ...because it uses `Self` as a type parameter
| |
| this trait cannot be made into an object...
= help: only type `()` implements the trait, consider using it directly instead
= note: required for the cast from `Box<()>` to `Box<dyn Foo>`

error: aborting due to 2 previous errors
Expand Down
1 change: 1 addition & 0 deletions tests/ui/traits/item-privacy.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ LL | const C: u8 = 0;
= help: consider moving `C` to another trait
= help: consider moving `A` to another trait
= help: consider moving `B` to another trait
= help: only type `S` implements the trait, consider using it directly instead

error[E0223]: ambiguous associated type
--> $DIR/item-privacy.rs:115:12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LL | trait Foo: for<T> Bar<T> {}
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
| |
| this trait cannot be made into an object...
= help: only type `()` implements the trait, consider using it directly instead
= note: required for the cast from `&()` to `&dyn Foo`

error[E0038]: the trait `Foo` cannot be made into an object
Expand All @@ -35,6 +36,7 @@ LL | trait Foo: for<T> Bar<T> {}
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
| |
| this trait cannot be made into an object...
= help: only type `()` implements the trait, consider using it directly instead

error[E0038]: the trait `Foo` cannot be made into an object
--> $DIR/supertrait-object-safety.rs:22:5
Expand All @@ -49,6 +51,7 @@ LL | trait Foo: for<T> Bar<T> {}
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
| |
| this trait cannot be made into an object...
= help: only type `()` implements the trait, consider using it directly instead

error: aborting due to 3 previous errors; 1 warning emitted

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/traits/object/safety.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LL | trait Tr {
| -- this trait cannot be made into an object...
LL | fn foo();
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `St` implements the trait, consider using it directly instead
= note: required for the cast from `&St` to `&dyn Tr`
help: consider turning `foo` into a method by giving it a `&self` argument
|
Expand All @@ -34,6 +35,7 @@ LL | trait Tr {
| -- this trait cannot be made into an object...
LL | fn foo();
| ^^^ ...because associated function `foo` has no `self` parameter
= help: only type `St` implements the trait, consider using it directly instead
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self);
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/traits/test-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| this trait cannot be made into an object...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead:
i32
u32

error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/test-2.rs:13:5
Expand All @@ -59,6 +62,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| this trait cannot be made into an object...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead:
i32
u32

error[E0038]: the trait `bar` cannot be made into an object
--> $DIR/test-2.rs:13:6
Expand All @@ -76,6 +82,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
| this trait cannot be made into an object...
= help: consider moving `dup` to another trait
= help: consider moving `blah` to another trait
= help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead:
i32
u32
= note: required for the cast from `Box<{integer}>` to `Box<dyn bar>`

error: aborting due to 5 previous errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; }
| |
| this trait cannot be made into an object...
= help: consider moving `add` to another trait
= help: only type `i32` implements the trait, consider using it directly instead

error: aborting due to 2 previous errors

Expand Down
Loading