Show source of ambiguity in a few more places

This commit is contained in:
Michael Goulet 2022-06-25 09:28:27 -07:00
parent f44ae98cee
commit ca0105ba4e
15 changed files with 35 additions and 20 deletions

View file

@ -2020,7 +2020,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
subst, subst,
impl_candidates, impl_candidates,
ErrorCode::E0283, ErrorCode::E0283,
false, true,
); );
let obligation = Obligation::new( let obligation = Obligation::new(
@ -2132,7 +2132,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
a.into(), a.into(),
vec![], vec![],
ErrorCode::E0282, ErrorCode::E0282,
false, true,
) )
} }
ty::PredicateKind::Projection(data) => { ty::PredicateKind::Projection(data) => {
@ -2149,7 +2149,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
self_ty.into(), self_ty.into(),
vec![], vec![],
ErrorCode::E0284, ErrorCode::E0284,
false, true,
); );
err.note(&format!("cannot satisfy `{}`", predicate)); err.note(&format!("cannot satisfy `{}`", predicate));
err err

View file

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

View file

@ -3,6 +3,9 @@ error[E0282]: type annotations needed for `Result<(), QualifiedError<_>>`
| |
LL | let x = || -> Result<_, QualifiedError<_>> { LL | let x = || -> Result<_, QualifiedError<_>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | infallible()?;
| ------------- type must be known at this point
| |
help: try giving this closure an explicit return type help: try giving this closure an explicit return type
| |

View file

@ -2,7 +2,7 @@ error[E0283]: type annotations needed for `Foo<i32, &str, W, Z>`
--> $DIR/erase-type-params-in-label.rs:2:9 --> $DIR/erase-type-params-in-label.rs:2:9
| |
LL | let foo = foo(1, ""); LL | let foo = foo(1, "");
| ^^^ | ^^^ --- type must be known at this point
| |
= note: cannot satisfy `_: Default` = note: cannot satisfy `_: Default`
note: required by a bound in `foo` note: required by a bound in `foo`
@ -23,7 +23,7 @@ error[E0283]: type annotations needed for `Bar<i32, &str, Z>`
--> $DIR/erase-type-params-in-label.rs:5:9 --> $DIR/erase-type-params-in-label.rs:5:9
| |
LL | let bar = bar(1, ""); LL | let bar = bar(1, "");
| ^^^ | ^^^ --- type must be known at this point
| |
= note: cannot satisfy `_: Default` = note: cannot satisfy `_: Default`
note: required by a bound in `bar` note: required by a bound in `bar`

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `&[_; 0]`
--> $DIR/issue-7813.rs:2:9 --> $DIR/issue-7813.rs:2:9
| |
LL | let v = &[]; LL | let v = &[];
| ^ | ^ --- type must be known at this point
| |
help: consider giving `v` an explicit type, where the placeholders `_` are specified help: consider giving `v` an explicit type, where the placeholders `_` are specified
| |

View file

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

View file

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
--> $DIR/suggest-closure-return-type-2.rs:4:18 --> $DIR/suggest-closure-return-type-2.rs:4:18
| |
LL | unbound_drop(|| { [] }) LL | unbound_drop(|| { [] })
| ^^ | ^^ -- type must be known at this point
| |
help: try giving this closure an explicit return type help: try giving this closure an explicit return type
| |

View file

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
--> $DIR/suggest-closure-return-type-3.rs:4:18 --> $DIR/suggest-closure-return-type-3.rs:4:18
| |
LL | unbound_drop(|| []); LL | unbound_drop(|| []);
| ^^ | ^^ -- type must be known at this point
| |
help: try giving this closure an explicit return type help: try giving this closure an explicit return type
| |

View file

@ -26,7 +26,9 @@ error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:8:10 --> $DIR/issue-77982.rs:8:10
| |
LL | opts.get(opt.as_ref()); LL | opts.get(opt.as_ref());
| ^^^ cannot infer type of the type parameter `Q` declared on the associated function `get` | ^^^ ------ type must be known at this point
| |
| cannot infer type of the type parameter `Q` declared on the associated function `get`
| |
= note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`: = note: multiple `impl`s satisfying `String: AsRef<_>` found in the following crates: `alloc`, `std`:
- impl AsRef<OsStr> for String; - impl AsRef<OsStr> for String;
@ -42,7 +44,9 @@ error[E0283]: type annotations needed
--> $DIR/issue-77982.rs:13:59 --> $DIR/issue-77982.rs:13:59
| |
LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect();
| ^^^^ | --------- ^^^^
| |
| type must be known at this point
| |
= note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`: = note: multiple `impl`s satisfying `u32: From<_>` found in the following crates: `core`, `std`:
- impl From<Ipv4Addr> for u32; - impl From<Ipv4Addr> for u32;
@ -59,7 +63,7 @@ error[E0283]: type annotations needed for `Box<T>`
--> $DIR/issue-77982.rs:36:9 --> $DIR/issue-77982.rs:36:9
| |
LL | let _ = ().foo(); LL | let _ = ().foo();
| ^ | ^ --- type must be known at this point
| |
note: multiple `impl`s satisfying `(): Foo<'_, _>` found note: multiple `impl`s satisfying `(): Foo<'_, _>` found
--> $DIR/issue-77982.rs:29:1 --> $DIR/issue-77982.rs:29:1
@ -77,7 +81,7 @@ error[E0283]: type annotations needed for `Box<T>`
--> $DIR/issue-77982.rs:40:9 --> $DIR/issue-77982.rs:40:9
| |
LL | let _ = (&()).bar(); LL | let _ = (&()).bar();
| ^ | ^ --- type must be known at this point
| |
note: multiple `impl`s satisfying `&(): Bar<'_, _>` found note: multiple `impl`s satisfying `&(): Bar<'_, _>` found
--> $DIR/issue-77982.rs:32:1 --> $DIR/issue-77982.rs:32:1

View file

@ -2,7 +2,7 @@ error[E0282]: type annotations needed for `[_; 0]`
--> $DIR/cannot_infer_local_or_array.rs:2:9 --> $DIR/cannot_infer_local_or_array.rs:2:9
| |
LL | let x = []; LL | let x = [];
| ^ | ^ -- type must be known at this point
| |
help: consider giving `x` an explicit type, where the placeholders `_` are specified help: consider giving `x` an explicit type, where the placeholders `_` are specified
| |