Skip to content

Commit 569a842

Browse files
committed
Point at call span that introduced obligation for the arg
1 parent 8a3f712 commit 569a842

File tree

94 files changed

+668
-250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+668
-250
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,9 +2297,19 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
22972297
}
22982298
ObligationCauseCode::FunctionArgumentObligation {
22992299
arg_hir_id: _,
2300-
call_hir_id: _,
2300+
call_hir_id,
23012301
ref parent_code,
23022302
} => {
2303+
let hir = self.tcx.hir();
2304+
if let Some(Node::Expr(hir::Expr {
2305+
kind:
2306+
hir::ExprKind::Call(hir::Expr { span, .. }, _)
2307+
| hir::ExprKind::MethodCall(_, span, ..),
2308+
..
2309+
})) = hir.find(call_hir_id)
2310+
{
2311+
err.span_label(*span, "required by a bound in this call");
2312+
}
23032313
ensure_sufficient_stack(|| {
23042314
self.note_obligation_cause_code(
23052315
err,

src/test/ui/associated-types/associated-types-bound-failure.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: the trait bound `<G as GetToInt>::R: ToInt` is not satisfied
22
--> $DIR/associated-types-bound-failure.rs:19:19
33
|
44
LL | ToInt::to_int(&g.get())
5-
| ^^^^^^^^ the trait `ToInt` is not implemented for `<G as GetToInt>::R`
5+
| ------------- ^^^^^^^^ the trait `ToInt` is not implemented for `<G as GetToInt>::R`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
note: required by `ToInt::to_int`
810
--> $DIR/associated-types-bound-failure.rs:6:5

src/test/ui/associated-types/associated-types-path-2.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied
1313
--> $DIR/associated-types-path-2.rs:29:14
1414
|
1515
LL | f1(2u32, 4u32);
16-
| ^^^^ the trait `Foo` is not implemented for `u32`
16+
| -- ^^^^ the trait `Foo` is not implemented for `u32`
17+
| |
18+
| required by a bound introduced by this call
1719
|
1820
note: required by a bound in `f1`
1921
--> $DIR/associated-types-path-2.rs:13:14
@@ -31,7 +33,9 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied
3133
--> $DIR/associated-types-path-2.rs:35:14
3234
|
3335
LL | f1(2u32, 4i32);
34-
| ^^^^ the trait `Foo` is not implemented for `u32`
36+
| -- ^^^^ the trait `Foo` is not implemented for `u32`
37+
| |
38+
| required by a bound introduced by this call
3539
|
3640
note: required by a bound in `f1`
3741
--> $DIR/associated-types-path-2.rs:13:14

src/test/ui/associated-types/issue-27675-unchecked-bounds.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: the trait bound `T: Copy` is not satisfied
22
--> $DIR/issue-27675-unchecked-bounds.rs:15:31
33
|
44
LL | copy::<dyn Setup<From=T>>(t)
5-
| ^ the trait `Copy` is not implemented for `T`
5+
| ------------------------- ^ the trait `Copy` is not implemented for `T`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
note: required by a bound in `copy`
810
--> $DIR/issue-27675-unchecked-bounds.rs:10:12

src/test/ui/async-await/issue-72442.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: the trait bound `Option<&str>: AsRef<Path>` is not satisfied
22
--> $DIR/issue-72442.rs:12:36
33
|
44
LL | let mut f = File::open(path.to_str())?;
5-
| ^^^^^^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Option<&str>`
5+
| ---------- ^^^^^^^^^^^^^ the trait `AsRef<Path>` is not implemented for `Option<&str>`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
note: required by a bound in `File::open`
810
--> $SRC_DIR/std/src/fs.rs:LL:COL

src/test/ui/box/into-boxed-slice-fail.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation
22
--> $DIR/into-boxed-slice-fail.rs:7:35
33
|
44
LL | let _ = Box::into_boxed_slice(boxed_slice);
5-
| ^^^^^^^^^^^ doesn't have a size known at compile-time
5+
| --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
6+
| |
7+
| required by a bound introduced by this call
68
|
79
= help: the trait `Sized` is not implemented for `[u8]`
810
note: required by `Box::<T, A>::into_boxed_slice`
@@ -24,7 +26,9 @@ error[E0277]: the size for values of type `dyn Debug` cannot be known at compila
2426
--> $DIR/into-boxed-slice-fail.rs:11:35
2527
|
2628
LL | let _ = Box::into_boxed_slice(boxed_trait);
27-
| ^^^^^^^^^^^ doesn't have a size known at compile-time
29+
| --------------------- ^^^^^^^^^^^ doesn't have a size known at compile-time
30+
| |
31+
| required by a bound introduced by this call
2832
|
2933
= help: the trait `Sized` is not implemented for `dyn Debug`
3034
note: required by `Box::<T, A>::into_boxed_slice`

src/test/ui/chalkify/type_inference.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: the trait bound `{float}: Bar` is not satisfied
22
--> $DIR/type_inference.rs:27:14
33
|
44
LL | only_bar(x);
5-
| ^ the trait `Bar` is not implemented for `{float}`
5+
| -------- ^ the trait `Bar` is not implemented for `{float}`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
= help: the following implementations were found:
810
<i32 as Bar>

src/test/ui/closure-expected.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
22
--> $DIR/closure-expected.rs:3:23
33
|
44
LL | let y = x.or_else(4);
5-
| ^ expected an `FnOnce<()>` closure, found `{integer}`
5+
| ------- ^ expected an `FnOnce<()>` closure, found `{integer}`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
= help: the trait `FnOnce<()>` is not implemented for `{integer}`
810
= note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`

src/test/ui/closures/closure-bounds-subtype.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: `F` cannot be shared between threads safely
22
--> $DIR/closure-bounds-subtype.rs:13:22
33
|
44
LL | take_const_owned(f);
5-
| ^ `F` cannot be shared between threads safely
5+
| ---------------- ^ `F` cannot be shared between threads safely
6+
| |
7+
| required by a bound introduced by this call
68
|
79
note: required by a bound in `take_const_owned`
810
--> $DIR/closure-bounds-subtype.rs:4:50

src/test/ui/closures/coerce-unsafe-to-closure.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0277]: expected a `FnOnce<(&str,)>` closure, found `unsafe extern "rust-i
22
--> $DIR/coerce-unsafe-to-closure.rs:2:44
33
|
44
LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
5-
| ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
5+
| --- ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
6+
| |
7+
| required by a bound introduced by this call
68
|
79
= help: the trait `FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {transmute::<_, _>}`
810

0 commit comments

Comments
 (0)