Skip to content

Commit ca0105b

Browse files
Show source of ambiguity in a few more places
1 parent f44ae98 commit ca0105b

15 files changed

+35
-20
lines changed

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
20202020
subst,
20212021
impl_candidates,
20222022
ErrorCode::E0283,
2023-
false,
2023+
true,
20242024
);
20252025

20262026
let obligation = Obligation::new(
@@ -2132,7 +2132,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21322132
a.into(),
21332133
vec![],
21342134
ErrorCode::E0282,
2135-
false,
2135+
true,
21362136
)
21372137
}
21382138
ty::PredicateKind::Projection(data) => {
@@ -2149,7 +2149,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21492149
self_ty.into(),
21502150
vec![],
21512151
ErrorCode::E0284,
2152-
false,
2152+
true,
21532153
);
21542154
err.note(&format!("cannot satisfy `{}`", predicate));
21552155
err

src/test/ui/const-generics/generic_arg_infer/issue-91614.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0283]: type annotations needed for `Mask<_, LANES>`
22
--> $DIR/issue-91614.rs:6:9
33
|
44
LL | let y = Mask::<_, _>::splat(false);
5-
| ^
5+
| ^ ------------------- type must be known at this point
66
|
77
= note: cannot satisfy `_: MaskElement`
88
note: required by a bound in `Mask::<T, LANES>::splat`

src/test/ui/inference/cannot-infer-partial-try-return.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `Result<(), QualifiedError<_>>`
33
|
44
LL | let x = || -> Result<_, QualifiedError<_>> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
LL |
7+
LL | infallible()?;
8+
| ------------- type must be known at this point
69
|
710
help: try giving this closure an explicit return type
811
|

src/test/ui/inference/erase-type-params-in-label.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0283]: type annotations needed for `Foo<i32, &str, W, Z>`
22
--> $DIR/erase-type-params-in-label.rs:2:9
33
|
44
LL | let foo = foo(1, "");
5-
| ^^^
5+
| ^^^ --- type must be known at this point
66
|
77
= note: cannot satisfy `_: Default`
88
note: required by a bound in `foo`
@@ -23,7 +23,7 @@ error[E0283]: type annotations needed for `Bar<i32, &str, Z>`
2323
--> $DIR/erase-type-params-in-label.rs:5:9
2424
|
2525
LL | let bar = bar(1, "");
26-
| ^^^
26+
| ^^^ --- type must be known at this point
2727
|
2828
= note: cannot satisfy `_: Default`
2929
note: required by a bound in `bar`

src/test/ui/inference/issue-72616.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
22
--> $DIR/issue-72616.rs:20:37
33
|
44
LL | if String::from("a") == "a".try_into().unwrap() {}
5-
| ^^^^^^^^
5+
| -- ^^^^^^^^
6+
| |
7+
| type must be known at this point
68
|
79
= note: multiple `impl`s satisfying `String: PartialEq<_>` found in the `alloc` crate:
810
- impl PartialEq for String;

src/test/ui/inference/issue-72690.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ error[E0283]: type annotations needed for `&T`
5555
--> $DIR/issue-72690.rs:17:9
5656
|
5757
LL | let _ = "x".as_ref();
58-
| ^
58+
| ^ ------ type must be known at this point
5959
|
6060
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
6161
- impl AsRef<OsStr> for str;

src/test/ui/inference/issue-86162-1.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
22
--> $DIR/issue-86162-1.rs:7:9
33
|
44
LL | foo(gen()); //<- Do not suggest `foo::<impl Clone>()`!
5-
| ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
5+
| --- ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
6+
| |
7+
| type must be known at this point
68
|
79
= note: cannot satisfy `_: Clone`
810
note: required by a bound in `foo`

src/test/ui/inference/issue-86162-2.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0283]: type annotations needed
22
--> $DIR/issue-86162-2.rs:12:14
33
|
44
LL | Foo::bar(gen()); //<- Do not suggest `Foo::bar::<impl Clone>()`!
5-
| ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
5+
| -------- ^^^ cannot infer type of the type parameter `T` declared on the function `gen`
6+
| |
7+
| type must be known at this point
68
|
79
= note: cannot satisfy `_: Clone`
810
note: required by a bound in `Foo::bar`

src/test/ui/issues/issue-69455.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ error[E0283]: type annotations needed
1414
--> $DIR/issue-69455.rs:29:41
1515
|
1616
LL | println!("{}", 23u64.test(xs.iter().sum()));
17-
| ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
17+
| ---- ^^^ cannot infer type of the type parameter `S` declared on the associated function `sum`
18+
| |
19+
| type must be known at this point
1820
|
1921
note: multiple `impl`s satisfying `u64: Test<_>` found
2022
--> $DIR/issue-69455.rs:11:1

src/test/ui/issues/issue-7813.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `&[_; 0]`
22
--> $DIR/issue-7813.rs:2:9
33
|
44
LL | let v = &[];
5-
| ^
5+
| ^ --- type must be known at this point
66
|
77
help: consider giving `v` an explicit type, where the placeholders `_` are specified
88
|

src/test/ui/suggestions/suggest-closure-return-type-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
22
--> $DIR/suggest-closure-return-type-1.rs:4:18
33
|
44
LL | unbound_drop(|| -> _ { [] });
5-
| ^^^^^^^
5+
| ^^^^^^^ -- type must be known at this point
66
|
77
help: try giving this closure an explicit return type
88
|

src/test/ui/suggestions/suggest-closure-return-type-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
22
--> $DIR/suggest-closure-return-type-2.rs:4:18
33
|
44
LL | unbound_drop(|| { [] })
5-
| ^^
5+
| ^^ -- type must be known at this point
66
|
77
help: try giving this closure an explicit return type
88
|

src/test/ui/suggestions/suggest-closure-return-type-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
22
--> $DIR/suggest-closure-return-type-3.rs:4:18
33
|
44
LL | unbound_drop(|| []);
5-
| ^^
5+
| ^^ -- type must be known at this point
66
|
77
help: try giving this closure an explicit return type
88
|

src/test/ui/traits/issue-77982.stderr

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ error[E0283]: type annotations needed
2626
--> $DIR/issue-77982.rs:8:10
2727
|
2828
LL | opts.get(opt.as_ref());
29-
| ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get`
29+
| ^^^ ------ type must be known at this point
30+
| |
31+
| cannot infer type of the type parameter `Q` declared on the associated function `get`
3032
|
3133
= note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`:
3234
- impl AsRef<OsStr> for String;
@@ -42,7 +44,9 @@ error[E0283]: type annotations needed
4244
--> $DIR/issue-77982.rs:13:59
4345
|
4446
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
45-
| ^^^^
47+
| --------- ^^^^
48+
| |
49+
| type must be known at this point
4650
|
4751
= note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
4852
- impl From<Ipv4Addr> for u32;
@@ -59,7 +63,7 @@ error[E0283]: type annotations needed for `Box<T>`
5963
--> $DIR/issue-77982.rs:36:9
6064
|
6165
LL | let _ = ().foo();
62-
| ^
66+
| ^ --- type must be known at this point
6367
|
6468
note: multiple `impl`s satisfying `(): Foo<'_, _>` found
6569
--> $DIR/issue-77982.rs:29:1
@@ -77,7 +81,7 @@ error[E0283]: type annotations needed for `Box<T>`
7781
--> $DIR/issue-77982.rs:40:9
7882
|
7983
LL | let _ = (&()).bar();
80-
| ^
84+
| ^ --- type must be known at this point
8185
|
8286
note: multiple `impl`s satisfying `&(): Bar<'_, _>` found
8387
--> $DIR/issue-77982.rs:32:1

src/test/ui/type/type-check/cannot_infer_local_or_array.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
22
--> $DIR/cannot_infer_local_or_array.rs:2:9
33
|
44
LL | let x = [];
5-
| ^
5+
| ^ -- type must be known at this point
66
|
77
help: consider giving `x` an explicit type, where the placeholders `_` are specified
88
|

0 commit comments

Comments
 (0)