Skip to content

Fix ICE: fn_arg_names: unexpected item DefId(..) #118526

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

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
&& !expected_inputs.is_empty()
&& expected_inputs.len() == found_inputs.len()
&& let Some(typeck) = &self.typeck_results
&& let Res::Def(_, fn_def_id) = typeck.qpath_res(&path, *arg_hir_id)
&& let Res::Def(res_kind, fn_def_id) = typeck.qpath_res(&path, *arg_hir_id)
&& res_kind.is_fn_like()
{
let closure: Vec<_> = self
.tcx
Expand Down Expand Up @@ -2155,7 +2156,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.map(|(name, ty)| {
format!(
"{name}{}",
if ty.has_infer_types() { String::new() } else { format!(": {ty}") }
if ty.has_infer_types() {
String::new()
} else if ty.references_error() {
": /* type */".to_string()
} else {
format!(": {ty}")
}
)
})
.collect();
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/mismatched_types/issue-118510.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pub enum Sexpr<'a, S> {
Ident(&'a mut S),
}

fn map<Foo, T, F: FnOnce(&Foo) -> T>(f: F) {}

fn main() {
map(Sexpr::Ident);
//~^ ERROR type mismatch in function arguments
}
26 changes: 26 additions & 0 deletions tests/ui/mismatched_types/issue-118510.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0631]: type mismatch in function arguments
--> $DIR/issue-118510.rs:8:9
|
LL | Ident(&'a mut S),
| ----- found signature defined here
...
LL | map(Sexpr::Ident);
| --- ^^^^^^^^^^^^ expected due to this
| |
| required by a bound introduced by this call
|
= note: expected function signature `for<'a> fn(&'a _) -> _`
found function signature `fn(&mut _) -> _`
note: required by a bound in `map`
--> $DIR/issue-118510.rs:5:19
|
LL | fn map<Foo, T, F: FnOnce(&Foo) -> T>(f: F) {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `map`
help: consider wrapping the function in a closure
|
LL | map(|arg0| Sexpr::Ident(&mut *arg0));
| ++++++ ++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0631`.