Skip to content

Rollup of 7 pull requests #114857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
971427e
Fix #114608
g0djan Aug 8, 2023
591b547
Point out expectation even if we have RegionsInsufficientlyPolymorphic
compiler-errors Aug 9, 2023
55f8c66
Point at return type when it influences non-first `match` arm
estebank Aug 14, 2023
5021dde
Move scrutinee `HirId` into `MatchSource::TryDesugar`
estebank Aug 14, 2023
298ca67
review comment: add claryfing comment
estebank Aug 14, 2023
58aa903
bless clippy test
estebank Aug 14, 2023
c3889d1
Fix typos in unstable-book
xzmeng Aug 14, 2023
f8bda18
Fix typos in rustc doc platform netbsd
xzmeng Aug 14, 2023
1b6cf74
Fix typos in rustc doc platform aarch64-unknown-teeos
xzmeng Aug 14, 2023
29a1e46
Fix typos in rustc doc codegen-options
xzmeng Aug 14, 2023
aa6c02d
Fix typos in rustc doc platform loongarch-linux
xzmeng Aug 14, 2023
fe6d541
Fix typos in rustc doc platform x86_64h-apple-darwin
xzmeng Aug 14, 2023
1f42be6
Deny FnDef in patterns
compiler-errors Aug 15, 2023
7b69439
add codegen test for issue 107554
khei4 Aug 15, 2023
a741a5a
Document Default for ExitStatus
ijackson Aug 7, 2023
5308a78
Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se
matthiaskrgr Aug 15, 2023
0ac0758
Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se
matthiaskrgr Aug 15, 2023
217e58b
Rollup merge of #114644 - compiler-errors:lt-err, r=wesleywiser
matthiaskrgr Aug 15, 2023
a9aa17c
Rollup merge of #114668 - compiler-errors:match-fn-def, r=petrochenkov
matthiaskrgr Aug 15, 2023
1200703
Rollup merge of #114819 - estebank:issue-78124, r=compiler-errors
matthiaskrgr Aug 15, 2023
1988575
Rollup merge of #114826 - xzmeng:fix-typos, r=JohnTitor
matthiaskrgr Aug 15, 2023
b0896e1
Rollup merge of #114850 - khei4:khei4/trailing_zero_codegen, r=nikic
matthiaskrgr Aug 15, 2023
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
Prev Previous commit
Next Next commit
Point out expectation even if we have RegionsInsufficientlyPolymorphic
  • Loading branch information
compiler-errors committed Aug 9, 2023
commit 591b547e815daa66e79db2ec3bb2c0b885a3e04e
5 changes: 1 addition & 4 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1645,10 +1645,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

augment_error(&mut err);

let is_insufficiently_polymorphic =
matches!(coercion_error, TypeError::RegionsInsufficientlyPolymorphic(..));

if !is_insufficiently_polymorphic && let Some(expr) = expression {
if let Some(expr) = expression {
fcx.emit_coerce_suggestions(
&mut err,
expr,
Expand Down
24 changes: 8 additions & 16 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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) {
return;
}
Expand Down Expand Up @@ -263,22 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 is_insufficiently_polymorphic =
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),
);
}
self.emit_coerce_suggestions(&mut err, expr, expr_ty, expected, expected_ty_expr, Some(e));

(expected, Some(err))
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
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_accessing_field_where_appropriate(cause, &exp_found, diag);
self.suggest_await_on_expect_found(cause, span, &exp_found, diag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/placeholder-pattern-fail.rs:9:47
|
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>)`
found fn pointer `for<'a> fn(Inv<'a>, Inv<'a>)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/hrtb-exists-forall-fn.rs:17:34
|
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)`
found fn pointer `fn(&u32)`
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/regions/higher-ranked-implied.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/higher-ranked-implied.rs:12:16
|
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 ()>)`
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'a ()>)`
Expand All @@ -11,7 +13,9 @@ error[E0308]: mismatched types
--> $DIR/higher-ranked-implied.rs:13:16
|
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 ()>)`
found fn pointer `for<'a, 'b> fn(Inv<&'a &'b ()>, Inv<&'b &'a ()>, Inv<&'b ()>)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
|
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)`
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
|
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)`
found fn item `for<'a, 'b, 'c> fn(&'a mut &isize, &'b mut &isize, &'c mut &isize) {a::<'_, '_, '_>}`
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/regions/regions-lifetime-bounds-on-fns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/regions-lifetime-bounds-on-fns.rs:20:43
|
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)`
found fn item `for<'a, 'b> fn(&'a mut &isize, &'b mut &isize) {a::<'_, '_>}`
Expand Down