Use final path segment for diagnostic

This commit is contained in:
Michael Goulet 2025-03-05 23:06:54 +00:00
parent 07b5eeebc9
commit 181ef540cf
3 changed files with 4 additions and 4 deletions

View File

@ -1265,7 +1265,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
CallableKind::Function
};
maybe_emit_help(def_id, path.segments[0].ident, args, callable_kind);
maybe_emit_help(def_id, path.segments.last().unwrap().ident, args, callable_kind);
}
hir::ExprKind::MethodCall(method, _receiver, args, _span) => {
let Some(def_id) =

View File

@ -20,7 +20,7 @@ help: the return type of this call is `{integer}` due to the type of the argumen
LL | <F as FnOnce(&mut u8)>::call_once(f, 1)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^
| |
| this argument influences the return type of `FnOnce`
| this argument influences the return type of `call_once`
note: method defined here
--> $SRC_DIR/core/src/ops/function.rs:LL:COL

View File

@ -25,7 +25,7 @@ help: the return type of this call is `u32` due to the type of the argument pass
LL | <i32 as Add<i32>>::add(1u32, 2);
| ^^^^^^^^^^^^^^^^^^^^^^^----^^^^
| |
| this argument influences the return type of `Add`
| this argument influences the return type of `add`
note: method defined here
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: change the type of the numeric literal from `u32` to `i32`
@ -48,7 +48,7 @@ help: the return type of this call is `u32` due to the type of the argument pass
LL | <i32 as Add<i32>>::add(1, 2u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----^
| |
| this argument influences the return type of `Add`
| this argument influences the return type of `add`
note: method defined here
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: change the type of the numeric literal from `u32` to `i32`