Skip to content

Commit b700e49

Browse files
committed
Deduplicate more E0038 object safety errors by pointing at type more often
On casts to `dyn Trait` caused by explicit `as` or return type, we point at the type instead of the expression. Silence note with context about the cast when we'd point at the type, which allows automatic deduplication to happen.
1 parent f5175fd commit b700e49

File tree

44 files changed

+184
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+184
-160
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,46 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
986986

987987
TraitNotObjectSafe(did) => {
988988
let violations = self.tcx.object_safety_violations(did);
989-
report_object_safety_error(self.tcx, span, None, did, violations)
989+
let (hir_id, early) = match root_obligation.cause.code() {
990+
ObligationCauseCode::Coercion { parent_code, .. } => {
991+
match &**parent_code {
992+
ObligationCauseCode::ExprAssignable(hir_id) => (*hir_id, true),
993+
ObligationCauseCode::ReturnValue(_) => {
994+
let node = self.tcx.hir_node(self.tcx.local_def_id_to_hir_id(root_obligation.cause.body_id));
995+
if let Some(decl) = node.fn_decl()
996+
&& let hir::FnRetTy::Return(ty) = decl.output
997+
{
998+
// We'll point at the return type on type safety errors.
999+
(Some(ty.hir_id), true)
1000+
} else {
1001+
(None, false)
1002+
}
1003+
}
1004+
ObligationCauseCode::BlockTailExpression(hir_id, _) => {
1005+
if let Some((_, decl, _)) = self.tcx.get_fn_decl(*hir_id)
1006+
&& let hir::FnRetTy::Return(ty) = decl.output
1007+
{
1008+
// We'll point at the return type on type safety errors.
1009+
(Some(ty.hir_id), true)
1010+
} else {
1011+
(None, false)
1012+
}
1013+
}
1014+
_ => (None, false),
1015+
}
1016+
}
1017+
_ => (None, false),
1018+
};
1019+
let mut err = report_object_safety_error(self.tcx, span, hir_id, did, violations);
1020+
if early {
1021+
// We want to skip `note_obligation_cause` because we don't want to note that
1022+
// the requirement came from a cast, because that note causes the error
1023+
// deduplication to not trigger and we'll have two errors instead of one.
1024+
self.point_at_returns_when_relevant(&mut err, &obligation);
1025+
return err.emit();
1026+
} else {
1027+
err
1028+
}
9901029
}
9911030

9921031
SelectionError::NotConstEvaluatable(NotConstEvaluatable::MentionsInfer) => {

tests/ui/dyn-keyword/trait-dyn-in-qualified-path-for-object-unsafe-trait.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ LL | trait Trait: Sized {}
4242
| |
4343
| this trait cannot be made into an object...
4444
= help: only type `()` implements the trait, consider using it directly instead
45-
= note: required for the cast from `&()` to `&(dyn Trait + 'static)`
4645

4746
error[E0038]: the trait `Trait` cannot be made into an object
4847
--> $DIR/trait-dyn-in-qualified-path-for-object-unsafe-trait.rs:10:6

tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ LL | fn ptr(self: Ptr<Self>);
1717
= help: only type `i32` implements the trait, consider using it directly instead
1818

1919
error[E0038]: the trait `Trait` cannot be made into an object
20-
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5
20+
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:29
2121
|
2222
LL | fn ptr(self: Ptr<Self>);
2323
| --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self`
2424
...
2525
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
26-
| ^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object
26+
| ^^^^^^^^^ `Trait` cannot be made into an object
2727
|
2828
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>
2929
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
@@ -33,7 +33,7 @@ LL | trait Trait {
3333
LL | fn ptr(self: Ptr<Self>);
3434
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
3535
= help: only type `i32` implements the trait, consider using it directly instead
36-
= note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>`
36+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3737

3838
error: aborting due to 2 previous errors
3939

tests/ui/generic-associated-types/gat-in-trait-path.base.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ LL | type A<'a> where Self: 'a;
5151
= 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:
5252
Fooer<T>
5353
Fooy
54-
= note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A = &'a ()> + 'static)>`
54+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5555

5656
error: aborting due to 3 previous errors
5757

tests/ui/generic-associated-types/issue-76535.base.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
3232
= 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
3333

3434
error[E0038]: the trait `SuperTrait` cannot be made into an object
35-
--> $DIR/issue-76535.rs:39:57
35+
--> $DIR/issue-76535.rs:39:18
3636
|
3737
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
38-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
3939
|
4040
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>
4141
--> $DIR/issue-76535.rs:9:10
@@ -47,7 +47,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
4747
= help: consider moving `SubType` to another trait
4848
= help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead
4949
= 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
50-
= note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`
50+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5151

5252
error: aborting due to 3 previous errors
5353

tests/ui/generic-associated-types/issue-79422.base.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0107]: missing generics for associated type `MapLike::VRefCont`
2-
--> $DIR/issue-79422.rs:47:36
2+
--> $DIR/issue-79422.rs:45:36
33
|
44
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
55
| ^^^^^^^^ expected 1 lifetime argument
@@ -15,7 +15,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
1515
| ++++
1616

1717
error[E0038]: the trait `MapLike` cannot be made into an object
18-
--> $DIR/issue-79422.rs:47:16
18+
--> $DIR/issue-79422.rs:45:16
1919
|
2020
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
2121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
@@ -33,10 +33,10 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
3333
std::collections::BTreeMap<K, V>
3434

3535
error[E0038]: the trait `MapLike` cannot be made into an object
36-
--> $DIR/issue-79422.rs:44:13
36+
--> $DIR/issue-79422.rs:45:16
3737
|
38-
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
39-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
38+
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
4040
|
4141
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>
4242
--> $DIR/issue-79422.rs:23:10
@@ -49,7 +49,7 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
4949
= 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:
5050
Source
5151
std::collections::BTreeMap<K, V>
52-
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>`
52+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5353

5454
error: aborting due to 3 previous errors
5555

tests/ui/generic-associated-types/issue-79422.extended.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0107]: missing generics for associated type `MapLike::VRefCont`
2-
--> $DIR/issue-79422.rs:47:36
2+
--> $DIR/issue-79422.rs:45:36
33
|
44
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
55
| ^^^^^^^^ expected 1 lifetime argument

tests/ui/generic-associated-types/issue-79422.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ impl<K, V: Default> MapLike<K, V> for Source {
4141
}
4242

4343
fn main() {
44-
let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
45-
//[base]~^ ERROR the trait
46-
//[extended]~^^ type mismatch
44+
let m = Box::new(std::collections::BTreeMap::<u8, u8>::new()) //[extended]~ type mismatch
4745
as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
4846
//~^ ERROR missing generics for associated type
4947
//[base]~^^ ERROR the trait
48+
//[base]~| ERROR the trait
5049
}

tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/span-bug-issue-121597.rs:14:23
2+
--> $DIR/span-bug-issue-121597.rs:14:13
33
|
44
LL | let x: &dyn Foo = &();
5-
| ^^^ `Foo` cannot be made into an object
5+
| ^^^^^^^ `Foo` cannot be made into an object
66
|
77
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>
88
--> $DIR/span-bug-issue-121597.rs:4:12
@@ -11,7 +11,6 @@ LL | trait Foo: for<T> Bar<T> {}
1111
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
1212
| |
1313
| this trait cannot be made into an object...
14-
= note: required for the cast from `&()` to `&dyn Foo`
1514

1615
error[E0038]: the trait `Foo` cannot be made into an object
1716
--> $DIR/span-bug-issue-121597.rs:14:13
@@ -26,6 +25,7 @@ LL | trait Foo: for<T> Bar<T> {}
2625
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
2726
| |
2827
| this trait cannot be made into an object...
28+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2929

3030
error[E0308]: mismatched types
3131
--> $DIR/span-bug-issue-121597.rs:18:15

tests/ui/impl-trait/in-trait/object-safety.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ LL | fn baz(&self) -> impl Debug;
4747
= help: only type `u32` implements the trait, consider using it directly instead
4848

4949
error[E0038]: the trait `Foo` cannot be made into an object
50-
--> $DIR/object-safety.rs:14:13
50+
--> $DIR/object-safety.rs:14:37
5151
|
5252
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
53-
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
53+
| ^^^^^^^ `Foo` cannot be made into an object
5454
|
5555
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>
5656
--> $DIR/object-safety.rs:4:22
@@ -61,7 +61,7 @@ LL | fn baz(&self) -> impl Debug;
6161
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
6262
= help: consider moving `baz` to another trait
6363
= help: only type `u32` implements the trait, consider using it directly instead
64-
= note: required for the cast from `Box<u32>` to `Box<dyn Foo>`
64+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6565

6666
error: aborting due to 4 previous errors
6767

tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ fn car() -> dyn NotObjectSafe { //~ ERROR the trait `NotObjectSafe` cannot be ma
2626
B
2727
}
2828

29-
fn cat() -> Box<dyn NotObjectSafe> { //~ ERROR the trait `NotObjectSafe` cannot be made into an
29+
fn cat() -> Box<dyn NotObjectSafe> {
30+
//~^ ERROR cannot be made into an object
31+
//~| ERROR cannot be made into an object
32+
//~| ERROR cannot be made into an object
3033
if true {
31-
return Box::new(A); //~ ERROR cannot be made into an object
34+
return Box::new(A);
3235
}
33-
Box::new(B) //~ ERROR cannot be made into an object
36+
Box::new(B)
3437
}
3538

3639
fn main() {}

tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ LL ~ Box::new(B)
6969
|
7070

7171
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
72-
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:31:16
72+
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:29:17
7373
|
74-
LL | return Box::new(A);
75-
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
74+
LL | fn cat() -> Box<dyn NotObjectSafe> {
75+
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
7676
|
7777
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>
7878
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
@@ -84,7 +84,7 @@ LL | fn foo() -> Self;
8484
= 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:
8585
A
8686
B
87-
= note: required for the cast from `Box<A>` to `Box<(dyn NotObjectSafe + 'static)>`
87+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
8888
help: consider turning `foo` into a method by giving it a `&self` argument
8989
|
9090
LL | fn foo(&self) -> Self;
@@ -95,10 +95,10 @@ LL | fn foo() -> Self where Self: Sized;
9595
| +++++++++++++++++
9696

9797
error[E0038]: the trait `NotObjectSafe` cannot be made into an object
98-
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:33:5
98+
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:29:17
9999
|
100-
LL | Box::new(B)
101-
| ^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
100+
LL | fn cat() -> Box<dyn NotObjectSafe> {
101+
| ^^^^^^^^^^^^^^^^^ `NotObjectSafe` cannot be made into an object
102102
|
103103
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>
104104
--> $DIR/object-unsafe-trait-in-return-position-dyn-trait.rs:3:8
@@ -110,7 +110,7 @@ LL | fn foo() -> Self;
110110
= 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:
111111
A
112112
B
113-
= note: required for the cast from `Box<B>` to `Box<(dyn NotObjectSafe + 'static)>`
113+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
114114
help: consider turning `foo` into a method by giving it a `&self` argument
115115
|
116116
LL | fn foo(&self) -> Self;

tests/ui/issues/issue-18959.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ LL | pub trait Bar: Foo { }
4444
= help: consider moving `foo` to another trait
4545

4646
error[E0038]: the trait `Bar` cannot be made into an object
47-
--> $DIR/issue-18959.rs:19:26
47+
--> $DIR/issue-18959.rs:19:16
4848
|
4949
LL | let test: &dyn Bar = &mut thing;
50-
| ^^^^^^^^^^ `Bar` cannot be made into an object
50+
| ^^^^^^^ `Bar` cannot be made into an object
5151
|
5252
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>
5353
--> $DIR/issue-18959.rs:1:20
@@ -57,7 +57,7 @@ LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
5757
LL | pub trait Bar: Foo { }
5858
| --- this trait cannot be made into an object...
5959
= help: consider moving `foo` to another trait
60-
= note: required for the cast from `&mut Thing` to `&dyn Bar`
60+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
6161

6262
error[E0038]: the trait `Bar` cannot be made into an object
6363
--> $DIR/issue-18959.rs:22:9

tests/ui/kindck/kindck-inherited-copy-bound.curr.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ LL | trait Foo : Copy {
3434
| this trait cannot be made into an object...
3535

3636
error[E0038]: the trait `Foo` cannot be made into an object
37-
--> $DIR/kindck-inherited-copy-bound.rs:28:13
37+
--> $DIR/kindck-inherited-copy-bound.rs:28:20
3838
|
3939
LL | let z = &x as &dyn Foo;
40-
| ^^ `Foo` cannot be made into an object
40+
| ^^^^^^^ `Foo` cannot be made into an object
4141
|
4242
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>
4343
--> $DIR/kindck-inherited-copy-bound.rs:10:13
@@ -46,7 +46,7 @@ LL | trait Foo : Copy {
4646
| --- ^^^^ ...because it requires `Self: Sized`
4747
| |
4848
| this trait cannot be made into an object...
49-
= note: required for the cast from `&Box<{integer}>` to `&dyn Foo`
49+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
5050

5151
error: aborting due to 3 previous errors
5252

tests/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ LL | fn take_param<T:Foo>(foo: &T) { }
2020
| ^^^ required by this bound in `take_param`
2121

2222
error[E0038]: the trait `Foo` cannot be made into an object
23-
--> $DIR/kindck-inherited-copy-bound.rs:28:13
23+
--> $DIR/kindck-inherited-copy-bound.rs:28:20
2424
|
2525
LL | let z = &x as &dyn Foo;
26-
| ^^ `Foo` cannot be made into an object
26+
| ^^^^^^^ `Foo` cannot be made into an object
2727
|
2828
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>
2929
--> $DIR/kindck-inherited-copy-bound.rs:10:13
@@ -32,7 +32,6 @@ LL | trait Foo : Copy {
3232
| --- ^^^^ ...because it requires `Self: Sized`
3333
| |
3434
| this trait cannot be made into an object...
35-
= note: required for the cast from `&Box<i32>` to `&dyn Foo`
3635

3736
error: aborting due to 2 previous errors
3837

tests/ui/object-safety/issue-19538.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ LL | trait Bar: Foo { }
1616
= help: only type `Thing` implements the trait, consider using it directly instead
1717

1818
error[E0038]: the trait `Bar` cannot be made into an object
19-
--> $DIR/issue-19538.rs:17:30
19+
--> $DIR/issue-19538.rs:17:20
2020
|
2121
LL | let test: &mut dyn Bar = &mut thing;
22-
| ^^^^^^^^^^ `Bar` cannot be made into an object
22+
| ^^^^^^^ `Bar` cannot be made into an object
2323
|
2424
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>
2525
--> $DIR/issue-19538.rs:2:8
@@ -31,7 +31,7 @@ LL | trait Bar: Foo { }
3131
| --- this trait cannot be made into an object...
3232
= help: consider moving `foo` to another trait
3333
= help: only type `Thing` implements the trait, consider using it directly instead
34-
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`
34+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3535

3636
error: aborting due to 2 previous errors
3737

0 commit comments

Comments
 (0)