about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-03-05 23:06:54 +0000
committerMichael Goulet <michael@errs.io>2025-03-05 23:06:54 +0000
commit181ef540cfa6f7819c999ba2c9c5036f86fff238 (patch)
tree69c1b09f1ea35b25483e15500111f971a4630e8f
parent07b5eeebc948743eaadb32a83d23931fd8854fe8 (diff)
downloadrust-181ef540cfa6f7819c999ba2c9c5036f86fff238.tar.gz
rust-181ef540cfa6f7819c999ba2c9c5036f86fff238.zip
Use final path segment for diagnostic
-rw-r--r--compiler/rustc_hir_typeck/src/demand.rs2
-rw-r--r--tests/ui/typeck/issue-84768.stderr2
-rw-r--r--tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr4
3 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index 85131f6195f..aa917ee07ff 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -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) =
diff --git a/tests/ui/typeck/issue-84768.stderr b/tests/ui/typeck/issue-84768.stderr
index 72784ba59c9..8a2200cbf68 100644
--- a/tests/ui/typeck/issue-84768.stderr
+++ b/tests/ui/typeck/issue-84768.stderr
@@ -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
 
diff --git a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr
index 05071834883..edee7c4f5a1 100644
--- a/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr
+++ b/tests/ui/ufcs/ufcs-qpath-self-mismatch.stderr
@@ -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`