Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1287,10 +1287,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.tcx.def_span(def.did()),
format!("`{self_ty}` needs to implement `From<{ty}>`"),
);
err.span_note(
self.tcx.def_span(found.did()),
format!("alternatively, `{ty}` needs to implement `Into<{self_ty}>`"),
);
}
(ty::Adt(def, _), None) if def.did().is_local() => {
let trait_path = self.tcx.short_string(
Expand Down
1 change: 0 additions & 1 deletion tests/ui/try-trait/bad-question-mark-on-trait-object.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
struct E;
//~^ NOTE `E` needs to implement `std::error::Error`
//~| NOTE alternatively, `E` needs to implement `Into<X>`
struct X; //~ NOTE `X` needs to implement `From<E>`

fn foo() -> Result<(), Box<dyn std::error::Error>> { //~ NOTE required `E: std::error::Error` because of this
Expand Down
11 changes: 3 additions & 8 deletions tests/ui/try-trait/bad-question-mark-on-trait-object.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: `?` couldn't convert the error: `E: std::error::Error` is not satisfied
--> $DIR/bad-question-mark-on-trait-object.rs:7:13
--> $DIR/bad-question-mark-on-trait-object.rs:6:13
|
LL | fn foo() -> Result<(), Box<dyn std::error::Error>> {
| -------------------------------------- required `E: std::error::Error` because of this
Expand All @@ -17,7 +17,7 @@ LL | struct E;
= note: required for `Box<dyn std::error::Error>` to implement `From<E>`

error[E0277]: `?` couldn't convert the error to `X`
--> $DIR/bad-question-mark-on-trait-object.rs:18:13
--> $DIR/bad-question-mark-on-trait-object.rs:17:13
|
LL | fn bat() -> Result<(), X> {
| ------------- expected `X` because of this
Expand All @@ -27,15 +27,10 @@ LL | Ok(bar()?)
| this can't be annotated with `?` because it has type `Result<_, E>`
|
note: `X` needs to implement `From<E>`
--> $DIR/bad-question-mark-on-trait-object.rs:4:1
--> $DIR/bad-question-mark-on-trait-object.rs:3:1
|
LL | struct X;
| ^^^^^^^^
note: alternatively, `E` needs to implement `Into<X>`
--> $DIR/bad-question-mark-on-trait-object.rs:1:1
|
LL | struct E;
| ^^^^^^^^
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait

error: aborting due to 2 previous errors
Expand Down
Loading