Skip to content

Commit 7af208f

Browse files
authored
Rollup merge of #150570 - Human9000-bit:main, r=jieyouxu
Removed confusing diagnostics note for trait required for `?` operator use - **test: modified `bad-question-mark-on-trait-objects` to match expected behavior** - **removed confusing message from diagnostics** fixes [#150527](#150527)
2 parents 78376fd + 97e5cab commit 7af208f

3 files changed

Lines changed: 3 additions & 13 deletions

File tree

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,10 +1288,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
12881288
self.tcx.def_span(def.did()),
12891289
format!("`{self_ty}` needs to implement `From<{ty}>`"),
12901290
);
1291-
err.span_note(
1292-
self.tcx.def_span(found.did()),
1293-
format!("alternatively, `{ty}` needs to implement `Into<{self_ty}>`"),
1294-
);
12951291
}
12961292
(ty::Adt(def, _), None) if def.did().is_local() => {
12971293
let trait_path = self.tcx.short_string(

tests/ui/try-trait/bad-question-mark-on-trait-object.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
struct E;
22
//~^ NOTE `E` needs to implement `std::error::Error`
3-
//~| NOTE alternatively, `E` needs to implement `Into<X>`
43
struct X; //~ NOTE `X` needs to implement `From<E>`
54

65
fn foo() -> Result<(), Box<dyn std::error::Error>> { //~ NOTE required `E: std::error::Error` because of this

tests/ui/try-trait/bad-question-mark-on-trait-object.stderr

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `?` couldn't convert the error: `E: std::error::Error` is not satisfied
2-
--> $DIR/bad-question-mark-on-trait-object.rs:7:13
2+
--> $DIR/bad-question-mark-on-trait-object.rs:6:13
33
|
44
LL | fn foo() -> Result<(), Box<dyn std::error::Error>> {
55
| -------------------------------------- required `E: std::error::Error` because of this
@@ -17,7 +17,7 @@ LL | struct E;
1717
= note: required for `Box<dyn std::error::Error>` to implement `From<E>`
1818

1919
error[E0277]: `?` couldn't convert the error to `X`
20-
--> $DIR/bad-question-mark-on-trait-object.rs:18:13
20+
--> $DIR/bad-question-mark-on-trait-object.rs:17:13
2121
|
2222
LL | fn bat() -> Result<(), X> {
2323
| ------------- expected `X` because of this
@@ -27,15 +27,10 @@ LL | Ok(bar()?)
2727
| this can't be annotated with `?` because it has type `Result<_, E>`
2828
|
2929
note: `X` needs to implement `From<E>`
30-
--> $DIR/bad-question-mark-on-trait-object.rs:4:1
30+
--> $DIR/bad-question-mark-on-trait-object.rs:3:1
3131
|
3232
LL | struct X;
3333
| ^^^^^^^^
34-
note: alternatively, `E` needs to implement `Into<X>`
35-
--> $DIR/bad-question-mark-on-trait-object.rs:1:1
36-
|
37-
LL | struct E;
38-
| ^^^^^^^^
3934
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
4035

4136
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)