Point out the type of more expressions on bad ?
This commit is contained in:
parent
e565eeed78
commit
8ef535e03d
3 changed files with 6 additions and 8 deletions
|
@ -961,14 +961,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
let Some(typeck) = &self.typeck_results else {
|
||||
return false;
|
||||
};
|
||||
let Some((ObligationCauseCode::QuestionMark, Some(y))) =
|
||||
obligation.cause.code().parent_with_predicate()
|
||||
else {
|
||||
let ObligationCauseCode::QuestionMark = obligation.cause.code().peel_derives() else {
|
||||
return false;
|
||||
};
|
||||
if !self.tcx.is_diagnostic_item(sym::FromResidual, y.def_id()) {
|
||||
return false;
|
||||
}
|
||||
let self_ty = trait_pred.skip_binder().self_ty();
|
||||
let found_ty = trait_pred.skip_binder().trait_ref.args.get(1).and_then(|a| a.as_type());
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ fn foo() -> Result<(), Box<dyn std::error::Error>> { //~ NOTE required `E: std::
|
|||
//~| NOTE the trait `std::error::Error` is not implemented for `E`
|
||||
//~| NOTE the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
//~| NOTE required for `Box<dyn std::error::Error>` to implement `From<E>`
|
||||
//~| NOTE this has type `Result<_, E>`
|
||||
//~| NOTE in this expansion
|
||||
//~| NOTE in this expansion
|
||||
//~| NOTE in this expansion
|
||||
|
|
|
@ -4,13 +4,15 @@ error[E0277]: `?` couldn't convert the error: `E: std::error::Error` is not sati
|
|||
LL | fn foo() -> Result<(), Box<dyn std::error::Error>> {
|
||||
| -------------------------------------- required `E: std::error::Error` because of this
|
||||
LL | Ok(bar()?)
|
||||
| ^ the trait `std::error::Error` is not implemented for `E`
|
||||
| -----^ the trait `std::error::Error` is not implemented for `E`
|
||||
| |
|
||||
| this has type `Result<_, E>`
|
||||
|
|
||||
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
|
||||
= 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:15:13
|
||||
--> $DIR/bad-question-mark-on-trait-object.rs:16:13
|
||||
|
|
||||
LL | fn bat() -> Result<(), X> {
|
||||
| ------------- expected `X` because of this
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue