Point out expectation even if we have RegionsInsufficientlyPolymorphic
This commit is contained in:
parent
f525bb4e2a
commit
591b547e81
@ -1645,10 +1645,7 @@ pub(crate) fn coerce_inner<'a>(
|
|||||||
|
|
||||||
augment_error(&mut err);
|
augment_error(&mut err);
|
||||||
|
|
||||||
let is_insufficiently_polymorphic =
|
if let Some(expr) = expression {
|
||||||
matches!(coercion_error, TypeError::RegionsInsufficientlyPolymorphic(..));
|
|
||||||
|
|
||||||
if !is_insufficiently_polymorphic && let Some(expr) = expression {
|
|
||||||
fcx.emit_coerce_suggestions(
|
fcx.emit_coerce_suggestions(
|
||||||
&mut err,
|
&mut err,
|
||||||
expr,
|
expr,
|
||||||
|
@ -84,6 +84,13 @@ pub fn emit_coerce_suggestions(
|
|||||||
|
|
||||||
self.annotate_expected_due_to_let_ty(err, expr, error);
|
self.annotate_expected_due_to_let_ty(err, expr, error);
|
||||||
|
|
||||||
|
// FIXME(#73154): For now, we do leak check when coercing function
|
||||||
|
// pointers in typeck, instead of only during borrowck. This can lead
|
||||||
|
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
|
||||||
|
if matches!(error, Some(TypeError::RegionsInsufficientlyPolymorphic(..))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if self.is_destruct_assignment_desugaring(expr) {
|
if self.is_destruct_assignment_desugaring(expr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -263,22 +270,7 @@ pub fn demand_coerce_diag(
|
|||||||
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
|
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
|
||||||
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
|
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
|
||||||
|
|
||||||
let is_insufficiently_polymorphic =
|
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));
|
||||||
matches!(e, TypeError::RegionsInsufficientlyPolymorphic(..));
|
|
||||||
|
|
||||||
// FIXME(#73154): For now, we do leak check when coercing function
|
|
||||||
// pointers in typeck, instead of only during borrowck. This can lead
|
|
||||||
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
|
|
||||||
if !is_insufficiently_polymorphic {
|
|
||||||
self.emit_coerce_suggestions(
|
|
||||||
&mut err,
|
|
||||||
expr,
|
|
||||||
expr_ty,
|
|
||||||
expected,
|
|
||||||
expected_ty_expr,
|
|
||||||
Some(e),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
(expected, Some(err))
|
(expected, Some(err))
|
||||||
}
|
}
|
||||||
|
@ -1927,7 +1927,12 @@ enum Similar<'tcx> {
|
|||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|
||||||
if should_suggest_fixes {
|
// FIXME(#73154): For now, we do leak check when coercing function
|
||||||
|
// pointers in typeck, instead of only during borrowck. This can lead
|
||||||
|
// to these `RegionsInsufficientlyPolymorphic` errors that aren't helpful.
|
||||||
|
if should_suggest_fixes
|
||||||
|
&& !matches!(terr, TypeError::RegionsInsufficientlyPolymorphic(..))
|
||||||
|
{
|
||||||
self.suggest_tuple_pattern(cause, &exp_found, diag);
|
self.suggest_tuple_pattern(cause, &exp_found, diag);
|
||||||
self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
|
self.suggest_accessing_field_where_appropriate(cause, &exp_found, diag);
|
||||||
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
|
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/placeholder-pattern-fail.rs:9:47
|
--> $DIR/placeholder-pattern-fail.rs:9:47
|
||||||
|
|
|
|
||||||
LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub;
|
LL | let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub;
|
||||||
| ^^^ one type is more general than the other
|
| -------------------------------- ^^^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)`
|
= note: expected fn pointer `for<'a, 'b> fn(Inv<'a>, Inv<'b>)`
|
||||||
found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)`
|
found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)`
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/hrtb-exists-forall-fn.rs:17:34
|
--> $DIR/hrtb-exists-forall-fn.rs:17:34
|
||||||
|
|
|
|
||||||
LL | let _: for<'b> fn(&'b u32) = foo();
|
LL | let _: for<'b> fn(&'b u32) = foo();
|
||||||
| ^^^^^ one type is more general than the other
|
| ------------------- ^^^^^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'b> fn(&'b u32)`
|
= note: expected fn pointer `for<'b> fn(&'b u32)`
|
||||||
found fn pointer `fn(&u32)`
|
found fn pointer `fn(&u32)`
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/higher-ranked-implied.rs:12:16
|
--> $DIR/higher-ranked-implied.rs:12:16
|
||||||
|
|
|
|
||||||
LL | let y: B = x;
|
LL | let y: B = x;
|
||||||
| ^ one type is more general than the other
|
| - ^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
|
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
|
||||||
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
|
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
|
||||||
@ -11,7 +13,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/higher-ranked-implied.rs:13:16
|
--> $DIR/higher-ranked-implied.rs:13:16
|
||||||
|
|
|
|
||||||
LL | let _: A = y;
|
LL | let _: A = y;
|
||||||
| ^ one type is more general than the other
|
| - ^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
|
= note: expected fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
|
||||||
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
|
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
|
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
|
||||||
|
|
|
|
||||||
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
||||||
| ^ one type is more general than the other
|
| ---------------------------- ^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
|
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
|
||||||
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
|
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
|
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
|
||||||
|
|
|
|
||||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||||
| ^ one type is more general than the other
|
| ----------------------------------------- ^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)`
|
= note: expected fn pointer `for<'a, 'b, 'c, 'd, 'e, 'f> fn(&'a mut &'b isize, &'c mut &'d isize, &'e mut &'f isize)`
|
||||||
found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}`
|
found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}`
|
||||||
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||||||
--> $DIR/regions-lifetime-bounds-on-fns.rs:20:43
|
--> $DIR/regions-lifetime-bounds-on-fns.rs:20:43
|
||||||
|
|
|
|
||||||
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
||||||
| ^ one type is more general than the other
|
| ---------------------------- ^ one type is more general than the other
|
||||||
|
| |
|
||||||
|
| expected due to this
|
||||||
|
|
|
|
||||||
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
|
= note: expected fn pointer `for<'a, 'b, 'c, 'd> fn(&'a mut &'b isize, &'c mut &'d isize)`
|
||||||
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
|
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
|
||||||
|
Loading…
Reference in New Issue
Block a user