diff options
| author | Michael Goulet <michael@errs.io> | 2022-04-02 15:27:14 -0700 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-04-04 19:37:14 -0700 |
| commit | a8877cf73823351cee2a871bd5387628054fabea (patch) | |
| tree | 83f87c01226c4040870994f603a8db0a802bd8eb /compiler | |
| parent | 60e50fc1cfe0bb693a5f4f93eb83ef70854531e3 (diff) | |
| download | rust-a8877cf73823351cee2a871bd5387628054fabea.tar.gz rust-a8877cf73823351cee2a871bd5387628054fabea.zip | |
Handle reporting invariance of fn pointer
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index e63450a1f58..3e7999b43ab 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -358,6 +358,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ); (desc, note) } + ty::FnDef(def_id, _) => { + let name = self.infcx.tcx.item_name(*def_id); + let identity_substs = + InternalSubsts::identity_for_item(self.infcx.tcx, *def_id); + let desc = format!("a function pointer to `{name}`"); + let note = format!( + "the function `{name}` is invariant over the parameter `{}`", + identity_substs[param_index as usize] + ); + (desc, note) + } _ => panic!("Unexpected type {:?}", ty), }; diag.note(&format!("requirement occurs because of {desc}",)); |
