mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
Auto merge of #118526 - sjwang05:issue-118510, r=petrochenkov
Fix ICE: `fn_arg_names: unexpected item DefId(..)` Fixes #118510
This commit is contained in:
commit
21d88b32cb
@ -2112,7 +2112,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
&& !expected_inputs.is_empty()
|
&& !expected_inputs.is_empty()
|
||||||
&& expected_inputs.len() == found_inputs.len()
|
&& expected_inputs.len() == found_inputs.len()
|
||||||
&& let Some(typeck) = &self.typeck_results
|
&& 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
|
let closure: Vec<_> = self
|
||||||
.tcx
|
.tcx
|
||||||
@ -2155,7 +2156,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
.map(|(name, ty)| {
|
.map(|(name, ty)| {
|
||||||
format!(
|
format!(
|
||||||
"{name}{}",
|
"{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();
|
.collect();
|
||||||
|
10
tests/ui/mismatched_types/issue-118510.rs
Normal file
10
tests/ui/mismatched_types/issue-118510.rs
Normal file
@ -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
tests/ui/mismatched_types/issue-118510.stderr
Normal file
26
tests/ui/mismatched_types/issue-118510.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user